Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

chore: better error log

Louis Beaumont60bdf3d816e4
diff --git a/screenpipe-audio/src/core.rs b/screenpipe-audio/src/core.rs
index 9ee9f6b7a..b78b054e6 100644
--- a/screenpipe-audio/src/core.rs
+++ b/screenpipe-audio/src/core.rs
@@ -300,7 +300,10 @@ pub async fn record_and_transcribe(
},
None,
),
- _ => Err(cpal::BuildStreamError::StreamConfigNotSupported),
+ f => {
+ error!("Unsupported sample format: {:?}", f);
+ return;
+ }
};
match stream {
diff --git a/screenpipe-audio/tests/windows_output_device_tests.rs b/screenpipe-audio/tests/windows_output_device_tests.rs
new file mode 100644
index 000000000..a5bf57130
--- /dev/null
+++ b/screenpipe-audio/tests/windows_output_device_tests.rs
@@ -0,0 +1,50 @@
+#[cfg(target_os = "windows")]
+#[cfg(test)]
+mod tests {
+ use screenpipe_audio::{list_audio_devices, record_and_transcribe};
+ use tokio::sync::mpsc;
+
+ use super::*;
+ use std::{
+ path::PathBuf,
+ sync::{atomic::AtomicBool, Arc},
+ time::Duration,
+ };
+
+ #[tokio::test]
+ async fn test_virtual_audio_device() -> anyhow::Result<()> {
+ // List devices and find the virtual output device
+ let devices = list_audio_devices().await?;
+ let virtual_device = devices
+ .iter()
+ .find(|d| d.name.contains("CABLE Output"))
+ .unwrap();
+
+ println!("Found virtual device: {:?}", virtual_device.name);
+
+ // Set up for recording
+ let duration = Duration::from_secs(5);
+ let output_path = PathBuf::from("test_output.mp4");
+ let (tx, _rx) = mpsc::unbounded_channel();
+ let is_running = Arc::new(AtomicBool::new(true));
+
+ // Record from the virtual device
+ let result = record_and_transcribe(
+ Arc::new(virtual_device.clone()),
+ duration,
+ output_path.clone(),
+ tx,
+ is_running.clone(),
+ )
+ .await;
+
+ assert!(result.is_ok());
+ assert!(output_path.exists());
+
+ println!("result: {:?}", result.unwrap());
+
+ // You might want to add more assertions here, like checking file size, etc.
+
+ Ok(())
+ }
+}
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 54b5b6ed9..abd61be8c 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -15,7 +15,7 @@ use crossbeam::queue::SegQueue;
use dirs::home_dir;
use log::{debug, error, info, LevelFilter};
use screenpipe_audio::{
- default_input_device, list_audio_devices, parse_audio_device, AudioDevice, DeviceControl
+ default_input_device, default_output_device, list_audio_devices, parse_audio_device, AudioDevice, DeviceControl
};
use screenpipe_vision::{monitor::{get_monitor_by_id, list_monitors}, OcrEngine};
use std::io::Write;
@@ -299,18 +299,15 @@ async fn main() -> anyhow::Result<()> {
};
devices_status.insert(input_device, device_control);
}
- // audio output only supported on linux and macos <15.0 atm
+ // audio output only on macos <15.0 atm ?
// see https://github.com/louis030195/screen-pipe/pull/106
- if cfg!(any(target_os = "linux", target_os = "macos")) {
- use screenpipe_audio::default_output_device;
- if let Ok(output_device) = default_output_device().await {
- audio_devices.push(Arc::new(output_device.clone()));
- let device_control = DeviceControl {
- is_running: true,
- is_paused: false,
- };
- devices_status.insert(output_device, device_control);
- }
+ if let Ok(output_device) = default_output_device().await {
+ audio_devices.push(Arc::new(output_device.clone()));
+ let device_control = DeviceControl {
+ is_running: true,
+ is_paused: false,
+ };
+ devices_status.insert(output_device, device_control);
}
} else {
// Use specified devices