Skip to content

Commit b2a9d8e

Browse files
committed
Add retry limit to video frame queuing
1 parent 8820729 commit b2a9d8e

File tree

1 file changed

+10
-0
lines changed
  • crates/recording/src/output_pipeline

1 file changed

+10
-0
lines changed

crates/recording/src/output_pipeline/macos.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ impl Muxer for AVFoundationMp4Muxer {
6363
impl VideoMuxer for AVFoundationMp4Muxer {
6464
type VideoFrame = screen_capture::VideoFrame;
6565

66+
const MAX_QUEUE_RETRIES: u32 = 500;
67+
6668
fn send_video_frame(
6769
&mut self,
6870
frame: Self::VideoFrame,
@@ -76,10 +78,18 @@ impl VideoMuxer for AVFoundationMp4Muxer {
7678
mp4.resume();
7779
}
7880

81+
let mut retry_count = 0;
7982
loop {
8083
match mp4.queue_video_frame(frame.sample_buf.clone(), timestamp) {
8184
Ok(()) => break,
8285
Err(QueueFrameError::NotReadyForMore) => {
86+
retry_count += 1;
87+
if retry_count >= Self::MAX_QUEUE_RETRIES {
88+
return Err(anyhow!(
89+
"send_video_frame/timeout after {} retries",
90+
Self::MAX_QUEUE_RETRIES
91+
));
92+
}
8393
std::thread::sleep(Duration::from_millis(2));
8494
continue;
8595
}

0 commit comments

Comments
 (0)