Skip to content

Commit 8c8ac4d

Browse files
committed
Add a blocklist function for devices to use with VPIO
1 parent 198e8ed commit 8c8ac4d

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

src/backend/mod.rs

+47-1
Original file line numberDiff line numberDiff line change
@@ -2670,14 +2670,60 @@ impl<'ctx> CoreStreamData<'ctx> {
26702670
input_domain == output_domain
26712671
}
26722672

2673+
fn should_block_vpio_for_device_pair(
2674+
&self,
2675+
in_device: &device_info,
2676+
out_device: &device_info,
2677+
) -> bool {
2678+
self.debug_assert_is_on_stream_queue();
2679+
cubeb_log!("Evaluating device pair against VPIO block list");
2680+
let log_device = |id, devtype| -> std::result::Result<(), OSStatus> {
2681+
cubeb_log!("{} uid='{}', model_uid='{}', transport_type={}, source={}, source_name='{}', name='{}', manufacturer='{}'",
2682+
if devtype == DeviceType::INPUT {
2683+
"Input"
2684+
} else {
2685+
debug_assert_eq!(devtype, DeviceType::OUTPUT);
2686+
"Output"
2687+
},
2688+
get_device_uid(id, devtype).map(|s| s.into_string()).unwrap_or_default(),
2689+
get_device_model_uid(id, devtype).map(|s| s.into_string()).unwrap_or_default(),
2690+
get_device_transport_type(id, devtype).unwrap_or(0),
2691+
get_device_source(id, devtype).unwrap_or(0),
2692+
get_device_source_name(id, devtype).map(|s| s.into_string()).unwrap_or_default(),
2693+
get_device_name(id, devtype).map(|s| s.into_string()).unwrap_or_default(),
2694+
get_device_manufacturer(id, devtype).map(|s| s.into_string()).unwrap_or_default());
2695+
Ok(())
2696+
};
2697+
log_device(in_device.id, DeviceType::INPUT);
2698+
log_device(out_device.id, DeviceType::OUTPUT);
2699+
const APPLE_STUDIO_DISPLAY_USB_ID: &str = "05AC:1114";
2700+
match (
2701+
get_device_model_uid(in_device.id, DeviceType::INPUT).map(|s| s.to_string()),
2702+
get_device_model_uid(out_device.id, DeviceType::OUTPUT).map(|s| s.to_string()),
2703+
) {
2704+
(Ok(in_model_uid), Ok(out_model_uid))
2705+
if in_model_uid.contains(APPLE_STUDIO_DISPLAY_USB_ID)
2706+
&& out_model_uid.contains(APPLE_STUDIO_DISPLAY_USB_ID) =>
2707+
{
2708+
cubeb_log!("Both input and output device is an Apple Studio Display. BLOCKED");
2709+
true
2710+
}
2711+
_ => {
2712+
cubeb_log!("Device pair is not blocked");
2713+
false
2714+
}
2715+
}
2716+
}
2717+
26732718
fn create_audiounits(&mut self) -> Result<(device_info, device_info)> {
26742719
self.debug_assert_is_on_stream_queue();
26752720
let should_use_voice_processing_unit = self.has_input()
26762721
&& self.has_output()
26772722
&& self
26782723
.input_stream_params
26792724
.prefs()
2680-
.contains(StreamPrefs::VOICE);
2725+
.contains(StreamPrefs::VOICE)
2726+
&& !self.should_block_vpio_for_device_pair(&self.input_device, &self.output_device);
26812727

26822728
let should_use_aggregate_device = {
26832729
// It's impossible to create an aggregate device from an aggregate device, and it's

0 commit comments

Comments
 (0)