Test app for displaying/verifying issue with AirPods not allowing routing overrides
System will force the route back to AirPods if the application attempts use overrideOutputAudioPort(_:)
Sample app can be found here
- Pair AirPods to device, and place in ears so device registers AirPods as connected.
- Audio route will automatically switch to AirPods
- Open Application
- Setup
AVAudioSessionaccording to the configuration below - Configure a
NotificationCenterobserver to listen and report changes onAVAudioSession.routeChangeNotification - Activate the audio session by passing
truetosetActive(_:) - Pass
AVAudioSession.PortOverride.speakertooverrideOutputAudioPort(_:)in order to initiate an audio route override - Observer the changes fired from your route change listener from step 4
App audio should be routed to the speakers instead of the AirPods.
AVAudioSessionRouteChangeNotification will report route changed due to AVAudioSessionRouteChangeReasonOverride, but then immediate after will switch back to AirPods with the reason AVAudioSessionRouteChangeReasonNewDeviceAvailable.
NOTE: At no point were the AirPods moved or removed.
- Able to reproduce building with Xcode 10.0 (10A255) using an iPhone 8+ running iOS 12.0.1 (16A404).
- Working as expected building with Xcode 10.0 (10A255) using an iPhone 7 running iOS 11.4.1 (15G77)
AVAudioSessioncategory:AVAudioSessionCategoryPlayAndRecordAVAudioSessionmode:AVAudioSessionModeVoiceChatAVAudioSessioncategory options mode:AVAudioSessionCategoryOptionAllowBluetooth