Qt: Fix frame delay with pausing and frame advancing

This commit is contained in:
Jeffrey Pfau 2015-08-03 23:52:18 -07:00
parent 6ae001037d
commit a6ff9f6c60
1 changed files with 5 additions and 6 deletions

View File

@ -121,15 +121,15 @@ GameController::GameController(QObject* parent)
m_threadContext.frameCallback = [](GBAThread* context) {
GameController* controller = static_cast<GameController*>(context->userData);
if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) {
GBAThreadPauseFromThread(context);
controller->gamePaused(&controller->m_threadContext);
}
if (GBASyncDrawingFrame(&controller->m_threadContext.sync)) {
controller->frameAvailable(controller->m_drawContext);
} else {
controller->frameAvailable(nullptr);
}
if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) {
GBAThreadPauseFromThread(context);
controller->gamePaused(&controller->m_threadContext);
}
};
m_threadContext.stopCallback = [](GBAThread* context) {
@ -464,8 +464,7 @@ void GameController::setPaused(bool paused) {
return;
}
if (paused) {
GBAThreadPause(&m_threadContext);
emit gamePaused(&m_threadContext);
m_pauseAfterFrame.testAndSetRelaxed(false, true);
} else {
GBAThreadUnpause(&m_threadContext);
emit gameUnpaused(&m_threadContext);