diff options
author | Joas Schilling <coding@schilljs.com> | 2021-08-27 11:51:15 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-08-30 11:25:06 +0300 |
commit | 84834e63847f16995e6a11c175ed33b952384f73 (patch) | |
tree | 8ea6cd46a2a9b9c2d38a3e04b9996043d978bdf9 /src | |
parent | 44ad976b56198a3456a01fe261639ec6bb10cc7d (diff) |
Use fallback device once all devices were processed
Otherwise the first device found would be used even if a "default"
device was found later.
In practice this may not be needed, as Chromium seems to always list the
"default" device first if it is available, but just in case.
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/webrtc/MediaDevicesManager.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/utils/webrtc/MediaDevicesManager.js b/src/utils/webrtc/MediaDevicesManager.js index e94529753..a231900e1 100644 --- a/src/utils/webrtc/MediaDevicesManager.js +++ b/src/utils/webrtc/MediaDevicesManager.js @@ -226,6 +226,14 @@ MediaDevicesManager.prototype = { this._addDevice(addedDevice) }) + // Fallback in case we didn't find the previously picked device + if (this.attributes.audioInputId === undefined) { + this.attributes.audioInputId = this._fallbackAudioInputId + } + if (this.attributes.videoInputId === undefined) { + this.attributes.videoInputId = this._fallbackVideoInputId + } + // Trigger change events after all the devices are processed to // prevent change events for intermediate states. if (previousAudioInputId !== this.attributes.audioInputId) { @@ -325,9 +333,6 @@ MediaDevicesManager.prototype = { if (!this._fallbackAudioInputId || addedDevice.deviceId === 'default') { this._fallbackAudioInputId = addedDevice.deviceId } - if (this.attributes.audioInputId === undefined) { - this.attributes.audioInputId = this._fallbackAudioInputId - } } else if (addedDevice.kind === 'videoinput') { if (BrowserStorage.getItem('videoInputId') === addedDevice.deviceId) { this.attributes.videoInputId = addedDevice.deviceId @@ -335,9 +340,6 @@ MediaDevicesManager.prototype = { if (!this._fallbackVideoInputId || addedDevice.deviceId === 'default') { this._fallbackVideoInputId = addedDevice.deviceId } - if (this.attributes.videoInputId === undefined) { - this.attributes.videoInputId = this._fallbackVideoInputId - } } this.attributes.devices.push(addedDevice) |