Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

don't abort encoding if capurer stop fails (#1223)

Brendan Allan0b689850e66a
diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs
index 700d38943..b60777eec 100644
--- a/crates/recording/src/output_pipeline/core.rs
+++ b/crates/recording/src/output_pipeline/core.rs
@@ -405,13 +405,26 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
muxer: Arc<Mutex<TMutex>>,
timestamps: Timestamps,
) {
+ setup_ctx.tasks().spawn("capture-video", {
+ let stop_token = stop_token.clone();
+ async move {
+ video_source.start().await?;
+
+ stop_token.cancelled().await;
+
+ if let Err(e) = video_source.stop().await {
+ error!("Video source stop failed: {e:#}");
+ };
+
+ Ok(())
+ }
+ });
+
setup_ctx.tasks().spawn("mux-video", async move {
use futures::StreamExt;
let mut first_tx = Some(first_tx);
- video_source.start().await?;
-
stop_token
.run_until_cancelled(async {
while let Some(frame) = video_rx.next().await {
@@ -432,8 +445,6 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
})
.await;
- video_source.stop().await.context("video_source_stop")?;
-
muxer.lock().await.stop();
Ok(())