feat: add custom audio sources

- Add capture_apps list of AudioSourceConfig (application, deviceOutput
  or deviceInput) to AudioSettings, serialized in the settings JSON
- Add IPC commands getAudioDevices, addAudioSource, removeAudioSource
  and updateAudioSource
- obs_context builds wasapi sources for the microphone and configured
  apps alongside the game-capture source
- Settings.vue gains an audio sources tab with device dropdowns and
  per-source volume
- getAudioDevices temporarily returns hardcoded defaults while the
  WASAPI enumeration crash is investigated; crash marker files around
  IPC and native call sites are part of that investigation
This commit is contained in:
vhaudiquet committed 2026-11-12 23:17:26 +01:00
1 parent 7468bdf5de
commit 4f9f84446d
13 files changed
+1711 -69

No files matched your search

+44 -3
View File
@@ -12,6 +12,29 @@ use super::handlers::IpcHandlers;
use super::protocol::{IpcMessage, IpcNotification, IpcResponse, MessageType};
use crate::error::{IpcError, Result};
/// Write an *unbuffered* marker file that survives native crashes/segfaults.
/// See [`super::handlers`] for the rationale: the tracing log appender buffers
/// writes in memory, so logs emitted microseconds before a native segfault are
/// lost on disk. This helper fsyncs so the bytes hit disk before returning.
#[cfg(target_os = "windows")]
fn write_ipc_crash_marker(stage: &str) {
use std::io::Write;
let dir = std::env::temp_dir().join("record-daemon-crash-markers");
let _ = std::fs::create_dir_all(&dir);
let path = dir.join(format!(
"{}_{}.txt",
stage,
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_nanos())
.unwrap_or(0)
));
if let Ok(mut f) = std::fs::File::create(&path) {
let _ = writeln!(f, "{} @ {:?}", stage, std::thread::current().id());
let _ = f.sync_all();
}
}
/// IPC server configuration.
#[derive(Debug, Clone)]
pub struct IpcServerConfig {
@@ -466,11 +489,16 @@ impl IpcServer {
}
};
trace!("Received: {}", line);
info!("[IPC] Received message ({} bytes)", line.len());
#[cfg(target_os = "windows")]
write_ipc_crash_marker("ipc_read_done");
// Parse message
let message = match IpcMessage::from_json(&line) {
Ok(msg) => msg,
Ok(msg) => {
info!("[IPC] Parsed message type={:?} command={:?}", msg.message_type, msg.command);
msg
}
Err(e) => {
warn!("Failed to parse message: {}", e);
let response =
@@ -486,10 +514,21 @@ impl IpcServer {
continue;
}
};
#[cfg(target_os = "windows")]
write_ipc_crash_marker(&format!("ipc_parsed_{:?}", message.command));
// Handle message
let response = match message.message_type {
MessageType::Request => handlers.handle(message).await,
MessageType::Request => {
#[cfg(target_os = "windows")]
let cmd_dbg = format!("{:?}", message.command);
#[cfg(target_os = "windows")]
write_ipc_crash_marker(&format!("ipc_dispatch_pre_{}", cmd_dbg));
let r = handlers.handle(message).await;
#[cfg(target_os = "windows")]
write_ipc_crash_marker(&format!("ipc_dispatch_post_{}", cmd_dbg));
r
}
MessageType::Notification => {
// Notifications don't get responses
trace!("Received notification: {:?}", message);
@@ -512,6 +551,8 @@ impl IpcServer {
.write_all(b"\n")
.await
.map_err(IpcError::WriteError)?;
#[cfg(target_os = "windows")]
write_ipc_crash_marker("ipc_response_sent");
}
Ok(())