I have an audio room application where the user can switch the mic input.
When I switch the sound input to the audio room using the replaceTracks function of the API then I can see the both the previous and new audio devices in Pulse Audio as being used by the browser for “recording”.
However, if I switch audio devices in the Device Selection demo, the audio input that the browser is “recording” simply changes in place. Not duplicates.
https://janus.conf.meetecho.com/devicetest.html
I can’t find anything that I am forgetting to do that would result in the sound input hanging. The application still works, in that it uses the last selected audio input, but this is obviously a bit messy.
How do I cleanly switch sound inputs without leaving the previous one active?
gSendMixerHandle.replaceTracks({
tracks: [
{ type: 'audio',
mid: '0',
capture: {
autoGainControl: true,
latency: 0,
echoCancellation: !gMusicTx,
noiseSuppression: !gMusicTx,
deviceId: {
exact: micDeviceId
}
},
recv: true
}
],
error: function(err) {
Janus.error("Error when changing Mic : ", err);
}
});