Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
b731459ea4
No account linked to committer's email address
1 değiştirilmiş dosya ile 25 ekleme ve 20 silme
  1. 25
    20
      react/features/device-selection/functions.js

+ 25
- 20
react/features/device-selection/functions.js Dosyayı Görüntüle

82
     case 'getCurrentDevices':
82
     case 'getCurrentDevices':
83
         dispatch(getAvailableDevices()).then(devices => {
83
         dispatch(getAvailableDevices()).then(devices => {
84
             if (areDeviceLabelsInitialized(state)) {
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
                 devices.forEach(device => {
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
             } else {
115
             } else {
111
                 // The labels are not available if the A/V permissions are
116
                 // The labels are not available if the A/V permissions are
112
                 // not yet granted.
117
                 // not yet granted.

Loading…
İptal
Kaydet