Bug 1307754 - Set default device index properly on first enumeration. r=padenot
authorRandell Jesup <rjesup@jesup.org>
Sun, 20 Nov 2016 02:04:21 -0500
changeset 324711 4dc5c5cf427d1603fc71f03588a962747cad5529
parent 324710 00596bfe1df013d063502a48162bd8f2ed9205d3
child 324712 0a18b6782086a5467d0203a542ab75ebc66ad809
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerspadenot
bugs1307754
milestone53.0a1
Bug 1307754 - Set default device index properly on first enumeration. r=padenot MozReview-Commit-ID: B1Sk3W7v5WC
dom/media/webrtc/MediaEngineWebRTC.cpp
--- a/dom/media/webrtc/MediaEngineWebRTC.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTC.cpp
@@ -86,16 +86,17 @@ void AudioInputCubeb::UpdateDeviceList()
       auto j = mDeviceNames->IndexOf(devices->device[i]->device_id);
       if (j != nsTArray<nsCString>::NoIndex) {
         // match! update the mapping
         (*mDeviceIndexes)[j] = i;
       } else {
         // new device, add to the array
         mDeviceIndexes->AppendElement(i);
         mDeviceNames->AppendElement(devices->device[i]->device_id);
+        j = mDeviceIndexes->Length()-1;
       }
       if (devices->device[i]->preferred & CUBEB_DEVICE_PREF_VOICE) {
         // There can be only one... we hope
         NS_ASSERTION(mDefaultDevice == -1, "multiple default cubeb input devices!");
         mDefaultDevice = j;
       }
     }
   }