forge
Explore
Log in

Don't you dare go Hollow

The clock counts the sound that played while the picture reopened

Browse files at this commit

db1affe8ef45912591be1c3be91a721db2c482bcAhmet Kaan GümüşParent: c2e62a3
  • test
    • the clock counts the sound that played while the picture reopened
Show full message
🧪 test(playback): the clock counts the sound that played while the picture reopened

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.rsmodified+5 -2
@@ -1704,8 +1704,11 @@ impl Player {
1704 /// ceiling by the same, and the switch either way (a ring of two, like the1704 /// ceiling by the same, and the switch either way (a ring of two, like the
1705 /// silence card's unit row).1705 /// silence card's unit row).
1706 ///1706 ///
1707- /// Every one of them goes through the session, so it reseeks: what the ear1707+ /// Every one of them goes through the session, which hands it straight to
1708- /// hears while the arrow is held is the mix that is being set.1708+ /// the running mixer: what the ear hears while the arrow is held is the mix
1709+ /// that is being set, and nothing is rebuilt to make that true -- no reseek,
1710+ /// so no `reset_after_reseek` and no blink in the picture behind the card
1711+ /// ([`engine::PlaybackSession::set_lane_gain_db`]).
1709 fn nudge_mix(&mut self, steps: i32, cx: &mut Context<Self>) {1712 fn nudge_mix(&mut self, steps: i32, cx: &mut Context<Self>) {
1710 let lanes = self.mix_lanes();1713 let lanes = self.mix_lanes();
1711 let Some(session) = self.session.as_mut() else {1714 let Some(session) = self.session.as_mut() else {
crates/engine/tests/playback.rsmodified+15 -3
@@ -284,15 +284,27 @@ fn seek_keeps_the_audio_clock() {
284 "clock at {}",284 "clock at {}",
285 session.now()285 session.now()
286 );286 );
287+ // From here on the *sound* is what the clock counts, and the sound restarts
288+ // at once -- the video decoder's reopen (up to a VA-API init) happens
289+ // underneath a stream that is already playing, so the window `next_index`
290+ // spends waiting for the first picture is time the timeline really moved
291+ // through. Measured against the wall rather than assumed free: counting it
292+ // is the fix for the offset an edit-while-playing used to leave behind
293+ // (`invalidation.rs`), where the clock re-anchored onto an empty ring and
294+ // the picture stayed that far behind the sound for good.
295+ let from = Instant::now();
287 let first = next_index(&mut session, "seek(3.0)");296 let first = next_index(&mut session, "seek(3.0)");
288 assert_eq!(first, (3.0 * meta.frame_rate) as u32);297 assert_eq!(first, (3.0 * meta.frame_rate) as u32);
289 let mut after_seek = None;298 let mut after_seek = None;
290 run_for(&mut session, &mut after_seek, Duration::from_millis(600));299 run_for(&mut session, &mut after_seek, Duration::from_millis(600));
291 let advanced = session.now();300 let advanced = session.now();
292- eprintln!("seek(3.0) -> {advanced:.3}s, frames {first}..={after_seek:?}");301+ let real = from.elapsed().as_secs_f64();
302+ eprintln!(
303+ "seek(3.0) -> {advanced:.3}s after {real:.3}s of real time, frames {first}..={after_seek:?}"
304+ );
293 assert!(305 assert!(
294- (3.3..3.9).contains(&advanced),306+ (3.0 + real - 0.35..3.0 + real + 0.35).contains(&advanced),
295- "clock did not run at real speed after the seek: {advanced:.3}s"307+ "clock did not run at real speed after the seek: {advanced:.3}s after {real:.3}s"
296 );308 );
297 309
298 // Everything from the target on, and nothing before it: ~2 s of frames.310 // Everything from the target on, and nothing before it: ~2 s of frames.