all repos — mgba @ 811d654893a68882f15b04f6f3f9bfe47dea20da

mGBA Game Boy Advance Emulator

Qt: Fix unpausing
Jeffrey Pfau jeffrey@endrift.com
Tue, 09 Feb 2016 21:18:15 -0800
commit

811d654893a68882f15b04f6f3f9bfe47dea20da

parent

2a80ddf8d0e1eaee3437c46547e6255f039987d0

2 files changed, 17 insertions(+), 20 deletions(-)

jump to
M src/platform/qt/GameController.cppsrc/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.hsrc/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);