Possible BUG? Getting the buffer size after route change


#1

Hi Jules,

I was browsing the code because I wanted to add a notification on iOS when the buffer size changes behind the scenes (other applications can do that) so that I could update my buffer size, etc. While doing that I noticed what seems to be a bug when getting the “actual” buffer size:
juce_ios_Audio.cpp - Line 348

            Float32 bufferDuration = preferredBufferSize / sampleRate;
            UInt32 bufferDurationSize = sizeof (bufferDuration);
            AudioSessionGetProperty (kAudioSessionProperty_CurrentHardwareIOBufferDuration, &bufferDurationSize, &bufferDurationSize);
            actualBufferSize = (int) (sampleRate * bufferDuration + 0.5);

The two parameters passed when getting the property are both the bufferDurationSize, which never gets used again, rendering that call useless. My guess is that you meant to do:

            AudioSessionGetProperty (kAudioSessionProperty_CurrentHardwareIOBufferDuration, &bufferDurationSize, &bufferDuration);
            actualBufferSize = (int) (sampleRate * bufferDuration + 0.5);

#2

Doh! Yes, thanks very much! (Bizarre that nobody spotted that before…)