AVAudioSession not respecting allowBluetooth not set in iOS 15.x

Hi,

In iOS 14.7.1 (testing on iPhone 6S) doing this:

AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode:AVAudioSession.Mode.default, options: [.mixWithOthers, .defaultToSpeaker])

outputs the audio on speaker even if I have a Bluetooth headset connected.

In iOS 15.6 (testing on iPhone 11) audio is always output to Bluetooth even if .allowBluetooth is not set in setCategory.

Is this an intended change in iOS15 or a bug? I have tried overrideOutputAudioPort(.speaker) as well in iOS15 but it does not make a difference, audio is always output over Bluetooth when connected.

Thanks in advance

Answering myself here. After further investigation, this happened due to that a third party library (pjsip) opens VPIO with mic and speaker even if configured for only playback. This was by design and could be solved by turning off EC in that lib. Then it seems as in iOS 15, if there is an input route over Bluetooth, it will use that, which was not the case in previous iOS versions. The solution here was to control the EC setting in the third-party library manually to get the desired behavior.

AVAudioSession not respecting allowBluetooth not set in iOS 15.x
 
 
Q