For Qt GUI, edit frame throttling logic when using turbo mode or really fast emulation speed to not be so wasteful when emulation is paused. Don't make sense to waste CPU resources spinning on nothing. Fixes #681.
This commit is contained in:
parent
c50c1d570c
commit
a85f348e50
|
@ -365,7 +365,12 @@ static int highPrecSleep( FCEU::timeStampRecord &ts )
|
|||
int
|
||||
SpeedThrottle(void)
|
||||
{
|
||||
if ( (g_fpsScale >= 32) || (NoWaiting & 0x01) || turbo )
|
||||
bool isEmuPaused = FCEUI_EmulationPaused() ? true : false;
|
||||
bool noWaitActive = (NoWaiting & 0x01) ? true : false;
|
||||
bool turboActive = (turbo || noWaitActive);
|
||||
|
||||
// If Emulator is paused, don't waste CPU cycles spinning on nothing.
|
||||
if ( !isEmuPaused && ((g_fpsScale >= 32) || turboActive) )
|
||||
{
|
||||
return 0; /* Done waiting */
|
||||
}
|
||||
|
@ -397,6 +402,16 @@ SpeedThrottle(void)
|
|||
time_left = Nexttime - cur_time;
|
||||
}
|
||||
|
||||
// If Emulator is paused, ensure that sleep time cannot be zero
|
||||
// we don't want to waste a full CPU core on nothing.
|
||||
if (isEmuPaused)
|
||||
{
|
||||
if (time_left.toMilliSeconds() < 1)
|
||||
{
|
||||
time_left.fromMilliSeconds(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (time_left.toMilliSeconds() > 50)
|
||||
{
|
||||
time_left.fromMilliSeconds(50);
|
||||
|
@ -407,7 +422,7 @@ SpeedThrottle(void)
|
|||
{
|
||||
InFrame = 0;
|
||||
}
|
||||
|
||||
|
||||
//fprintf(stderr, "attempting to sleep %Ld ms, frame complete=%s\n",
|
||||
// time_left, InFrame?"no":"yes");
|
||||
|
||||
|
|
Loading…
Reference in New Issue