Bug 1547381 - Call StopTrack() in the right order. r=padenot
authorJan-Ivar Bruaroey <jib@mozilla.com>
Mon, 06 May 2019 09:14:38 +0000
changeset 531541 cf38c251e2e643abd7b4bbc994f141a5dd174c5b
parent 531540 2547daf183e553ec60d8cb5ccbfb47358a17fb4d
child 531542 729b948b257afc86585243423bb191b845b09238
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1547381
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547381 - Call StopTrack() in the right order. r=padenot Differential Revision: https://phabricator.services.mozilla.com/D29924
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -4591,32 +4591,36 @@ void GetUserMediaWindowListener::StopSha
   for (auto& source : mActiveListeners) {
     source->StopSharing();
   }
 }
 
 void GetUserMediaWindowListener::StopRawID(const nsString& removedDeviceID) {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
 
+  nsTArray<Pair<RefPtr<SourceListener>, TrackID>> matches;
   for (auto& source : mActiveListeners) {
     if (source->GetAudioDevice()) {
       nsString id;
       source->GetAudioDevice()->GetRawId(id);
       if (removedDeviceID.Equals(id)) {
-        source->StopTrack(kAudioTrack);
+        matches.AppendElement(MakePair(source, TrackID(kAudioTrack)));
       }
     }
     if (source->GetVideoDevice()) {
       nsString id;
       source->GetVideoDevice()->GetRawId(id);
       if (removedDeviceID.Equals(id)) {
-        source->StopTrack(kVideoTrack);
+        matches.AppendElement(MakePair(source, TrackID(kVideoTrack)));
       }
     }
   }
+  for (auto& pair : matches) {
+    pair.first()->StopTrack(pair.second());
+  }
 }
 
 void GetUserMediaWindowListener::ChromeAffectingStateChanged() {
   MOZ_ASSERT(NS_IsMainThread());
 
   // We wait until stable state before notifying chrome so chrome only does one
   // update if more updates happen in this event loop.