diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index e0eb8943d..e07b4ec10 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -340,16 +340,7 @@ void GameController::openGame(bool biosOnly) { m_gameOpen = false; emit gameFailed(); } else if (m_audioProcessor) { - bool started = false; - QMetaObject::invokeMethod(m_audioProcessor, "start", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, started)); - if (!started) { - LOG(ERROR) << tr("Failed to start audio processor"); - // Don't freeze! - m_audioSync = false; - m_videoSync = true; - m_threadContext.sync.audioWait = false; - m_threadContext.sync.videoFrameWait = true; - } + startAudio(); } } @@ -479,6 +470,7 @@ void GameController::setPaused(bool paused) { m_pauseAfterFrame.testAndSetRelaxed(false, true); } else { GBAThreadUnpause(&m_threadContext); + startAudio(); emit gameUnpaused(&m_threadContext); } } @@ -658,6 +650,19 @@ void GameController::setAudioChannelEnabled(int channel, bool enable) { } } +void GameController::startAudio() { + bool started = false; + QMetaObject::invokeMethod(m_audioProcessor, "start", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, started)); + if (!started) { + LOG(ERROR) << tr("Failed to start audio processor"); + // Don't freeze! + m_audioSync = false; + m_videoSync = true; + m_threadContext.sync.audioWait = false; + m_threadContext.sync.videoFrameWait = true; + } +} + void GameController::setVideoLayerEnabled(int layer, bool enable) { if (layer > 4 || layer < 0) { return; @@ -912,16 +917,7 @@ void GameController::reloadAudioDriver() { connect(this, SIGNAL(gamePaused(GBAThread*)), m_audioProcessor, SLOT(pause())); if (isLoaded()) { m_audioProcessor->setInput(&m_threadContext); - bool started = false; - QMetaObject::invokeMethod(m_audioProcessor, "start", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, started)); - if (!started) { - LOG(ERROR) << tr("Failed to start audio processor"); - // Don't freeze! - m_audioSync = false; - m_videoSync = true; - m_threadContext.sync.audioWait = false; - m_threadContext.sync.videoFrameWait = true; - } + startAudio(); } } diff --git a/src/platform/qt/GameController.h b/src/platform/qt/GameController.h index a7a3d89ae..43ab44740 100644 --- a/src/platform/qt/GameController.h +++ b/src/platform/qt/GameController.h @@ -122,6 +122,7 @@ public slots: void setAudioBufferSamples(int samples); void setAudioSampleRate(unsigned rate); void setAudioChannelEnabled(int channel, bool enable = true); + void startAudio(); void setVideoLayerEnabled(int layer, bool enable = true); void setFPSTarget(float fps); void loadState(int slot = 0);