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

fix(audio): add type annotations for cpal config iterators on Windows

Louis Beaumont6330d5a6cf1a
diff --git a/crates/screenpipe-audio/src/core/device.rs b/crates/screenpipe-audio/src/core/device.rs
index f5aaa8e78..88a8b25d1 100644
--- a/crates/screenpipe-audio/src/core/device.rs
+++ b/crates/screenpipe-audio/src/core/device.rs
@@ -271,8 +271,9 @@ pub async fn get_cpal_device_and_config(
// Get the highest quality configuration based on device type
let config = if is_output_device && !is_display {
- let configs = cpal_audio_device.supported_output_configs()?;
+ let configs: Vec<_> = cpal_audio_device.supported_output_configs()?.collect();
let best_config = configs
+ .iter()
.max_by(|a, b| {
a.max_sample_rate()
.0
@@ -281,10 +282,11 @@ pub async fn get_cpal_device_and_config(
})
.ok_or_else(|| anyhow!("No supported output configurations found"))?;
- best_config.with_sample_rate(best_config.max_sample_rate())
+ best_config.clone().with_sample_rate(best_config.max_sample_rate())
} else {
- let configs = cpal_audio_device.supported_input_configs()?;
+ let configs: Vec<_> = cpal_audio_device.supported_input_configs()?.collect();
let best_config = configs
+ .iter()
.max_by(|a, b| {
a.max_sample_rate()
.0
@@ -293,7 +295,7 @@ pub async fn get_cpal_device_and_config(
})
.ok_or_else(|| anyhow!("No supported input configurations found"))?;
- best_config.with_sample_rate(best_config.max_sample_rate())
+ best_config.clone().with_sample_rate(best_config.max_sample_rate())
};
Ok((cpal_audio_device, config))