Possible bug setting sample rate in iOS


#1

Jules, 

there's something slightly odd in using AudioDeviceManager::setAudioDeviceSetup on iOS. On line 489 the requested sample rate is checked and adjusted with AudioDeviceManager::chooseBestSampleRate which in turn takes its data from the sampleRates array in iosIOAudioDevice. This is filled by iosIOAudioDevice::updateSampleRates. Now the problem: updateSampleRates is only ever called from the open method which, if you're using setAudioDeviceSetup, won't be called until 2 lines after you've checked and adjusted the sample rate. In effect the first time you call setAudioDeviceSetup it won't change the sample rate.

An easy workaround is just to call setAudioDeviceSetup twice the first time round. I'm not sure what the proper fix would be as I don't really know my way around core audio, and I don't see how you can check the sample rates before you open the device.