From 51627932451f6972c4af68c552376e72d9e065ed Mon Sep 17 00:00:00 2001 From: attila Date: Tue, 22 Nov 2022 16:42:26 +0100 Subject: [PATCH] CoreAudioIODevice: Fix handling channel configurations with disabled lower bits Prior to this commit it was not possible to deactivate the first few channels of an audio device. If say channel 5 was active in the requested configuration then all channels up to 5 would be active as well regardless of the provided activation pattern. --- modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index fafaacf422..370874d377 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -836,7 +836,12 @@ public: latency (getLatencyFromDevice (isInput, parent)), bitDepth (getBitDepthFromDevice (isInput, parent)), chanNames (getChannelNames (isInput, parent)), - activeChans (BigInteger().setRange (0, jmin (activeRequested.getHighestBit() + 1, chanNames.size()), true)), + activeChans ([&activeRequested, clearFrom = chanNames.size()] + { + auto result = activeRequested; + result.setRange (clearFrom, result.getHighestBit() + 1 - clearFrom, false); + return result; + }()), channelInfo (getChannelInfos (isInput, parent, activeChans)), channels (static_cast (channelInfo.size())) {}