Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 31 additions & 12 deletions src/host/aaudio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuperKenVery was arguing that it should include the address. I'm not so sure because an address is not a name. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my case, device_type is unique enough to distinguish the device.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roderickvd I added the changelog entry.

};
let mut builder = DeviceDescriptionBuilder::new(name)
.device_type(device_type)
.interface_type(info.device_type.into())
.direction(info.direction);

Expand All @@ -431,23 +436,37 @@ impl DeviceTrait for Device {
fn supported_input_configs(
&self,
) -> Result<Self::SupportedInputConfigs, SupportedStreamConfigsError> {
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<Self::SupportedOutputConfigs, SupportedStreamConfigsError> {
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<SupportedStreamConfig, DefaultStreamConfigError> {
Expand Down