Core: Make pause/fast forward/save state/etc more responsive when running emulation at low speeds

This commit is contained in:
Sour 2019-11-13 20:52:26 -05:00
parent 3d079f66d7
commit 96e7edb1f5
2 changed files with 14 additions and 2 deletions

View file

@ -157,7 +157,12 @@ void Console::ProcessEndOfFrame()
}
_frameLimiter->ProcessFrame();
_frameLimiter->WaitForNextFrame();
while(_frameLimiter->WaitForNextFrame()) {
if(_stopFlag || _frameDelay != GetFrameDelay() || _paused || _pauseOnNextFrame || _lockCounter > 0) {
//Need to process another event, stop sleeping
break;
}
}
double newFrameDelay = GetFrameDelay();
if(newFrameDelay != _frameDelay) {

View file

@ -39,8 +39,15 @@ public:
_targetTime += _delay;
}
void WaitForNextFrame()
bool WaitForNextFrame()
{
if(_targetTime - _clockTimer.GetElapsedMS() > 50) {
//When sleeping for a long time (e.g <= 25% speed), sleep in small chunks and check to see if we need to stop sleeping between each sleep call
_clockTimer.WaitUntil(_clockTimer.GetElapsedMS() + 40);
return true;
}
_clockTimer.WaitUntil(_targetTime);
return false;
}
};