Stop CoreAudio from doing expensive audio rate conversion
authorSam Lantinga <slouken@libsdl.org>
Thu, 23 Feb 2017 12:10:02 -0800
changeset 1090666a188fbf8bf
parent 10905 9c6570c422c4
child 10907 e64cf9261cc7
Stop CoreAudio from doing expensive audio rate conversion
src/audio/coreaudio/SDL_coreaudio.m
     1.1 --- a/src/audio/coreaudio/SDL_coreaudio.m	Mon Feb 20 11:02:35 2017 -0800
     1.2 +++ b/src/audio/coreaudio/SDL_coreaudio.m	Thu Feb 23 12:10:02 2017 -0800
     1.3 @@ -734,6 +734,13 @@
     1.4      if (!update_audio_session(this, SDL_TRUE)) {
     1.5          return -1;
     1.6      }
     1.7 +
     1.8 +    /* Stop CoreAudio from doing expensive audio rate conversion */
     1.9 +    @autoreleasepool {
    1.10 +        AVAudioSession* session = [AVAudioSession sharedInstance];
    1.11 +        [session setPreferredSampleRate:this->spec.freq error:nil];
    1.12 +        this->spec.freq = (int)session.sampleRate;
    1.13 +    }
    1.14  #endif
    1.15  
    1.16      /* Setup a AudioStreamBasicDescription with the requested format */