From 6bb31980068dcbd5736ef90a8e61b0696670bd9b Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:03:10 +0300 Subject: [PATCH] LLE DSP: Handle cycle drifting --- include/audio/teakra_core.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/audio/teakra_core.hpp b/include/audio/teakra_core.hpp index 171049853..778671d9e 100644 --- a/include/audio/teakra_core.hpp +++ b/include/audio/teakra_core.hpp @@ -85,7 +85,9 @@ namespace Audio { // Run 1 slice of DSP instructions and schedule the next audio frame void runAudioFrame(u64 eventTimestamp) override { runSlice(); - scheduler.addEvent(Scheduler::EventType::RunDSP, scheduler.currentTimestamp + Audio::lleSlice * 2); + // How many cycles we were late + const u64 cycleDrift = scheduler.currentTimestamp - eventTimestamp; + scheduler.addEvent(Scheduler::EventType::RunDSP, scheduler.currentTimestamp + Audio::lleSlice * 2 - cycleDrift); } void setAudioEnabled(bool enable) override;