Bug 1399395 - skip devicechange event handler in shutdown stage. r?pehrsons draft
authorMunro Mengjue Chiang <mchiang@mozilla.com>
Thu, 14 Sep 2017 11:16:42 +0800
changeset 664576 dec92fb0a3875de1bea28f97e121c8f1c369e3a0
parent 658358 8e05298328da75f3056a9f1f9609938870d756a0
child 731473 0054e82aa634d92fa8f150243f7c544cdcb26942
push id79727
push userbmo:mchiang@mozilla.com
push dateThu, 14 Sep 2017 03:17:16 +0000
reviewerspehrsons
bugs1399395
milestone57.0a1
Bug 1399395 - skip devicechange event handler in shutdown stage. r?pehrsons MozReview-Commit-ID: 8skWP7LuGvR
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -2055,16 +2055,19 @@ StopRawIDCallback(MediaManager *aThis,
   aListener->StopRawID(*removedDeviceID);
 }
 
 
 void MediaManager::OnDeviceChange() {
   RefPtr<MediaManager> self(this);
   NS_DispatchToMainThread(media::NewRunnableFrom([self]() mutable {
     MOZ_ASSERT(NS_IsMainThread());
+    if (sInShutdown) {
+      return NS_OK;
+    }
     self->DeviceChangeCallback::OnDeviceChange();
 
     // On some Windows machine, if we call EnumertaeRawDevices immediately after receiving
     // devicechange event, sometimes we would get outdated devices list.
     PR_Sleep(PR_MillisecondsToInterval(100));
     RefPtr<PledgeSourceSet> p = self->EnumerateRawDevices(0, MediaSourceEnum::Camera, MediaSourceEnum::Microphone, false);
     p->Then([self](SourceSet*& aDevices) mutable {
       UniquePtr<SourceSet> devices(aDevices);