AVAudioSession.sampleRate does not get updated

Hello,


After setting the preferred sample rate by calling `setPreferredSampleRate` on `AVAudioSession`, when I query the `sampleRate` on AVAudioSession, it returns the sample rate set earlier by calling the `setPreferredSampleRate` API most of the time. However in few cases (e.g. iPad Pro running iOS 11), the `AVAudioSession.sampleRate` does not get updated. We observed the sampleRate gets updated if the preferred sample rate is set after the AVAudioSession is activated. The setPreferredSampleRate documentation says -


"This method requests a change to the input and output audio sample rate. To see the effect of this change, use the sampleRate property.

You can set a preferred sample rate before or after activating the audio session."


Should I not expect the `sampleRate` to get updated immediately after setting the preferred sample rate when the audio session is not activated?


Thank you,
Piyush

Replies

IIRC, one should not expect the audio sample rate to always be changed to the preferred sample rate. Other processes might be using the current sample rate such that it can't be changed.

Makes sense. Thank you.