From db1affe8ef45912591be1c3be91a721db2c482bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 11 Aug 2026 09:57:29 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test(playback):=20the=20clock=20?= =?UTF-8?q?counts=20the=20sound=20that=20played=20while=20the=20picture=20?= =?UTF-8?q?reopened?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit seek_keeps_the_audio_clock measured the clock across a window that included next_index -- the wait for the first picture after the seek -- and assumed that wait cost the timeline nothing. It did, before: the clock re-anchored onto an empty ring, so the audio that played during the video decoder's reopen was thrown away and the picture stayed that far behind the sound. Now it is counted, so the assertion is made against the wall clock the window really took (measured: 3.917 s after 0.969 s of real time). The mix card's doc says what a fader now costs, which is nothing. --- crates/app/src/main.rs | 7 +++++-- crates/engine/tests/playback.rs | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 7db1f93..f47001a 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -1704,8 +1704,11 @@ impl Player { /// ceiling by the same, and the switch either way (a ring of two, like the /// silence card's unit row). /// - /// Every one of them goes through the session, so it reseeks: what the ear - /// hears while the arrow is held is the mix that is being set. + /// Every one of them goes through the session, which hands it straight to + /// the running mixer: what the ear hears while the arrow is held is the mix + /// that is being set, and nothing is rebuilt to make that true -- no reseek, + /// so no `reset_after_reseek` and no blink in the picture behind the card + /// ([`engine::PlaybackSession::set_lane_gain_db`]). fn nudge_mix(&mut self, steps: i32, cx: &mut Context) { let lanes = self.mix_lanes(); let Some(session) = self.session.as_mut() else { diff --git a/crates/engine/tests/playback.rs b/crates/engine/tests/playback.rs index cb8a7a4..5939aba 100644 --- a/crates/engine/tests/playback.rs +++ b/crates/engine/tests/playback.rs @@ -284,15 +284,27 @@ fn seek_keeps_the_audio_clock() { "clock at {}", session.now() ); + // From here on the *sound* is what the clock counts, and the sound restarts + // at once -- the video decoder's reopen (up to a VA-API init) happens + // underneath a stream that is already playing, so the window `next_index` + // spends waiting for the first picture is time the timeline really moved + // through. Measured against the wall rather than assumed free: counting it + // is the fix for the offset an edit-while-playing used to leave behind + // (`invalidation.rs`), where the clock re-anchored onto an empty ring and + // the picture stayed that far behind the sound for good. + let from = Instant::now(); let first = next_index(&mut session, "seek(3.0)"); assert_eq!(first, (3.0 * meta.frame_rate) as u32); let mut after_seek = None; run_for(&mut session, &mut after_seek, Duration::from_millis(600)); let advanced = session.now(); - eprintln!("seek(3.0) -> {advanced:.3}s, frames {first}..={after_seek:?}"); + let real = from.elapsed().as_secs_f64(); + eprintln!( + "seek(3.0) -> {advanced:.3}s after {real:.3}s of real time, frames {first}..={after_seek:?}" + ); assert!( - (3.3..3.9).contains(&advanced), - "clock did not run at real speed after the seek: {advanced:.3}s" + (3.0 + real - 0.35..3.0 + real + 0.35).contains(&advanced), + "clock did not run at real speed after the seek: {advanced:.3}s after {real:.3}s" ); // Everything from the target on, and nothing before it: ~2 s of frames.