From 92d02b0e000ccd3b3d9d3ab65f9a50be7d9a5ab5 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sun, 25 Oct 2026 03:26:56 +0300 Subject: [PATCH] Wait for the studio's delivered count in the capture-backend test Beyond the list of this round, found by its load runs: in 150 runs of the whole voelin-media test binary beside 32 busy loops, 11 failed, 9 of them in packets_reach_the_outputs_and_the_studio_is_a_capture_backend at `assert!(studio.shared.delivered.load(..) > 0)` (the other 2 in it_composes_into_the_preview_and_follows_commands, fixed in the commit before). The studio counts a frame as delivered after it has handed it to the capture sink (`sink.frame(..)`, then `delivered.fetch_add`), so a test that has just received the frame can read the count before it is made. The test now waits for the count to become non-zero after it has the frame; the wait for the frame is 30 s instead of 5 s, and the wait for the count 30 s, which only end a hang. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-media/src/studio/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/voelin-media/src/studio/mod.rs b/crates/voelin-media/src/studio/mod.rs index 5a00624..ee5efc9 100644 --- a/crates/voelin-media/src/studio/mod.rs +++ b/crates/voelin-media/src/studio/mod.rs @@ -1411,9 +1411,16 @@ mod tests { assert_eq!((listed[0].width, listed[0].height), (64, 48)); let frames = capture.start(&SourceId::Studio, &CaptureOptions::default()).await.unwrap(); let mut frames = frames; - let frame = frames.recv_timeout(Duration::from_secs(5)).expect("a composed frame"); + // (The wait only ends a hang.) + let frame = frames.recv_timeout(Duration::from_secs(30)).expect("a composed frame"); assert_eq!((frame.width, frame.height), (64, 48)); - assert!(studio.shared.delivered.load(Ordering::Relaxed) > 0); + // A frame is counted once it has been handed over, so the count can still be + // behind when the frame is in the hands of the test. + let deadline = Instant::now() + Duration::from_secs(30); + while studio.shared.delivered.load(Ordering::Relaxed) == 0 { + assert!(Instant::now() < deadline, "the frame handed over was never counted"); + std::thread::sleep(Duration::from_millis(5)); + } capture.stop(); std::fs::remove_dir_all(&dir).ok(); }