twilio / audioswitch

An Android audio management library for real-time communication apps.
Apache License 2.0
163 stars 50 forks source link

When should we call the activate() method? #97

Closed rocboronat closed 1 year ago

rocboronat commented 3 years ago

According to the Twilio voice quickstart, the activate() method should be called when the call starts, which is in the Twilio's onConnected() method. But if I do it and call deactivate() when the call ends, the audio mode goes to ringtone instead of normal. So, the user can't change the volume anymore, and the feedback he receives is like the app is actually on a call... or something weird like that. 💭 Something wrong is happening...

That's because when activate() is called, you save the current audio mode which is ringtone because the ringtone is ringing. Later, when the call ends, you restore the audio mode, passing from in communication to ringtone again, instead of normal.

So, am I wrongly using AudioSwitch and I should call activate() in another place, or is this actually a bug?

Thanks a lot for the support and also for open-sourcing this project 👍

afalls-twilio commented 2 years ago

@rocboronat Activate can be called before the call is started too, infact, its probably easier.

rocboronat commented 2 years ago

Then, the ringtone will sound on the earpiece, right?

afalls-twilio commented 1 year ago

@rocboronat I see 2 issues here.. 1) after deactivate was called, did it not revert to the original routing? was 'ringtone' or 'normal' the previous setting prior to calling activate? 2) If the ringtone was triggered by the same application, yes, audioswitch will route it to the earpiece if that is what is selected. If the ringtone is from another application, then I believe its up that application how its routed.