Drop me an email if you'd like to hire me (part time) or learn more about what I do. You can read about my experience and references on LinkedIn.
iOS: Selecting audio inputs
Recently I learned how to select microphone inputs and switch between them.
I think it is worth to share, so you might can find it useful. The case was
to switch between built-in and external headset microphone.
Getting devices for media type
The system is returning just one audio device no matter whether headphones
are connected or not.
Well, by asking for device with specific media type we’re not able to select proper
audio input - system selects the source on its own.
Instead of asking for devices with specific media type we can ask AVAudioSession
to return all input ports, iterate through them and select the ones we need.
To select an input, we need to set it as a preferred input.