From 5594cc84c7d8d489bcb6c2fceca53a92a953a0bd Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Wed, 13 Nov 2024 13:44:37 -0800 Subject: [PATCH] Do not send extra channels for aggregate devices. After f8df86f753d81c3ef2e8a6661b11ed65af579919, we drop the **first** several channels if there are extras (e.g. for aggregate devices). This is often incorrect (because the first device is the input device), and also is inefficient. --- src/backend/mod.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/backend/mod.rs b/src/backend/mod.rs index e320d020..b0ca1d22 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -3612,16 +3612,11 @@ impl<'ctx> CoreStreamData<'ctx> { self.stm_ptr, input_hw_desc ); - // Notice: when we are using aggregate device, the input_hw_desc.mChannelsPerFrame is - // the total of all the input channel count of the devices added in the aggregate device. - // Due to our aggregate device settings, the data captured by the output device's input - // channels will be put in the beginning of the raw data given by the input callback. - - // Always request all the input channels of the device, and only pass the correct - // channels to the audio callback. + // The input stream channel count is not necessarily the same as the + // input **device** channel count; request the latter from audiounit. let params = unsafe { let mut p = *self.input_stream_params.as_ptr(); - p.channels = input_hw_desc.mChannelsPerFrame; + p.channels = device_channel_count; // Input AudioUnit must be configured with device's sample rate. // we will resample inside input callback. p.rate = input_hw_desc.mSampleRate as _;