Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Improve logging and error context in recording pipeline

Richie McIlroye6e9320f8172
diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs
index b68eb5ad2..1c5ff7b8b 100644
--- a/crates/recording/src/output_pipeline/core.rs
+++ b/crates/recording/src/output_pipeline/core.rs
@@ -455,7 +455,7 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
let mut first_tx = Some(first_tx);
- stop_token
+ let res = stop_token
.run_until_cancelled(async {
while let Some(frame) = video_rx.next().await {
let timestamp = frame.timestamp();
@@ -471,10 +471,15 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
.map_err(|e| anyhow!("Error queueing video frame: {e}"))?;
}
+ info!("mux-video stream ended (rx closed)");
Ok::<(), anyhow::Error>(())
})
.await;
+ if res.is_none() {
+ info!("mux-video cancelled");
+ }
+
muxer.lock().await.stop();
Ok(())
diff --git a/crates/recording/src/sources/camera.rs b/crates/recording/src/sources/camera.rs
index e60733ece..30ba67392 100644
--- a/crates/recording/src/sources/camera.rs
+++ b/crates/recording/src/sources/camera.rs
@@ -10,6 +10,24 @@ use std::sync::Arc;
pub struct Camera(Arc<CameraFeedLock>);
+struct LogDrop<T>(T, &'static str);
+impl<T> Drop for LogDrop<T> {
+ fn drop(&mut self) {
+ tracing::debug!("Dropping {}", self.1);
+ }
+}
+impl<T> std::ops::Deref for LogDrop<T> {
+ type Target = T;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+impl<T> std::ops::DerefMut for LogDrop<T> {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.0
+ }
+}
+
impl VideoSource for Camera {
type Config = Arc<CameraFeedLock>;
type Frame = FFmpegVideoFrame;
@@ -29,11 +47,14 @@ impl VideoSource for Camera {
.await
.map_err(|e| anyhow!("Failed to add camera sender: {e}"))?;
+ let mut video_tx = LogDrop(video_tx, "camera_video_tx");
+
tokio::spawn(async move {
tracing::debug!("Camera source task started");
loop {
match rx.recv_async().await {
Ok(frame) => {
+ // tracing::trace!("Sending camera frame");
if let Err(e) = video_tx.send(frame).await {
tracing::warn!("Failed to send to video pipeline: {e}");
// If pipeline is closed, we should stop?
diff --git a/crates/recording/src/studio_recording.rs b/crates/recording/src/studio_recording.rs
index 75ef41659..79a7b19c2 100644
--- a/crates/recording/src/studio_recording.rs
+++ b/crates/recording/src/studio_recording.rs
@@ -855,7 +855,7 @@ async fn create_segment_pipeline(
}))
.await
.transpose()
- .context("microphone pipeline setup")?;
+ .context("system audio pipeline setup")?;
let cursor = custom_cursor_capture
.then(move || {