From edf449b708f1232b48b5aadcfbe8c5b6cc12a7d1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 6 Feb 2022 18:00:14 -0600 Subject: [PATCH] Cap selected channel count at physical maximum --- Limelight/ViewControllers/MainFrameViewController.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index 508ce446..968d0151 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -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; }