Ver código fonte

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.
master
virtuacoplenny 6 anos atrás
pai
commit
b731459ea4
Nenhuma conta vinculada ao e-mail do autor do commit
1 arquivos alterados com 25 adições e 20 exclusões
  1. 25
    20
      react/features/device-selection/functions.js

+ 25
- 20
react/features/device-selection/functions.js Ver arquivo

@@ -82,31 +82,36 @@ export function processExternalDeviceRequest( // eslint-disable-line max-params
82 82
     case 'getCurrentDevices':
83 83
         dispatch(getAvailableDevices()).then(devices => {
84 84
             if (areDeviceLabelsInitialized(state)) {
85
-                let audioInput, audioOutput, videoInput;
86
-                const audioOutputDeviceId = getAudioOutputDeviceId();
87
-                const { cameraDeviceId, micDeviceId } = settings;
85
+                const deviceDescriptions = {
86
+                    audioInput: undefined,
87
+                    audioOutput: undefined,
88
+                    videoInput: undefined
89
+                };
90
+                const currentlyUsedDeviceIds = new Set([
91
+                    getAudioOutputDeviceId(),
92
+                    settings.micDeviceId,
93
+                    settings.cameraDeviceId
94
+                ]);
88 95
 
89 96
                 devices.forEach(device => {
90
-                    const { deviceId } = device;
91
-
92
-                    switch (deviceId) {
93
-                    case micDeviceId:
94
-                        audioInput = device;
95
-                        break;
96
-                    case audioOutputDeviceId:
97
-                        audioOutput = device;
98
-                        break;
99
-                    case cameraDeviceId:
100
-                        videoInput = device;
101
-                        break;
97
+                    const { deviceId, kind } = device;
98
+
99
+                    if (currentlyUsedDeviceIds.has(deviceId)) {
100
+                        switch (kind) {
101
+                        case 'audioinput':
102
+                            deviceDescriptions.audioInput = device;
103
+                            break;
104
+                        case 'audiooutput':
105
+                            deviceDescriptions.audioOutput = device;
106
+                            break;
107
+                        case 'videoinput':
108
+                            deviceDescriptions.videoInput = device;
109
+                            break;
110
+                        }
102 111
                     }
103 112
                 });
104 113
 
105
-                responseCallback({
106
-                    audioInput,
107
-                    audioOutput,
108
-                    videoInput
109
-                });
114
+                responseCallback(deviceDescriptions);
110 115
             } else {
111 116
                 // The labels are not available if the A/V permissions are
112 117
                 // not yet granted.

Carregando…
Cancelar
Salvar