From 3c012ec6ef43d0dbdef6e5522efc9f77ab4a7648 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 20 Jan 2021 12:05:05 +1000 Subject: [PATCH] SPU: Consider partial ticks when generating pending samples Fixes hitches in opening FMV in Soul Blade (Europe). --- src/core/spu.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/spu.cpp b/src/core/spu.cpp index 98be1d3fa..48174f247 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -1001,7 +1001,21 @@ void SPU::GeneratePendingSamples() if (m_transfer_event->IsActive()) m_transfer_event->InvokeEarly(); - m_tick_event->InvokeEarly(); + const TickCount ticks_pending = m_tick_event->GetTicksSinceLastExecution(); + TickCount frames_to_execute; + if (g_settings.cpu_overclock_active) + { + frames_to_execute = static_cast((static_cast(ticks_pending) * g_settings.cpu_overclock_denominator) + + static_cast(m_ticks_carry)) / + static_cast(m_cpu_tick_divider); + } + else + { + frames_to_execute = (m_tick_event->GetTicksSinceLastExecution() + m_ticks_carry) / SYSCLK_TICKS_PER_SPU_TICK; + } + + const bool force_exec = (frames_to_execute > 0); + m_tick_event->InvokeEarly(force_exec); } bool SPU::StartDumpingAudio(const char* filename)