Audio Recording not working when bluetooth speaker is connected.
I am currently working on a project in which I have to provide the ability to play and record audio. Everything is working fine except when I use a bluetooth speaker. By default in my app, the audio engine is using PlayAndRecord audio session category. When using this audio session category, connected Bluetooth speaker(JBL Pulse, no mic) does not work with the app. So I tried switching the audio session category to Playback using the
-setAudioSessionCategory method of AEAudioController . After switching, playback works but obviously the recording won't work. So I tried to change the category back to PlaybackAndRecord through AEAudioController but it doesn't change to PlaybackAndRecord. After some debugging I observed that in -setAudioSessionCategory, code checks for available input devices. If there is any input device available, then only it switches to PlayAndRecord otherwise to Playback. So If I switch to Playback category and keep the Bluetooth speaker connected and try to switch to PlayAndRecord category, It doesn't work and recording feature doesn't work.
The audio session provides a facility to override output audio port using
-overrideOutputAudioPort: by passing the constant AVAudioSessionPortOverrideSpeaker which only works with PlayAndRecord audio session category and it overrides both the input and output to device's speakers and mic (making Bluetooth speakers to not work).
Is there any solution to this? Thanks in advance.