The clock counts the sound that played while the picture reopened
Browse files at this commitdb1affe8ef45912591be1c3be91a721db2c482bcParent: c2e62a3- test
- the clock counts the sound that played while the picture reopened
2 changed files +20 -5
crates/app/src/main.rsmodified+5 -2
| @@ -1704,8 +1704,11 @@ impl Player { | ||
| 1704 | 1704 | /// ceiling by the same, and the switch either way (a ring of two, like the |
| 1705 | 1705 | /// silence card's unit row). |
| 1706 | 1706 | /// |
| 1707 | - /// Every one of them goes through the session, so it reseeks: what the ear | |
| 1708 | - /// hears while the arrow is held is the mix that is being set. | |
| 1707 | + /// Every one of them goes through the session, which hands it straight to | |
| 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 | 1712 | fn nudge_mix(&mut self, steps: i32, cx: &mut Context<Self>) { |
| 1710 | 1713 | let lanes = self.mix_lanes(); |
| 1711 | 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 | 284 | "clock at {}", |
| 285 | 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 | 296 | let first = next_index(&mut session, "seek(3.0)"); |
| 288 | 297 | assert_eq!(first, (3.0 * meta.frame_rate) as u32); |
| 289 | 298 | let mut after_seek = None; |
| 290 | 299 | run_for(&mut session, &mut after_seek, Duration::from_millis(600)); |
| 291 | 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 | 305 | assert!( |
| 294 | - (3.3..3.9).contains(&advanced), | |
| 295 | - "clock did not run at real speed after the seek: {advanced:.3}s" | |
| 306 | + (3.0 + real - 0.35..3.0 + real + 0.35).contains(&advanced), | |
| 307 | + "clock did not run at real speed after the seek: {advanced:.3}s after {real:.3}s" | |
| 296 | 308 | ); |
| 297 | 309 | |
| 298 | 310 | // Everything from the target on, and nothing before it: ~2 s of frames. |