WebsiteBeaver / CordovaCall

Cordova CallKit & ConnectionService plugin for iOS/Android that displays the native call UI for VOIP apps
MIT License
196 stars 91 forks source link

Turning on speaker for iOS seems to redirect all audio back to the same device #110

Closed mattkhaw closed 3 years ago

mattkhaw commented 3 years ago

@dmarcs @D-Marc1 Not sure why this is happening but when I tried to turn on the speaker option for iOS, it seems that all the audio inputs and outputs redirects back to the same device. I've tried playing around with AVAudioSession settings but none of them work. I've also searched for other source codes to compare and they seem to be exactly the same as this plugin. I've solved the Android part but still haven't finalised the code yet so can't share it at the moment.

I'm using this with cordova-plugin-iosrtc as well and they have the same code as this too. I'm currently testing on iOS 12 and iOS14. All of them has the same behaviour.

mattkhaw commented 3 years ago

I think I've solved the issue. It turns out that AVAudioSessionModeVoiceChat doesn't not transmit audio to the remote device. However, setting it back to AVAudioSessionModeDefault does and yes, we lose the benefits of certain optimisations but if it doesn't work, it's kinda useless too. Also, the echo loopback is caused by the speaker and mic being too close together, so dropping the volume lower seems to do the trick.

Here's the link to the solution => https://stackoverflow.com/questions/49170274/callkit-loudspeaker-bug-how-whatsapp-fixed-it.