# iOS output sound through speakers or headphones, while using microphone input

**URL:** <https://qa.fmod.com/t/ios-output-sound-through-speakers-or-headphones-while-using-microphone-input/21543>\
**Category:** Unity\
**Tags:** ios, unity\
**Created:** [April 25, 2024, 5:43pm UTC](https://qa.fmod.com/t/ios-output-sound-through-speakers-or-headphones-while-using-microphone-input/21543 "2024-04-25T17:43:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lingolooper](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@lingolooper](https://qa.fmod.com/u/lingolooper)\
**Post date:** [April 25, 2024, 5:43pm UTC](https://qa.fmod.com/t/ios-output-sound-through-speakers-or-headphones-while-using-microphone-input/21543/1 "2024-04-25T17:43:49Z")

</div>

Hi there!

I just pretty much finished migrating all the audio of my Unity game to FMOD, and now I’m running into an issue with iOS that I don’t know how to solve.

Some context: the game makes heavy use of voice input. By default it should use the speakers of the device for its audio output, the internal mic for input; and when a headphone is connected, it should switch output to that headphone and use its mic if there is one.

To make this work on iOS, I already before needed to set **AVAudioSession** to **AVAudioSessionCategoryPlayAndRecord** ; i am using **AVAudioSessionModeDefault** and for options: **AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetooth**. This worked alright before FMOD.

Now with FMOD, and the same settings, the audio and mic still works with speakers, but as soon as I connect a headphone, I don’t get any audio output anymore. Not in my headphones, and not on the speakers. Only when i disconnect the headphones does the sound resume.

I tried different **AVAudioSession** configurations, but without success. If I only set **AVAudioSessionCategoryPlayAndRecord** and no options, the sound only comes out of the receiver (the small speakers used for phonecalls) and it does not switch to bluetooth headphones when connected. Same if I add the option **AVAudioSessionCategoryOptionAllowBluetooth**.

I found this [post](https://qa.fmod.com/t/ios-sound-plays-through-receiver-when-using-voice-chat/19346/15) which sounded like a similar issue; it didn’t seem to come to any conclusion though. I spent so so much time integrating FMOD, I really hope there is a solution for this; using voice input in games is probably only becoming more commonplace in the future. Please, point me in the right direction!

Thank you! –Simon

---

<div class="post-metadata">

**Author:** ![lingolooper](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@lingolooper](https://qa.fmod.com/u/lingolooper)\
**Post date:** [April 26, 2024, 8:33am UTC](https://qa.fmod.com/t/ios-output-sound-through-speakers-or-headphones-while-using-microphone-input/21543/2 "2024-04-26T08:33:53Z")

</div>

Two observations that might give a clue to what’s going on here:

As soon as I connect a bluetooth headset, I’m getting the following warning spammed in the logs:  
[FMOD] OutputRingBuffer::read : **Insufficient buffer size detected** , requested 24576 bytes, buffer size is 16384 bytes.  
This happens for both my Galaxy Buds and Sony Headphones that i’m testing with.

What I also noticed is that when trying to listen to SYSTEM\_CALLBACK\_TYPE. **DEVICELISTCHANGED,** nothing is being called when connecting headphones. When logging the audio output drivers, there is only ever one driver: driver 0; Core Audio output. Even when headphones are connected. I suppose iOS really only gives us the one driver we are supposed to use…

---

<div class="post-metadata">

**Author:** ![lingolooper](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@lingolooper](https://qa.fmod.com/u/lingolooper)\
**Post date:** [April 26, 2024, 10:41am UTC](https://qa.fmod.com/t/ios-output-sound-through-speakers-or-headphones-while-using-microphone-input/21543/3 "2024-04-26T10:41:16Z")

</div>

Happy to report that [FMOD] OutputRingBuffer::read : **Insufficient buffer size detected** pointed me to the right direction!

What I needed to do is explicitly set sample rate and buffer size for the AVAudioSession in my iOS code. Now I can switch between devices without issue! Works really smoothly actually. This page in the [docs](https://fmod.com/docs/2.00/api/platforms-ios.html) was very helpful. Maybe [this](https://www.fmod.com/docs/2.03/unity/platform-specifics.html#recording) page should link to it!

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [April 29, 2024, 1:27am UTC](https://qa.fmod.com/t/ios-output-sound-through-speakers-or-headphones-while-using-microphone-input/21543/4 "2024-04-29T01:27:17Z")

</div>

Glad to hear it’s working correctly now. I will write up a task to get links from the Unity docs into the Platform Specific doc sections- thanks for the suggestion!
