Skip to content

Commit 02fbdbf

Browse files
committed
Improve device naming and filter unsupported configs
1 parent f2f92ad commit 02fbdbf

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/host/aaudio/mod.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,13 @@ impl DeviceTrait for Device {
405405
match &self.0 {
406406
None => Ok(DeviceDescriptionBuilder::new("Default Device".to_string()).build()),
407407
Some(info) => {
408-
let mut builder = DeviceDescriptionBuilder::new(info.product_name.clone())
409-
.device_type(info.device_type.into())
408+
let device_type: DeviceType = info.device_type.into();
409+
let name = match device_type {
410+
DeviceType::Unknown => info.product_name.clone(),
411+
_ => format!("{} ({})", info.product_name, device_type),
412+
};
413+
let mut builder = DeviceDescriptionBuilder::new(name)
414+
.device_type(device_type)
410415
.interface_type(info.device_type.into())
411416
.direction(info.direction);
412417

@@ -432,7 +437,12 @@ impl DeviceTrait for Device {
432437
&self,
433438
) -> Result<Self::SupportedInputConfigs, SupportedStreamConfigsError> {
434439
let configs = if let Some(info) = &self.0 {
435-
device_supported_configs(info)
440+
// Output-only devices do not support input
441+
if matches!(info.direction, DeviceDirection::Output) {
442+
Vec::new().into_iter()
443+
} else {
444+
device_supported_configs(info)
445+
}
436446
} else {
437447
default_supported_configs()
438448
};
@@ -443,7 +453,12 @@ impl DeviceTrait for Device {
443453
&self,
444454
) -> Result<Self::SupportedOutputConfigs, SupportedStreamConfigsError> {
445455
let configs = if let Some(info) = &self.0 {
446-
device_supported_configs(info)
456+
// Input-only devices do not support output
457+
if matches!(info.direction, DeviceDirection::Input) {
458+
Vec::new().into_iter()
459+
} else {
460+
device_supported_configs(info)
461+
}
447462
} else {
448463
default_supported_configs()
449464
};

0 commit comments

Comments
 (0)