Qt: Fix unpausing
Jeffrey Pfau jeffrey@endrift.com
Tue, 09 Feb 2016 21:18:15 -0800
2 files changed,
17 insertions(+),
20 deletions(-)
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -340,16 +340,7 @@ if (!GBAThreadStart(&m_threadContext)) {
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 @@ if (paused) {
m_pauseAfterFrame.testAndSetRelaxed(false, true); } else { GBAThreadUnpause(&m_threadContext); + startAudio(); emit gameUnpaused(&m_threadContext); } }@@ -658,6 +650,19 @@ }
} } +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 @@ m_audioProcessor->moveToThread(m_audioThread);
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(); } }
M
src/platform/qt/GameController.h
→
src/platform/qt/GameController.h
@@ -122,6 +122,7 @@ void setAutofire(int key, bool enable);
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);