record-daemon: keep app audio attached across recordings
OBS starts with the daemon and builds one scene, and every recording reuses it. The process captures that used to be created per recording stay in that scene, so a game or Discord window that disappears mid-session keeps feeding the mix. The captures come from a watcher that scans for a window every two seconds: a process with no window cannot be opened, so each source waits for its app to show one, and a new window means the process restarted and needs a fresh source. Settings now travel to the engine, and an audio change swaps only the device captures. Applying them used to clear the scene, which took the process captures with it.
This commit is contained in:
1 parent
9f5f1f669d
commit
365e4ad732
5 files changed
+793
-202
No files matched your search
@@ -3,6 +3,7 @@
|
||||
pub mod encoder;
|
||||
mod obs_context;
|
||||
mod output;
|
||||
mod process_audio;
|
||||
|
||||
pub use encoder::EncoderCapability;
|
||||
pub use obs_context::{ObsContext, ObsContextBuilder};
|
||||
@@ -43,26 +44,34 @@ impl RecordingEngine {
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize the recording engine.
|
||||
/// Start OBS and build the recording scene.
|
||||
///
|
||||
/// This runs at daemon startup rather than on the first game: the audio captures need to
|
||||
/// attach while their applications still have a window, and the scene is then reused by
|
||||
/// every recording.
|
||||
pub fn initialize(&mut self) -> Result<()> {
|
||||
info!("Initializing recording engine");
|
||||
|
||||
let settings = self.settings.read().clone();
|
||||
|
||||
let context = ObsContextBuilder::new()
|
||||
let mut context = ObsContextBuilder::new()
|
||||
.with_video_settings(settings.video.clone())
|
||||
.with_audio_settings(settings.audio.clone())
|
||||
.with_output_dir(&settings.output.path)
|
||||
.build()?;
|
||||
context.start()?;
|
||||
|
||||
self.context = Some(context);
|
||||
info!("Recording engine initialized");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Update settings.
|
||||
pub fn update_settings(&self, new_settings: Settings) -> Result<()> {
|
||||
*self.settings.write() = new_settings;
|
||||
/// Take new settings from the app and apply them to the running OBS context.
|
||||
pub fn update_settings(&mut self, new_settings: Settings) -> Result<()> {
|
||||
*(self.settings.write()) = new_settings.clone();
|
||||
if let Some(context) = self.context.as_mut() {
|
||||
context.apply_settings(new_settings.video, new_settings.audio)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user