AVAudioSession .defaultToSpeaker changes mic input

自古美人都是妖i 提交于 2019-11-28 00:09:58

Thanks to everyone who took the time to comment. I learned new things from each comment. Seems like I found a solution. Which is actually very simple. When AVAudioSession category is .defaultToSpeaker (Or overrideOutputAudioPort) apparently the tap input buffer framelength changes to 4800 from 4410.

This strangely happens regardless of which microphone is used. So using

AVAudioSession.sharedInstance().setInputDataSource(datasource);

Does not help.

This difference seems to cause problems later in my code. So mic was actually working, but later in code it was failing to do its job due to a different framelength.

Solution/workaround was I basically hardcoded the framelength in the tap. Since I use a converter I don't expect this to be a problem. This means I can set ".defaultToSpeaker" And mic is still working as expected.

capacity = 4410 (DUH!)

Maybe there are different/better ways to approach this problem. So feel free to add your answer if so.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!