lower window update rate if rendering too fast

This commit is contained in:
RSDuck 2022-02-14 00:25:11 +01:00
parent 0761fe736f
commit 03b5c48088
1 changed files with 13 additions and 2 deletions

View File

@ -415,6 +415,8 @@ void EmuThread::run()
double frameLimitError = 0.0;
double lastMeasureTime = lastTime;
u32 winUpdateCount = 0, winUpdateFreq = 1;
char melontitle[100];
while (EmuRunning != 0)
@ -571,11 +573,16 @@ void EmuThread::run()
if (EmuRunning == 0) break;
emit windowUpdate();
winUpdateCount++;
if (winUpdateCount >= winUpdateFreq)
{
emit windowUpdate();
winUpdateCount = 0;
}
bool fastforward = Input::HotkeyDown(HK_FastForward);
if (Config::AudioSync && (!fastforward) && audioDevice)
if (Config::AudioSync && !fastforward && audioDevice)
{
SDL_LockMutex(audioSyncLock);
while (SPU::GetOutputSize() > 1024)
@ -624,6 +631,10 @@ void EmuThread::run()
float fpstarget = 1.0/frametimeStep;
winUpdateFreq = fps / (u32)round(fpstarget);
if (winUpdateFreq < 1)
winUpdateFreq = 1;
sprintf(melontitle, "[%d/%.0f] melonDS " MELONDS_VERSION, fps, fpstarget);
changeWindowTitle(melontitle);
}