Qt Loop / Netplay: Fix netplay session getting stuck when shutting down the mainwindow

This commit is contained in:
HeatXD 2023-04-19 21:43:24 +02:00
parent 31a1339ace
commit df4e21a170
No known key found for this signature in database
GPG Key ID: BF30D71B2F1305C7
2 changed files with 4 additions and 8 deletions

View File

@ -176,7 +176,7 @@ void Netplay::SetSettings()
si.SetIntValue("Main", "RunaheadFrameCount", 0);
si.SetBoolValue("Main", "RewindEnable", false);
// no block linking, it degrades loading performance
// no block linking, it degrades savestate loading performance
si.SetBoolValue("CPU", "RecompilerBlockLinking", false);
Host::Internal::SetNetplaySettingsLayer(&si);
@ -203,18 +203,14 @@ void Netplay::UpdateThrottlePeriod()
void Netplay::HandleTimeSyncEvent(float frame_delta, int update_interval)
{
// we need a threshold since low advantage frames values are not worth correcting for.
if (std::abs(frame_delta ) < 3.0f)
return;
// only account for half the distance
// Distribute the frame difference over the next N * 0.75 frames.
// only part of the interval time is used since we want to come back to normal speed.
// otherwise we will keep spiraling into unplayable gameplay.
float total_time = frame_delta * s_frame_period;
float total_time = (frame_delta / 8) * s_frame_period;
float mun_timesync_frames = update_interval * 0.75f;
float added_time_per_frame = -(total_time / mun_timesync_frames);
float iterations_per_frame = 1.0f / s_frame_period;
s_target_speed = (s_frame_period + added_time_per_frame) * iterations_per_frame;
s_next_timesync_recovery_frame = CurrentFrame() + static_cast<s32>(std::ceil(mun_timesync_frames));

View File

@ -1466,7 +1466,7 @@ void EmuThread::run()
// main loop
while (!m_shutdown_flag)
{
if (Netplay::IsActive())
if (Netplay::IsActive() && System::IsRunning())
{
Netplay::ExecuteNetplay();
}