diff --git a/base/QtMain.cpp b/base/QtMain.cpp index cc6d552041..98edad1dd7 100644 --- a/base/QtMain.cpp +++ b/base/QtMain.cpp @@ -156,23 +156,19 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) vibra = CHWRMVibra::NewL(); #endif -#ifdef __SYMBIAN32__ - MainAudio *audio = new MainAudio(); -#else QThread* thread = new QThread; MainAudio *audio = new MainAudio(); audio->moveToThread(thread); + QObject::connect(thread, SIGNAL(started()), audio, SLOT(run())); QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start(); -#endif int ret = a.exec(); delete audio; #ifdef __SYMBIAN32__ delete vibra; -#else - thread->quit(); #endif + thread->quit(); NativeShutdown(); net::Shutdown(); return ret; diff --git a/base/QtMain.h b/base/QtMain.h index 76bde0c716..d4f9a09e4e 100644 --- a/base/QtMain.h +++ b/base/QtMain.h @@ -186,6 +186,21 @@ class MainAudio: public QObject Q_OBJECT public: MainAudio() { + } + ~MainAudio() { + if (feed != NULL) { + killTimer(timer); + feed->close(); + } + if (output) { + output->stop(); + delete output; + } + if (mixbuf) + free(mixbuf); + } +public slots: + void run() { QAudioFormat fmt; fmt.setSampleRate(AUDIO_FREQ); fmt.setCodec("audio/pcm"); @@ -201,15 +216,6 @@ public: if (feed != NULL) timer = startTimer(1000*AUDIO_SAMPLES / AUDIO_FREQ); } - ~MainAudio() { - if (feed != NULL) { - killTimer(timer); - feed->close(); - } - output->stop(); - delete output; - free(mixbuf); - } protected: void timerEvent(QTimerEvent *) {