Qt: Fix unpausing

This commit is contained in:
Jeffrey Pfau 2016-02-09 21:18:15 -08:00
parent 2a80ddf8d0
commit 811d654893
2 changed files with 17 additions and 20 deletions

View File

@ -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();
}
}

View File

@ -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);