mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
System: Use socket multiplier for sleeping when connected
Should significantly reduce PINE latency.
This commit is contained in:
parent
1fd8d2701d
commit
bc73dacea4
|
@ -2200,16 +2200,39 @@ void System::Throttle(Common::Timer::Value current_time)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_SOCKET_MULTIPLEXER
|
||||||
|
// If we are using the socket multiplier, and have clients, then use it to sleep instead.
|
||||||
|
// That way in a query->response->query->response chain, we don't process only one message per frame.
|
||||||
|
if (s_socket_multiplexer && s_socket_multiplexer->HasAnyClientSockets())
|
||||||
|
{
|
||||||
|
Common::Timer::Value poll_start_time = current_time;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
const u32 sleep_ms =
|
||||||
|
static_cast<u32>(Common::Timer::ConvertValueToMilliseconds(s_next_frame_time - poll_start_time));
|
||||||
|
s_socket_multiplexer->PollEventsWithTimeout(sleep_ms);
|
||||||
|
poll_start_time = Common::Timer::GetCurrentValue();
|
||||||
|
if (poll_start_time >= s_next_frame_time || (!g_settings.display_optimal_frame_pacing && sleep_ms == 0))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Use a spinwait if we undersleep for all platforms except android.. don't want to burn battery.
|
// Use a spinwait if we undersleep for all platforms except android.. don't want to burn battery.
|
||||||
// Linux also seems to do a much better job of waking up at the requested time.
|
// Linux also seems to do a much better job of waking up at the requested time.
|
||||||
#if !defined(__linux__) && !defined(__ANDROID__)
|
#if !defined(__linux__)
|
||||||
Common::Timer::SleepUntil(s_next_frame_time, g_settings.display_optimal_frame_pacing);
|
Common::Timer::SleepUntil(s_next_frame_time, g_settings.display_optimal_frame_pacing);
|
||||||
#else
|
#else
|
||||||
Common::Timer::SleepUntil(s_next_frame_time, false);
|
Common::Timer::SleepUntil(s_next_frame_time, false);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// No spinwait on Android, see above.
|
||||||
|
Common::Timer::SleepUntil(s_next_frame_time, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
Log_DevPrintf("Asked for %.2f ms, slept for %.2f ms, %.2f ms late",
|
DEV_LOG("Asked for {:.2f} ms, slept for {:.2f} ms, {:.2f} ms late",
|
||||||
Common::Timer::ConvertValueToMilliseconds(s_next_frame_time - current_time),
|
Common::Timer::ConvertValueToMilliseconds(s_next_frame_time - current_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds(Common::Timer::GetCurrentValue() - current_time),
|
Common::Timer::ConvertValueToMilliseconds(Common::Timer::GetCurrentValue() - current_time),
|
||||||
Common::Timer::ConvertValueToMilliseconds(Common::Timer::GetCurrentValue() - s_next_frame_time));
|
Common::Timer::ConvertValueToMilliseconds(Common::Timer::GetCurrentValue() - s_next_frame_time));
|
||||||
|
|
Loading…
Reference in a new issue