mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-28 15:05:41 -04:00
System: Handle large event timing overshoots better
Usually a result of DMA cycle stealing. Instead of adding all time, add min(all_events.downcount) at a time. 1.5% performance improvement, but fixes desyncs between the SPU and CD-ROM.
This commit is contained in:
parent
0317541477
commit
dd48a1f585
@ -1090,13 +1090,15 @@ void System::RunEvents()
|
|||||||
{
|
{
|
||||||
DebugAssert(!m_running_events && !m_events.empty());
|
DebugAssert(!m_running_events && !m_events.empty());
|
||||||
|
|
||||||
const TickCount pending_ticks = m_cpu->GetPendingTicks();
|
|
||||||
m_global_tick_counter += static_cast<u32>(pending_ticks);
|
|
||||||
m_cpu->ResetPendingTicks();
|
|
||||||
|
|
||||||
TickCount time = static_cast<TickCount>(m_global_tick_counter - m_last_event_run_time);
|
|
||||||
m_running_events = true;
|
m_running_events = true;
|
||||||
m_last_event_run_time = m_global_tick_counter;
|
|
||||||
|
TickCount pending_ticks = (m_global_tick_counter + m_cpu->GetPendingTicks()) - m_last_event_run_time;
|
||||||
|
m_cpu->ResetPendingTicks();
|
||||||
|
while (pending_ticks > 0)
|
||||||
|
{
|
||||||
|
const TickCount time = std::min(pending_ticks, m_events[0]->m_downcount);
|
||||||
|
m_global_tick_counter += static_cast<u32>(time);
|
||||||
|
pending_ticks -= time;
|
||||||
|
|
||||||
// Apply downcount to all events.
|
// Apply downcount to all events.
|
||||||
// This will result in a negative downcount for those events which are late.
|
// This will result in a negative downcount for those events which are late.
|
||||||
@ -1135,7 +1137,9 @@ void System::RunEvents()
|
|||||||
std::push_heap(m_events.begin(), m_events.end(), CompareEvents);
|
std::push_heap(m_events.begin(), m_events.end(), CompareEvents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_last_event_run_time = m_global_tick_counter;
|
||||||
m_running_events = false;
|
m_running_events = false;
|
||||||
m_cpu->SetDowncount(m_events.front()->GetDowncount());
|
m_cpu->SetDowncount(m_events.front()->GetDowncount());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user