Enable threaded audio on Symbian.

This commit is contained in:
Sacha
2013-10-26 19:51:29 +10:00
parent c53bf92350
commit 37cd71b2a4
2 changed files with 17 additions and 15 deletions
+2 -6
View File
@@ -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;
+15 -9
View File
@@ -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 *) {