Skip to content

Commit

Permalink
fix(device-selection): use device kind when getting current devices (j…
Browse files Browse the repository at this point in the history
…itsi#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.
  • Loading branch information
virtuacoplenny authored Apr 3, 2019
1 parent f73d3a4 commit b731459
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions react/features/device-selection/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,36 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
case 'getCurrentDevices':
dispatch(getAvailableDevices()).then(devices => {
if (areDeviceLabelsInitialized(state)) {
let audioInput, audioOutput, videoInput;
const audioOutputDeviceId = getAudioOutputDeviceId();
const { cameraDeviceId, micDeviceId } = settings;
const deviceDescriptions = {
audioInput: undefined,
audioOutput: undefined,
videoInput: undefined
};
const currentlyUsedDeviceIds = new Set([
getAudioOutputDeviceId(),
settings.micDeviceId,
settings.cameraDeviceId
]);

devices.forEach(device => {
const { deviceId } = device;

switch (deviceId) {
case micDeviceId:
audioInput = device;
break;
case audioOutputDeviceId:
audioOutput = device;
break;
case cameraDeviceId:
videoInput = device;
break;
const { deviceId, kind } = device;

if (currentlyUsedDeviceIds.has(deviceId)) {
switch (kind) {
case 'audioinput':
deviceDescriptions.audioInput = device;
break;
case 'audiooutput':
deviceDescriptions.audioOutput = device;
break;
case 'videoinput':
deviceDescriptions.videoInput = device;
break;
}
}
});

responseCallback({
audioInput,
audioOutput,
videoInput
});
responseCallback(deviceDescriptions);
} else {
// The labels are not available if the A/V permissions are
// not yet granted.
Expand Down

0 comments on commit b731459

Please sign in to comment.