fix: apply audio volumes, enumerate real devices, remove dead code

- Audio sources were created but never added to the scene, so mic,
  game and app audio never reached the output; all sources are now
  added with their configured volume via obs_source_set_volume
- getAudioDevices enumerates real WASAPI devices again instead of
  returning hardcoded defaults (the crash-isolation bypass)
- Recording module split: encoder selection and output building move
  to their own files; obs_context shrinks from 1556 to 464 lines
- Remove unused IPC (recordings/timeline/export commands), the
  CommandHandler trait, crash marker files, and the stats plumbing
  that was never wired to the frontend
- Deduplicate the LCU reconnect logic into connect_and_listen
This commit is contained in:
vhaudiquet committed 2026-11-13 00:06:16 +01:00
1 parent 4f9f84446d
commit 2e98159083
15 files changed
+457 -2662

No files matched your search

+15 -63
View File
@@ -1,28 +1,23 @@
//! Recording module for video capture using libobs.
//!
//! This module provides the recording engine that captures game footage
//! and encodes it using hardware or software encoders.
mod capture;
pub mod encoder;
mod obs_context;
mod output;
pub use capture::{CaptureMode, GameCapture, MonitorCapture, SourceType, WindowCapture};
pub use encoder::{AudioEncoderConfig, EncoderCapability, EncoderConfig, EncoderSettings};
pub use encoder::EncoderCapability;
pub use obs_context::{ObsContext, ObsContextBuilder};
pub use output::{OutputConfig, OutputFormat, RecordingOutput, RecordingResult, RecordingStats};
pub use output::{RecordingOutput, RecordingResult};
use std::sync::Arc;
use chrono::{DateTime, Utc};
use parking_lot::RwLock;
use tracing::{error, info, warn};
use tracing::{info, warn};
use crate::config::Settings;
use crate::error::{RecordingError, Result};
/// Recording engine that manages the entire recording pipeline.
/// Recording engine that manages the recording pipeline.
pub struct RecordingEngine {
/// OBS context.
context: Option<ObsContext>,
@@ -49,14 +44,11 @@ impl RecordingEngine {
}
/// Initialize the recording engine.
///
/// This sets up OBS and prepares for recording.
pub fn initialize(&mut self) -> Result<()> {
info!("Initializing recording engine");
let settings = self.settings.read().clone();
// Build OBS context
let context = ObsContextBuilder::new()
.with_video_settings(settings.video.clone())
.with_audio_settings(settings.audio.clone())
@@ -64,15 +56,13 @@ impl RecordingEngine {
.build()?;
self.context = Some(context);
info!("Recording engine initialized successfully");
info!("Recording engine initialized");
Ok(())
}
/// Update settings.
pub fn update_settings(&self, new_settings: Settings) -> Result<()> {
let mut settings = self.settings.write();
*settings = new_settings;
*self.settings.write() = new_settings;
Ok(())
}
@@ -92,39 +82,20 @@ impl RecordingEngine {
}
/// Start recording.
///
/// # Arguments
/// * `game_id` - Optional game ID for the recording.
/// * `champion` - Optional champion name for the filename.
pub fn start_recording(&mut self, game_id: Option<u64>, champion: Option<&str>) -> Result<()> {
info!(
"RecordingEngine::start_recording called - game_id: {:?}, champion: {:?}",
game_id, champion
);
if self.is_recording {
warn!("Already recording, returning error");
return Err(RecordingError::AlreadyRecording.into());
}
info!("Reading settings...");
let settings = self.settings.read().clone();
// Generate output filename
let filename = self.generate_filename(game_id, champion);
let output_path = settings.output.path.join(&filename);
info!("Starting recording to: {:?}", output_path);
// Start the recording
let context = self.context.as_mut().ok_or_else(|| {
error!("OBS not initialized when start_recording was called");
RecordingError::ObsInitError("OBS not initialized".to_string())
})?;
info!("Calling OBS context start_recording...");
let context = self
.context
.as_mut()
.ok_or_else(|| RecordingError::ObsInitError("OBS not initialized".to_string()))?;
context.start_recording(&output_path)?;
info!("OBS context start_recording returned successfully");
self.current_output = Some(RecordingOutput {
path: output_path,
@@ -134,7 +105,7 @@ impl RecordingEngine {
self.start_time = Some(Utc::now());
self.is_recording = true;
info!("Recording started successfully");
info!("Recording started");
Ok(())
}
@@ -147,48 +118,29 @@ impl RecordingEngine {
let context = self.context.as_mut().ok_or(RecordingError::ObsInitError(
"OBS not initialized".to_string(),
))?;
info!("Stopping recording");
// Stop the recording
context.stop_recording()?;
let output = self
.current_output
.take()
.ok_or(RecordingError::StopError("No active output".to_string()))?;
let start_time = self
.start_time
.take()
.ok_or(RecordingError::StopError("No start time".to_string()))?;
let end_time = Utc::now();
let duration = end_time - start_time;
self.is_recording = false;
let result = RecordingResult {
info!("Recording stopped: {:?}", output.path);
Ok(RecordingResult {
path: output.path,
game_id: output.game_id,
champion: output.champion,
start_time,
end_time,
duration,
stats: None, // Stats would be populated from OBS context if available
};
info!("Recording stopped: {:?}", result.path);
Ok(result)
}
/// Get the current recording timestamp (time since recording started).
pub fn current_timestamp(&self) -> Option<chrono::Duration> {
if !self.is_recording {
return None;
}
self.start_time.map(|start| Utc::now() - start)
duration: end_time - start_time,
})
}
/// Generate a filename for the recording.