Skip to content

Commit 0b68985

Browse files
authored
don't abort encoding if capurer stop fails (#1223)
* don't abort encoding if capurer stop fails * separate capture-video task
1 parent 58c343d commit 0b68985

File tree

1 file changed

+15
-4
lines changed
  • crates/recording/src/output_pipeline

1 file changed

+15
-4
lines changed

crates/recording/src/output_pipeline/core.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,26 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
405405
muxer: Arc<Mutex<TMutex>>,
406406
timestamps: Timestamps,
407407
) {
408+
setup_ctx.tasks().spawn("capture-video", {
409+
let stop_token = stop_token.clone();
410+
async move {
411+
video_source.start().await?;
412+
413+
stop_token.cancelled().await;
414+
415+
if let Err(e) = video_source.stop().await {
416+
error!("Video source stop failed: {e:#}");
417+
};
418+
419+
Ok(())
420+
}
421+
});
422+
408423
setup_ctx.tasks().spawn("mux-video", async move {
409424
use futures::StreamExt;
410425

411426
let mut first_tx = Some(first_tx);
412427

413-
video_source.start().await?;
414-
415428
stop_token
416429
.run_until_cancelled(async {
417430
while let Some(frame) = video_rx.next().await {
@@ -432,8 +445,6 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
432445
})
433446
.await;
434447

435-
video_source.stop().await.context("video_source_stop")?;
436-
437448
muxer.lock().await.stop();
438449

439450
Ok(())

0 commit comments

Comments
 (0)