diff --git a/crates/engine/tests/audio_segments.rs b/crates/engine/tests/audio_segments.rs index 3bd3c1e..d66538f 100644 --- a/crates/engine/tests/audio_segments.rs +++ b/crates/engine/tests/audio_segments.rs @@ -238,15 +238,22 @@ fn a_copied_gap_is_packets_of_hand_written_silence() { "and they are one interior run, at {run:?}" ); - // A gap at the *head* is packets of its own: nothing rides on a neighbour, - // so there is no leading misplacement left to document. + // A gap at the *head* is packets of its own -- its own length plus the one + // more a reader drops as priming. Without that one the drop would come out + // of the hole and everything after it would play a packet early. let (_, leading) = AudioSession::copy_multi_segments(&sources, &[(None, 0.0, 0.5), (Some(0), 0.0, 1.0)]) .unwrap() .unwrap(); let head = leading.iter().take_while(|p| silent(p)).count() as u64; assert!( - (head * PACKET).abs_diff(RATE / 2) <= PACKET, - "{head} silent packets for half a second of leading hole" + (head * PACKET).abs_diff(RATE / 2 + PACKET) <= PACKET / 2, + "{head} silent packets for half a second of leading hole plus priming" + ); + // ...and only a *leading* hole gets it: the interior one above did not. + assert_eq!( + run.len() as u64 * PACKET, + gap, + "an interior gap is its own length exactly" ); } diff --git a/crates/engine/tests/playback.rs b/crates/engine/tests/playback.rs index 546c776..96e3b8c 100644 --- a/crates/engine/tests/playback.rs +++ b/crates/engine/tests/playback.rs @@ -928,7 +928,7 @@ fn audio_runs_across_a_source_join() { #[test] fn a_video_gap_plays_black_without_shortening_the_timeline() { let path = asset("test_baseline.mp4"); - let mut session = PlaybackSession::open(&path).expect("open"); + let mut session = open(&path); let (fps, total) = (session.meta().frame_rate, session.meta().frame_count); let whole = session.timeline_duration(); @@ -985,10 +985,15 @@ fn a_video_gap_plays_black_without_shortening_the_timeline() { /// samples the device has been fed, so silence has to be fed as real chunks or /// the timeline would stall on the hole. Needs a PipeWire daemon and the output /// plugin next to the test binary (`LD_LIBRARY_PATH=target/release`). +/// +/// Muted like every other device test: what it asserts is the clock and the +/// frame numbering, both of which count fed samples and not their loudness. The +/// silence of a gap is proved off the decoder instead, with no device involved, +/// in `audio_segments::a_gap_segment_is_silence_of_its_own_length`. #[test] #[ignore = "needs a running PipeWire daemon"] fn an_audio_gap_is_silent_and_the_clock_keeps_counting() { - let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open"); + let mut session = open(asset("test_av.mp4")); assert!(session.cut_at(1.0), "split at 1 s"); assert!(session.cut_at(2.0), "split at 2 s"); // Silence over [1, 2) s while the picture plays on -- the two lanes part.