From db821dbb465cd8e162dc997b21f96a63871e53a7 Mon Sep 17 00:00:00 2001 From: Dmitry Makarenko Date: Mon, 27 Jan 2025 13:14:46 +0300 Subject: [PATCH] fix 4231: do not set stream format for the global scope as it is not required and not supported by all effects (cherry picked from commit 3cc0977d3646478dc15951523eb6fc16cceb1c7e) Signed-off-by: Avery King --- libraries/lib-audio-unit/AudioUnitWrapper.cpp | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/libraries/lib-audio-unit/AudioUnitWrapper.cpp b/libraries/lib-audio-unit/AudioUnitWrapper.cpp index 4be860ac0..8f46daa8a 100644 --- a/libraries/lib-audio-unit/AudioUnitWrapper.cpp +++ b/libraries/lib-audio-unit/AudioUnitWrapper.cpp @@ -453,13 +453,11 @@ bool AudioUnitWrapper::SetRateAndChannels( sizeof(float) * 8, }; - unsigned one = 1u; const struct Info{ unsigned &nChannels; AudioUnitScope scope; const char *const msg; // used only in log messages } infos[]{ - { one, kAudioUnitScope_Global, "global" }, { mAudioIns, kAudioUnitScope_Input, "input" }, { mAudioOuts, kAudioUnitScope_Output, "output" }, }; @@ -471,21 +469,20 @@ bool AudioUnitWrapper::SetRateAndChannels( identifier.wx_str(), msg); return false; } - if (scope != kAudioUnitScope_Global) { - bool failed = true; - ++nChannels; - do { - --nChannels; - streamFormat.mChannelsPerFrame = nChannels; - failed = SetProperty(kAudioUnitProperty_StreamFormat, - streamFormat, scope); - } while(failed && nChannels > 0); - if (failed) { - wxLogError("%ls didn't accept stream format on %s\n", - // Exposing internal name only in logging - identifier.wx_str(), msg); - return false; - } + + bool failed = true; + ++nChannels; + do { + --nChannels; + streamFormat.mChannelsPerFrame = nChannels; + failed = SetProperty(kAudioUnitProperty_StreamFormat, + streamFormat, scope); + } while(failed && nChannels > 0); + if (failed) { + wxLogError("%ls didn't accept stream format on %s\n", + // Exposing internal name only in logging + identifier.wx_str(), msg); + return false; } } }