From 94cbdcf0b1f3788a38f720038b6f1493973980e1 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 19 Nov 2026 22:47:57 +0100 Subject: [PATCH] record-daemon: build the Linux capture path again CI has been red since libobs-simple started handing back an either-or source for screen capture: on Linux the builder picks X11 or PipeWire, so build() gives ObsEitherSource rather than a source ref, and the closure's error was left as a RecordingError instead of the daemon's. The kept source is now a per-platform alias, one type on Windows and the either-or on Linux; the scene calls only ask for a source, so both go through. The encoder list is built per platform too: the Linux one never grew past x264 and the `mut` was flagged. --- record-daemon/src/recording/encoder.rs | 12 +++++++++--- record-daemon/src/recording/obs_context.rs | 21 ++++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/record-daemon/src/recording/encoder.rs b/record-daemon/src/recording/encoder.rs index fb1da54..56080dc 100644 --- a/record-daemon/src/recording/encoder.rs +++ b/record-daemon/src/recording/encoder.rs @@ -17,11 +17,18 @@ pub enum EncoderCapability { } /// All encoders available on this machine. +/// +/// Only the Windows branch has anything to add; elsewhere the list is x264 and nobody has to +/// grow it. pub fn detect_hardware_encoders() -> Vec { - let mut capabilities = vec![EncoderCapability::Software]; + #[cfg(not(target_os = "windows"))] + { + vec![EncoderCapability::Software] + } #[cfg(target_os = "windows")] { + let mut capabilities = vec![EncoderCapability::Software]; let vendors = detect_gpu_vendors(); if vendors.contains(&GpuVendor::Nvidia) { capabilities.push(EncoderCapability::Nvenc); @@ -32,9 +39,8 @@ pub fn detect_hardware_encoders() -> Vec { if vendors.contains(&GpuVendor::Intel) { capabilities.push(EncoderCapability::QuickSync); } + capabilities } - - capabilities } /// The single best encoder for recording, hardware over software. diff --git a/record-daemon/src/recording/obs_context.rs b/record-daemon/src/recording/obs_context.rs index 2c58fcc..66b9faa 100644 --- a/record-daemon/src/recording/obs_context.rs +++ b/record-daemon/src/recording/obs_context.rs @@ -151,7 +151,7 @@ pub struct ObsContext { /// Process captures. They are scene items as well, but the watcher owns them. process_audio: Option, /// Video source of the recording that is running, added to the scene on start. - video: Option, + video: Option, output: Option, recording: bool, /// Settings that arrived while a recording was running, applied once it stops. @@ -538,12 +538,21 @@ fn add_device_sources( Ok(added) } +/// The capture source a recording runs with, kept so stopping can take it back out. +/// +/// Windows builds one game or monitor capture. Linux picks X11 or PipeWire from the display +/// server, which the builder settles at build time, so the source is one of two types there. +#[cfg(target_os = "windows")] +type VideoSource = ObsSourceRef; +#[cfg(target_os = "linux")] +type VideoSource = libobs_simple::sources::linux::LinuxGeneralScreenCaptureSourceRef; + /// Put a video capture source in the scene for the recording that is starting. #[cfg(target_os = "windows")] fn add_video_source( context: &LibObsContext, scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>, - slot: &mut Option, + slot: &mut Option, ) -> Result<()> { use libobs_simple::sources::windows::{GameCaptureSourceBuilder, ObsGameCaptureMode}; @@ -594,7 +603,7 @@ fn add_video_source( fn add_video_source( context: &LibObsContext, scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>, - slot: &mut Option, + slot: &mut Option, ) -> Result<()> { use libobs_simple::sources::linux::LinuxGeneralScreenCaptureBuilder; @@ -604,7 +613,9 @@ fn add_video_source( LinuxGeneralScreenCaptureBuilder::new("screen_capture", context.runtime().clone()) .map_err(|e| RecordingError::StartError(format!("screen capture builder: {:?}", e)))? .build() - .map_err(|e| RecordingError::StartError(format!("screen capture source: {:?}", e))) + .map_err(|e| { + RecordingError::StartError(format!("screen capture source: {:?}", e)).into() + }) })?; scene .add_source(source.clone()) @@ -616,7 +627,7 @@ fn add_video_source( /// Take the video source back out of the scene and drop it. fn remove_video_source( scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>, - source: Option, + source: Option, ) -> Result<()> { let (Some(scene), Some(source)) = (scene, source) else { return Ok(());