Cap selected channel count at physical maximum

This commit is contained in:
Cameron Gutman
2022-02-06 18:00:14 -06:00
parent 72292dde94
commit edf449b708

View File

@@ -631,9 +631,13 @@ static NSMutableSet* hostList;
// multiController must be set before calling getConnectedGamepadMask
_streamConfig.multiController = streamSettings.multiController;
_streamConfig.gamepadMask = [ControllerSupport getConnectedGamepadMask:_streamConfig];
int numberOfChannels = [streamSettings.audioConfig intValue];
Log(LOG_I, @"Number of audio channels %d", numberOfChannels);
// Probe for supported channel configurations
int physicalOutputChannels = (int)[AVAudioSession sharedInstance].maximumOutputNumberOfChannels;
Log(LOG_I, @"Audio device supports %d channels", physicalOutputChannels);
int numberOfChannels = MIN([streamSettings.audioConfig intValue], physicalOutputChannels);
Log(LOG_I, @"Selected number of audio channels %d", numberOfChannels);
if (numberOfChannels >= 8) {
_streamConfig.audioConfiguration = AUDIO_CONFIGURATION_71_SURROUND;
}