What is the proper way of handling audio device changes mid session?

529 views
Skip to first unread message

Spencer Dixon

unread,
Nov 19, 2018, 3:11:54 PM11/19/18
to discuss-webrtc
In our peer connection creation we pass in a `nullptr` for the audio device module which lets webrtc create the default one.  The problem we're running into is if mid session I connect some bluetooth headphones all the audio stops working.

Is there a recommended approach for handling this situation or should the ADM already be handling this and something else may be going on?

My initial thoughts are maybe we need to control the ADM and then have some sort of listener for when the input/output device ID's change and then re-init the ADM.  Does that sound reasonable?

Any guidance would be much appreciate :-)

Jiawei Ou

unread,
Nov 19, 2018, 3:24:24 PM11/19/18
to discuss...@googlegroups.com
There will be some difference between iOS and Android. On iOS, ADM should already be handling this and it will reset the audio unit. If it stop working, it's likely a bug on the webrtc or the iOS side.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/1abd058e-1ef4-4f8a-98bc-3937f97299c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from my nondescript tablet that doesn't pay me to advertise it. Excuse brevity.

Spencer Dixon

unread,
Nov 19, 2018, 3:32:26 PM11/19/18
to discuss-webrtc
Ahh yeah we're on macOS.  I wonder if the mechanisms for listening to changes just aren't set up for mac but they are for iOS?

I've been looking through the ADM code and it looks like it should be reinitializing when the devices change.  In the logs I get this when I start a session with the bluetooth headphones and then disconnect:



(audio_mixer_manager_mac.cc:198): MicrophoneIsInitialized


(audio_device_mac.cc:1947): Capture device is not alive (probably removed)


(audio_mixer_manager_mac.cc:192): SpeakerIsInitialized


(audio_device_mac.cc:1966): Render device is not alive (probably removed)

Jiawei Ou

unread,
Nov 19, 2018, 4:02:15 PM11/19/18
to discuss...@googlegroups.com
I see. 
I have never read into the ADM for mac, so I cannot provide much help there.. 


* This message transmitted on 100% recycled electrons. *


Henrik Andreasson

unread,
Nov 20, 2018, 5:10:18 AM11/20/18
to discuss...@googlegroups.com
Here is an attempt to summarize the situation.

The audio layer in Chrome deals with devices being removed/added during an ongoing audio session. 

The ADMs in native WebRTC have different support depending on OS/platform:
- iOS and Android contains no (or very little) device handling. The user/client is responsible for device handling, enumeration, etc. Some parts are taken care of by the OS itself but not all.
As an example: on Android, any client must implement components like AppRTCAudioManager and AppRTCBluetoothManager to deal with all devices. 
- Desktop ADMs (Windows, Mac OSX, Linux) are rather old and might not be up-to-date when it comes to device handling. A new ADM implementation has recently been landed for Windows
but it is still experimental. For issues related to any of these ADMs, please file an issue


Spencer Dixon

unread,
Nov 20, 2018, 10:31:23 AM11/20/18
to discuss-webrtc
Thank you for the detailed overview!

Vinayak Badrinathan

unread,
Nov 14, 2020, 3:46:56 AM11/14/20
to discuss-webrtc
@spencer -- how did you resolve changing the default audio playout / recording device on runtime? I'm running into the same issue and am trying to figure out what cleanup/init I need to run...

Elise Monaghan

unread,
Apr 8, 2021, 12:58:19 PM4/8/21
to discuss-webrtc
Running into the same problem here. Any help would be appreciated.

Elise Monaghan

unread,
Apr 12, 2021, 5:52:29 PM4/12/21
to discuss-webrtc
Reply all
Reply to author
Forward
0 new messages