From 7a8b276bf3bf5284b75b5b7a462acd7bd711a11f Mon Sep 17 00:00:00 2001 From: Ian Ruiz Date: Tue, 21 Oct 2025 17:28:51 -0500 Subject: [PATCH 1/2] Added Result to fix warning Fix WASAPI Host warnings: Added Stream and impl handling of input/output error configs to return Result for better user experience and better error handling Before: warning: unused import: `crate::SupportedStreamConfigsError` --> src\host\wasapi\mod.rs:11:5 | 11 | use crate::SupportedStreamConfigsError; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- src/host/wasapi/mod.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/host/wasapi/mod.rs b/src/host/wasapi/mod.rs index e80760267..982c21963 100644 --- a/src/host/wasapi/mod.rs +++ b/src/host/wasapi/mod.rs @@ -25,6 +25,25 @@ impl Host { pub fn new() -> Result { Ok(Host) } + + fn supported_output_configs(&self, device: &Device) -> Result { + Ok(device.supported_output_configs()?) + } + + fn supported_input_configs(&self, device: &Device) -> Result { + Ok(device.supported_input_configs()?) + } + +} + +impl From for DevicesError { + fn from(err: SupportedStreamConfigsError) -> DevicesError { + DevicesError::BackendSpecific { + err: BackendSpecificError { + description: format!("SupportedStreamConfigsError: {}", err), + }, + } + } } impl HostTrait for Host { @@ -39,7 +58,7 @@ impl HostTrait for Host { fn devices(&self) -> Result { Devices::new() } - + fn default_input_device(&self) -> Option { default_input_device() } @@ -47,6 +66,7 @@ impl HostTrait for Host { fn default_output_device(&self) -> Option { default_output_device() } + } impl From for BackendSpecificError { From bfe447047058f4bd4d99fd22002a0054db0cd760 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Oct 2025 11:35:36 -0500 Subject: [PATCH 2/2] Format code with cargo fmt --- src/host/wasapi/mod.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/host/wasapi/mod.rs b/src/host/wasapi/mod.rs index 982c21963..6f479e954 100644 --- a/src/host/wasapi/mod.rs +++ b/src/host/wasapi/mod.rs @@ -6,6 +6,7 @@ pub use self::stream::Stream; use crate::traits::HostTrait; use crate::BackendSpecificError; use crate::DevicesError; +use crate::SupportedStreamConfigsError; use std::io::Error as IoError; use windows::Win32::Media::Audio; @@ -25,15 +26,20 @@ impl Host { pub fn new() -> Result { Ok(Host) } - - fn supported_output_configs(&self, device: &Device) -> Result { - Ok(device.supported_output_configs()?) + + fn supported_input_configs( + &self, + device: &Device, + ) -> Result { + Ok(device.supported_input_configs()?) } - - fn supported_input_configs(&self, device: &Device) -> Result { + + fn supported_output_configs( + &self, + device: &Device, + ) -> Result { Ok(device.supported_input_configs()?) } - } impl From for DevicesError { @@ -58,7 +64,7 @@ impl HostTrait for Host { fn devices(&self) -> Result { Devices::new() } - + fn default_input_device(&self) -> Option { default_input_device() } @@ -66,7 +72,6 @@ impl HostTrait for Host { fn default_output_device(&self) -> Option { default_output_device() } - } impl From for BackendSpecificError {