From 0f5e259d97816d8909377eba837a990aa871de5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 10 Aug 2026 04:23:28 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=87=20test(engine):=20the=20lane=20and?= =?UTF-8?q?=20gap=20tests=20go=20through=20the=20muted=20open()=20too?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves the merge of e1d090d by hand where git resolved it textually: the two sessions this branch added opened the device at full gain, and the audio one plays 2.4 s of a real file. Both go through the silent helper now. Neither loses anything by it -- what they asserts is the clock, the frame numbering and the picture, none of which the last multiply before the device can change; the silence of a gap is proved off the decoder in audio_segments, with no device at all. The leading-gap copy assertion moves with the priming packet: a hole at the head is its own length plus the one packet a reader drops. --- crates/engine/tests/audio_segments.rs | 15 +++++++++++---- crates/engine/tests/playback.rs | 9 +++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) 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.