Skip to content

Audio Control | Default to using earpiece when doing audio vs speaker for video call (depending on presence of headset or not)#3801

Open
BillCarsonFr wants to merge 5 commits intolivekitfrom
valere/default_route
Open

Audio Control | Default to using earpiece when doing audio vs speaker for video call (depending on presence of headset or not)#3801
BillCarsonFr wants to merge 5 commits intolivekitfrom
valere/default_route

Conversation

@BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Mar 12, 2026

Content

fix #3774
This PR is a following up the recent addition of voice call support on android.
When you accept a voice call on android, EC was automatically choosing the speaker audio routing instead of earpiece. Speaker is a good default for video calls, but for voice call you expect the sound out of the earpiece.

We do not handle routing the same way for every platfrom. Mobile has some specificities, as well as some limitations when using only the web API.
That's why we have some native/custom controls for mobiles.

There are been severl iterations, testing, tweaks for the mobile integration. Part of the code is a bit messy due to that (deprecated code, attributes, outdated behavior, etc..)

I spent some time adding more documentation and logs.
We have more than a difference between mobile and web, there are notable difference between iOS and android.

That's why I decided to extract a specific android audio control class AndroidControlledAudioOutput.
It allows me to do extensive testing with real life android values, without riskign regressing any iOS behavior.

The AndroidControlledAudioOutput now uses the initial call intent to decide for the best default.
It is also responsible for auto-swtiching to a device if a new device is added or removed.
If a new device is added it will only switch to it if it is more private. e.g:

  • if you are on headset and a BT speaker connects, you will stay on the headset
  • If you are on speaker and you connect a bluetooth headset, sound will go to headset

Notable change: The android native part used to also do some automatic switching, this was causing selection flickers, as there was 2 different things trying to set a good default.
This is not the case anymore, EC has all the informations to decide for the best device. So the AndroidControlledAudioOutput doesn't listen to native calling the controls to set a device.

=> Need a follow-up task on android, to do some clean-up:

  • Stop using controls to auto select a default
  • Stop using long deprecated methods
  • Stop filtering out hearing aids
  • Mark wired headset as external headsets

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Checklist

  • I have read through CONTRIBUTING.md.
  • Pull request includes screenshots or videos if containing UI changes
  • Tests written for new code (and old code if feasible).
  • Linter and other CI checks pass.
  • I have licensed the changes to Element by completing the Contributor License Agreement (CLA)

@BillCarsonFr BillCarsonFr force-pushed the valere/default_route branch from a8dcebf to d2856dd Compare March 13, 2026 10:23
@BillCarsonFr BillCarsonFr force-pushed the valere/default_route branch from 290e53c to 83b343c Compare March 13, 2026 12:13
@BillCarsonFr BillCarsonFr force-pushed the valere/default_route branch from 9da0a5c to d3a12d5 Compare March 17, 2026 09:16
Add comments on existing code
Extracted a specific android controller for isolation and better testing

lint fixes

Fix device update logic and more tests

better typescript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug | EC should not default voice call to the speaker

1 participant