diff --git a/CHANGELOG.md b/CHANGELOG.md index b09200a95..b2f6b3c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Public error enums are now marked `#[non_exhaustive]` to allow adding variants without SemVer-breaking changes. +- **AAudio**: Device names now include the device type suffix (e.g. "Speaker (Builtin Speaker)") + for easier identification when enumerating devices. +- **AAudio**: `supported_input_configs` and `supported_output_configs` now return an error for + direction-mismatched devices (e.g. querying input configs on an output-only device) instead of + silently returning an empty list. - **ASIO**: `Device::driver`, `asio_streams`, and `current_callback_flag` are no longer `pub`. ### Fixed diff --git a/src/host/aaudio/mod.rs b/src/host/aaudio/mod.rs index c2afe3b21..981153151 100644 --- a/src/host/aaudio/mod.rs +++ b/src/host/aaudio/mod.rs @@ -405,8 +405,13 @@ impl DeviceTrait for Device { match &self.0 { None => Ok(DeviceDescriptionBuilder::new("Default Device".to_string()).build()), Some(info) => { - let mut builder = DeviceDescriptionBuilder::new(info.product_name.clone()) - .device_type(info.device_type.into()) + let device_type: DeviceType = info.device_type.into(); + let name = match device_type { + DeviceType::Unknown => info.product_name.clone(), + _ => format!("{} ({})", info.product_name, device_type), + }; + let mut builder = DeviceDescriptionBuilder::new(name) + .device_type(device_type) .interface_type(info.device_type.into()) .direction(info.direction); @@ -431,23 +436,37 @@ impl DeviceTrait for Device { fn supported_input_configs( &self, ) -> Result { - let configs = if let Some(info) = &self.0 { - device_supported_configs(info) + if let Some(info) = &self.0 { + // Output-only devices do not support input + if matches!(info.direction, DeviceDirection::Output) { + return Err(SupportedStreamConfigsError::BackendSpecific { + err: BackendSpecificError { + description: "output-only device does not support input".to_string(), + }, + }); + } + Ok(device_supported_configs(info)) } else { - default_supported_configs() - }; - Ok(configs) + Ok(default_supported_configs()) + } } fn supported_output_configs( &self, ) -> Result { - let configs = if let Some(info) = &self.0 { - device_supported_configs(info) + if let Some(info) = &self.0 { + // Input-only devices do not support output + if matches!(info.direction, DeviceDirection::Input) { + return Err(SupportedStreamConfigsError::BackendSpecific { + err: BackendSpecificError { + description: "input-only device does not support output".to_string(), + }, + }); + } + Ok(device_supported_configs(info)) } else { - default_supported_configs() - }; - Ok(configs) + Ok(default_supported_configs()) + } } fn default_input_config(&self) -> Result {