From 1804874beae006b6ccdcbab259dea002a6cd41b4 Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Sun, 11 Nov 2007 23:21:03 +0000 Subject: [PATCH] tidying up, finallying correct close behavior git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@701 6778bc44-b910-0410-a7a0-be141de4315d --- .../QPulseAudioThread.cpp | 11 ++++---- .../qprojectM-pulseaudio.cpp | 26 +++++-------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/qprojectM-pulseaudio/QPulseAudioThread.cpp b/src/qprojectM-pulseaudio/QPulseAudioThread.cpp index a21005917..17e7069c3 100644 --- a/src/qprojectM-pulseaudio/QPulseAudioThread.cpp +++ b/src/qprojectM-pulseaudio/QPulseAudioThread.cpp @@ -3,7 +3,7 @@ #include "libprojectM/projectM.hpp" #define BUFSIZE 1024 -PulseAudioThread::PulseAudioThread(int _argc, char **_argv, projectM * _projectM, QObject * parent) : QThread(parent), argc(_argc), argv(_argv), s(0) , m_projectM(_projectM) { +PulseAudioThread::PulseAudioThread(int _argc, char **_argv, projectM * _projectM, QObject * parent) : QThread(parent), argc(_argc), argv(_argv), s(0) , m_projectM(_projectM), m_timer(0) { m_timer = new QTimer(this); @@ -15,7 +15,7 @@ void PulseAudioThread::cleanup() { pa_simple_free ( s ); s = 0; - qDebug() << "pulse audio quit"; + //qDebug() << "pulse audio quit"; return ; } @@ -42,7 +42,7 @@ void PulseAudioThread::updatePCM() { float buf[BUFSIZE]; ssize_t r; int error; - qDebug() << "HERE"; + // qDebug() << "HERE"; /* Record some data ... */ if ( pa_simple_read ( s, buf, sizeof(buf), &error ) < 0 ) { @@ -51,7 +51,7 @@ void PulseAudioThread::updatePCM() { return; //this->exit(error); } - qDebug() << "HERE"; + // qDebug() << "HERE"; m_projectM->pcm->addPCMfloat(buf, BUFSIZE); } @@ -67,8 +67,7 @@ void PulseAudioThread::run() init(); connect(m_timer, SIGNAL(timeout()), this, SLOT(updatePCM())); - m_timer->start(0); - //exec(); + exec(); } diff --git a/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp b/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp index 61cacb88f..eab0f8ff9 100644 --- a/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp +++ b/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp @@ -82,22 +82,6 @@ int wvw=512,wvh=512; int fvw=1024,fvh=768; int fps=30, fullscreen=0; -/* A simple routine calling UNIX write() in a loop */ -static ssize_t loop_write ( const float * data, size_t size ) -{ - ssize_t ret = 1; - - while ( size > 0 ) { - size--; - qDebug() << "data[" << size << "]=" << data[size]; - } - -} - - - - - int main ( int argc, char*argv[] ) { int i; @@ -116,8 +100,12 @@ int main ( int argc, char*argv[] ) PulseAudioThread * pulseThread = new PulseAudioThread(argc, argv, mainWindow->getQProjectM(), mainWindow); pulseThread->start(); - qDebug() << "app exec"; - return app.exec(); + //qDebug() << "app exec"; + int ret = app.exec(); + pulseThread->exit(); + + delete(mainWindow); + return ret; } @@ -157,7 +145,7 @@ std::string read_config() strcpy ( projectM_home, home ); strcpy ( projectM_home+strlen ( home ), "/.projectM" ); projectM_home[strlen ( home ) +strlen ( "/.projectM" ) ]='\0'; - mkdir ( projectM_home,0755 ); + mkdir ( projectM_home, 0755 ); strcpy ( projectM_home, home ); strcpy ( projectM_home+strlen ( home ), "/.projectM/config.inp" );