mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Drop the thread from Qt audio loop. Makes exit cleaner.
Probably needs to be reworked or replaced with SDL it seems.
This commit is contained in:
1 parent
2ba8e36b2b
commit
14d2fa9a39
2 files changed
+5
-14
No files matched your search
+2
-11
@@ -162,21 +162,12 @@ static int mainInternal(QApplication &a)
|
||||
SDL_CloseAudio();
|
||||
}
|
||||
}
|
||||
|
||||
// Audio must be unpaused _after_ NativeInit()
|
||||
SDL_PauseAudio(0);
|
||||
#else
|
||||
QScopedPointer<QThread> thread(new QThread);
|
||||
QScopedPointer<MainAudio> audio(new MainAudio());
|
||||
audio->moveToThread(thread.data());
|
||||
QObject::connect(thread.data(), SIGNAL(started()), audio.data(), SLOT(run()));
|
||||
thread->start();
|
||||
audio->run();
|
||||
#endif
|
||||
int ret = a.exec();
|
||||
#ifndef QT_HAS_SDL
|
||||
thread->terminate();
|
||||
#endif
|
||||
return ret;
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
#ifndef QT_HAS_SDL
|
||||
|
||||
+3
-3
@@ -269,19 +269,19 @@ public slots:
|
||||
fmt.setSampleSize(AUDIO_SAMPLESIZE);
|
||||
fmt.setByteOrder(QAudioFormat::LittleEndian);
|
||||
fmt.setSampleType(QAudioFormat::SignedInt);
|
||||
mixlen = 5*2*AUDIO_CHANNELS*AUDIO_SAMPLES;
|
||||
mixlen = 2*AUDIO_CHANNELS*AUDIO_SAMPLES;
|
||||
mixbuf = (char*)malloc(mixlen);
|
||||
output = new QAudioOutput(fmt);
|
||||
output->setBufferSize(mixlen);
|
||||
feed = output->start();
|
||||
if (feed != NULL)
|
||||
timer = startTimer(1000*AUDIO_SAMPLES / AUDIO_FREQ);
|
||||
timer = startTimer((1000*AUDIO_SAMPLES) / AUDIO_FREQ);
|
||||
}
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *) {
|
||||
memset(mixbuf, 0, mixlen);
|
||||
size_t frames = NativeMix((short *)mixbuf, 5*AUDIO_SAMPLES);
|
||||
size_t frames = NativeMix((short *)mixbuf, AUDIO_SAMPLES);
|
||||
if (frames > 0)
|
||||
feed->write(mixbuf, sizeof(short) * 2 * frames);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user