Commit e3b0713e40b94b3f0240109ecee53232c616056e

Sam Lantinga 2020-02-24T12:07:18

Don't call setPreferredOutputNumberOfChannels on iOS, it breaks audio output

diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index 10962c5..68aae35 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -855,6 +855,7 @@ COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
         AVAudioSession* session = [AVAudioSession sharedInstance];
         [session setPreferredSampleRate:this->spec.freq error:nil];
         this->spec.freq = (int)session.sampleRate;
+#if TARGET_OS_TV
         if (iscapture) {
             [session setPreferredInputNumberOfChannels:this->spec.channels error:nil];
             this->spec.channels = session.preferredInputNumberOfChannels;
@@ -862,6 +863,9 @@ COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
             [session setPreferredOutputNumberOfChannels:this->spec.channels error:nil];
             this->spec.channels = session.preferredOutputNumberOfChannels;
         }
+#else
+		/* Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS */
+#endif /* TARGET_OS_TV */
     }
 #endif