iOS getAvailableSampleRates() causes buffer size to switch

Currently, even in the juce demo, if you call getAvailableSampleRates on iOS then your buffer size gets set to 1024 without notifying you. You can observe this in the JuceDemo, after setting the buffer size to anything, the audio callbacks still occur with 1024 sized buffers.

I believe that issue comes from getAvailableSampleRates setting the sample rate for the device without calling updateSampleRateAndAudioInput() or updateCurrentBufferSize(). Adding these two functions to the code after iterating through the available rates fixes the issue.

I also added a Scoped Lock to the callback mutex as I was also seeing that code get hit within the audio callback which is definitely dangerous.

Thanks for reporting.

A fix will appear on the develop branch shortly.

1 Like