forge
Explore
Log in

Don't you dare go Hollow

The lane and gap tests go through the muted open() too

Browse files at this commit

0f5e259d97816d8909377eba837a990aa871de5fAhmet Kaan GümüşParent: 2f8f546
  • test
    • the lane and gap tests go through the muted open() too
Show full message
🔇 test(engine): the lane and gap tests go through the muted open() too

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.rsmodified+11 -4
@@ -238,15 +238,22 @@ fn a_copied_gap_is_packets_of_hand_written_silence() {
238 "and they are one interior run, at {run:?}"238 "and they are one interior run, at {run:?}"
239 );239 );
240 240
241- // A gap at the *head* is packets of its own: nothing rides on a neighbour,241+ // A gap at the *head* is packets of its own -- its own length plus the one
242- // so there is no leading misplacement left to document.242+ // more a reader drops as priming. Without that one the drop would come out
243+ // of the hole and everything after it would play a packet early.
243 let (_, leading) =244 let (_, leading) =
244 AudioSession::copy_multi_segments(&sources, &[(None, 0.0, 0.5), (Some(0), 0.0, 1.0)])245 AudioSession::copy_multi_segments(&sources, &[(None, 0.0, 0.5), (Some(0), 0.0, 1.0)])
245 .unwrap()246 .unwrap()
246 .unwrap();247 .unwrap();
247 let head = leading.iter().take_while(|p| silent(p)).count() as u64;248 let head = leading.iter().take_while(|p| silent(p)).count() as u64;
248 assert!(249 assert!(
249- (head * PACKET).abs_diff(RATE / 2) <= PACKET,250+ (head * PACKET).abs_diff(RATE / 2 + PACKET) <= PACKET / 2,
250- "{head} silent packets for half a second of leading hole"251+ "{head} silent packets for half a second of leading hole plus priming"
252+ );
253+ // ...and only a *leading* hole gets it: the interior one above did not.
254+ assert_eq!(
255+ run.len() as u64 * PACKET,
256+ gap,
257+ "an interior gap is its own length exactly"
251 );258 );
252 }259 }
crates/engine/tests/playback.rsmodified+7 -2
@@ -928,7 +928,7 @@ fn audio_runs_across_a_source_join() {
928 #[test]928 #[test]
929 fn a_video_gap_plays_black_without_shortening_the_timeline() {929 fn a_video_gap_plays_black_without_shortening_the_timeline() {
930 let path = asset("test_baseline.mp4");930 let path = asset("test_baseline.mp4");
931- let mut session = PlaybackSession::open(&path).expect("open");931+ let mut session = open(&path);
932 let (fps, total) = (session.meta().frame_rate, session.meta().frame_count);932 let (fps, total) = (session.meta().frame_rate, session.meta().frame_count);
933 let whole = session.timeline_duration();933 let whole = session.timeline_duration();
934 934
@@ -985,10 +985,15 @@ fn a_video_gap_plays_black_without_shortening_the_timeline() {
985 /// samples the device has been fed, so silence has to be fed as real chunks or985 /// samples the device has been fed, so silence has to be fed as real chunks or
986 /// the timeline would stall on the hole. Needs a PipeWire daemon and the output986 /// the timeline would stall on the hole. Needs a PipeWire daemon and the output
987 /// plugin next to the test binary (`LD_LIBRARY_PATH=target/release`).987 /// plugin next to the test binary (`LD_LIBRARY_PATH=target/release`).
988+///
989+/// Muted like every other device test: what it asserts is the clock and the
990+/// frame numbering, both of which count fed samples and not their loudness. The
991+/// silence of a gap is proved off the decoder instead, with no device involved,
992+/// in `audio_segments::a_gap_segment_is_silence_of_its_own_length`.
988 #[test]993 #[test]
989 #[ignore = "needs a running PipeWire daemon"]994 #[ignore = "needs a running PipeWire daemon"]
990 fn an_audio_gap_is_silent_and_the_clock_keeps_counting() {995 fn an_audio_gap_is_silent_and_the_clock_keeps_counting() {
991- let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open");996+ let mut session = open(asset("test_av.mp4"));
992 assert!(session.cut_at(1.0), "split at 1 s");997 assert!(session.cut_at(1.0), "split at 1 s");
993 assert!(session.cut_at(2.0), "split at 2 s");998 assert!(session.cut_at(2.0), "split at 2 s");
994 // Silence over [1, 2) s while the picture plays on -- the two lanes part.999 // Silence over [1, 2) s while the picture plays on -- the two lanes part.