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 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d04e0158a
commit
92d02b0e00
1 file changed
+9
-2
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user