all repos — mgba @ 37fd51df39b9802446e1a89cfe6d993f3ec74558

mGBA Game Boy Advance Emulator

Qt: Fix thread sync issues with QtMultimedia audio driver
Jeffrey Pfau jeffrey@endrift.com
Sat, 21 Feb 2015 02:44:59 -0800
commit

37fd51df39b9802446e1a89cfe6d993f3ec74558

parent

56475e578bc27ab79aa34047dda1bf6c3fbd4106

2 files changed, 3 insertions(+), 1 deletions(-)

jump to
M src/platform/qt/AudioDevice.cppsrc/platform/qt/AudioDevice.cpp

@@ -34,6 +34,7 @@ double fauxClock = GBAAudioCalculateRatio(1, m_context->fpsTarget, 1);

GBASyncLockAudio(&m_context->sync); blip_set_rates(m_context->gba->audio.left, GBA_ARM7TDMI_FREQUENCY, format.sampleRate() * fauxClock); blip_set_rates(m_context->gba->audio.right, GBA_ARM7TDMI_FREQUENCY, format.sampleRate() * fauxClock); + GBASyncUnlockAudio(&m_context->sync); #endif }

@@ -53,6 +54,7 @@

#if RESAMPLE_LIBRARY == RESAMPLE_NN return GBAAudioResampleNN(&m_context->gba->audio, m_ratio, &m_drift, reinterpret_cast<GBAStereoSample*>(data), maxSize / sizeof(GBAStereoSample)) * sizeof(GBAStereoSample); #elif RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF + GBASyncLockAudio(&m_context->sync); int available = blip_samples_avail(m_context->gba->audio.left); if (available > maxSize / sizeof(GBAStereoSample)) { available = maxSize / sizeof(GBAStereoSample);
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -461,7 +461,7 @@ threadContinue();

} void GameController::reloadAudioDriver() { - m_audioProcessor->pause(); + QMetaObject::invokeMethod(m_audioProcessor, "pause", Qt::BlockingQueuedConnection); delete m_audioProcessor; m_audioProcessor = AudioProcessor::create(); m_audioProcessor->moveToThread(m_audioThread);