mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 07:15:45 -04:00
System: Reset throttler when audio buffers underflow
Should hopefully reduce the chances of the audio source ending up out of phase from the emulation when vsync is disabled.
This commit is contained in:
@ -1216,8 +1216,22 @@ void UpdateThrottlePeriod()
|
||||
static_cast<s32>(1000000000.0 / static_cast<double>(s_throttle_frequency) / static_cast<double>(s_target_speed));
|
||||
}
|
||||
|
||||
void ResetThrottler()
|
||||
{
|
||||
s_last_throttle_time = 0;
|
||||
s_throttle_timer.Reset();
|
||||
}
|
||||
|
||||
void Throttle()
|
||||
{
|
||||
// Reset the throttler on audio buffer overflow, so we don't end up out of phase.
|
||||
if (g_host_interface->GetAudioStream()->DidUnderflow())
|
||||
{
|
||||
Log_DevPrintf("Audio buffer underflowed, resetting throttler");
|
||||
ResetThrottler();
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow variance of up to 40ms either way.
|
||||
constexpr s64 MAX_VARIANCE_TIME = INT64_C(40000000);
|
||||
|
||||
@ -1239,8 +1253,7 @@ void Throttle()
|
||||
s_speed_lost_time_timestamp.Reset();
|
||||
}
|
||||
#endif
|
||||
s_last_throttle_time = 0;
|
||||
s_throttle_timer.Reset();
|
||||
ResetThrottler();
|
||||
}
|
||||
else if (sleep_time >= MINIMUM_SLEEP_TIME)
|
||||
{
|
||||
@ -1294,8 +1307,7 @@ void ResetPerformanceCounters()
|
||||
s_average_frame_time_accumulator = 0.0f;
|
||||
s_worst_frame_time_accumulator = 0.0f;
|
||||
s_fps_timer.Reset();
|
||||
s_throttle_timer.Reset();
|
||||
s_last_throttle_time = 0;
|
||||
ResetThrottler();
|
||||
}
|
||||
|
||||
bool LoadEXE(const char* filename)
|
||||
|
@ -154,6 +154,7 @@ void SetThrottleFrequency(float frequency);
|
||||
|
||||
/// Updates the throttle period, call when target emulation speed changes.
|
||||
void UpdateThrottlePeriod();
|
||||
void ResetThrottler();
|
||||
|
||||
/// Throttles the system, i.e. sleeps until it's time to execute the next frame.
|
||||
void Throttle();
|
||||
|
Reference in New Issue
Block a user