fix(device-selection): use device kind when getting current devices (#4059)
Devices of different kinds can have the same id, such as speaker and mic both being default. Using id only can then lead to incorrectly setting device descriptions in the current devices object.
This commit is contained in:
parent
f73d3a4063
commit
b731459ea4
|
@ -82,31 +82,36 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
|
||||||
case 'getCurrentDevices':
|
case 'getCurrentDevices':
|
||||||
dispatch(getAvailableDevices()).then(devices => {
|
dispatch(getAvailableDevices()).then(devices => {
|
||||||
if (areDeviceLabelsInitialized(state)) {
|
if (areDeviceLabelsInitialized(state)) {
|
||||||
let audioInput, audioOutput, videoInput;
|
const deviceDescriptions = {
|
||||||
const audioOutputDeviceId = getAudioOutputDeviceId();
|
audioInput: undefined,
|
||||||
const { cameraDeviceId, micDeviceId } = settings;
|
audioOutput: undefined,
|
||||||
|
videoInput: undefined
|
||||||
|
};
|
||||||
|
const currentlyUsedDeviceIds = new Set([
|
||||||
|
getAudioOutputDeviceId(),
|
||||||
|
settings.micDeviceId,
|
||||||
|
settings.cameraDeviceId
|
||||||
|
]);
|
||||||
|
|
||||||
devices.forEach(device => {
|
devices.forEach(device => {
|
||||||
const { deviceId } = device;
|
const { deviceId, kind } = device;
|
||||||
|
|
||||||
switch (deviceId) {
|
if (currentlyUsedDeviceIds.has(deviceId)) {
|
||||||
case micDeviceId:
|
switch (kind) {
|
||||||
audioInput = device;
|
case 'audioinput':
|
||||||
|
deviceDescriptions.audioInput = device;
|
||||||
break;
|
break;
|
||||||
case audioOutputDeviceId:
|
case 'audiooutput':
|
||||||
audioOutput = device;
|
deviceDescriptions.audioOutput = device;
|
||||||
break;
|
break;
|
||||||
case cameraDeviceId:
|
case 'videoinput':
|
||||||
videoInput = device;
|
deviceDescriptions.videoInput = device;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
responseCallback({
|
responseCallback(deviceDescriptions);
|
||||||
audioInput,
|
|
||||||
audioOutput,
|
|
||||||
videoInput
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// The labels are not available if the A/V permissions are
|
// The labels are not available if the A/V permissions are
|
||||||
// not yet granted.
|
// not yet granted.
|
||||||
|
|
Loading…
Reference in New Issue