From 70b95279579146bf46910257f8e0ecb1ff62b24f Mon Sep 17 00:00:00 2001 From: Astatin Date: Wed, 6 Aug 2025 15:59:22 +0200 Subject: Dynamically adapt audio speed to keep latency low --- src/io.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/io.rs') diff --git a/src/io.rs b/src/io.rs index 8ed35e8..f2ed8d0 100644 --- a/src/io.rs +++ b/src/io.rs @@ -164,11 +164,21 @@ impl Gameboy = None; while !state.is_stopped { if was_previously_halted && !state.mem.halt { - log(LogLevel::HaltCycles, format!("Halt cycles {}", halt_time)); + let n = SystemTime::now(); + log( + LogLevel::HaltCycles, + format!( + "Halt cycles {} (system average speed: {}Hz)", + halt_time, + last_halt_cycle_counter as f32 / n.duration_since(last_halt_cycle).unwrap().as_secs_f32(), + ) + ); halt_time = 0; } was_previously_halted = state.mem.halt; @@ -179,6 +189,7 @@ impl Gameboy Gameboy= 0.0 || next_precise_gamepad_update.map_or(false, |c| (c >= total_cycle_counter)) @@ -233,11 +244,12 @@ impl Gameboy