mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix frame delay with pausing and frame advancing
This commit is contained in:
parent
6ae001037d
commit
a6ff9f6c60
|
@ -121,15 +121,15 @@ GameController::GameController(QObject* parent)
|
||||||
|
|
||||||
m_threadContext.frameCallback = [](GBAThread* context) {
|
m_threadContext.frameCallback = [](GBAThread* context) {
|
||||||
GameController* controller = static_cast<GameController*>(context->userData);
|
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)) {
|
if (GBASyncDrawingFrame(&controller->m_threadContext.sync)) {
|
||||||
controller->frameAvailable(controller->m_drawContext);
|
controller->frameAvailable(controller->m_drawContext);
|
||||||
} else {
|
} else {
|
||||||
controller->frameAvailable(nullptr);
|
controller->frameAvailable(nullptr);
|
||||||
}
|
}
|
||||||
|
if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) {
|
||||||
|
GBAThreadPauseFromThread(context);
|
||||||
|
controller->gamePaused(&controller->m_threadContext);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
m_threadContext.stopCallback = [](GBAThread* context) {
|
m_threadContext.stopCallback = [](GBAThread* context) {
|
||||||
|
@ -464,8 +464,7 @@ void GameController::setPaused(bool paused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (paused) {
|
if (paused) {
|
||||||
GBAThreadPause(&m_threadContext);
|
m_pauseAfterFrame.testAndSetRelaxed(false, true);
|
||||||
emit gamePaused(&m_threadContext);
|
|
||||||
} else {
|
} else {
|
||||||
GBAThreadUnpause(&m_threadContext);
|
GBAThreadUnpause(&m_threadContext);
|
||||||
emit gameUnpaused(&m_threadContext);
|
emit gameUnpaused(&m_threadContext);
|
||||||
|
|
Loading…
Reference in New Issue