Bug 1387058 - Part 2: Early return in AudioNotificationReceiver::NotifyDefaultDeviceChanged if there is no AudioStream. r=jwwang, a=lizzard
authorChun-Min Chang <chun.m.chang@gmail.com>
Fri, 04 Aug 2017 15:01:39 +0800
changeset 421661 2e414f305aabc2795cd4e62704559e86eb402710
parent 421660 abfc6cba67470808a1a4a0bb73598d6cb052f749
child 421662 93101738c6f900e32dc4d547076e279201680080
push id7736
push userryanvm@gmail.com
push dateMon, 11 Sep 2017 15:47:51 +0000
treeherdermozilla-beta@94cf7f1ee06b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, lizzard
bugs1387058
milestone56.0
Bug 1387058 - Part 2: Early return in AudioNotificationReceiver::NotifyDefaultDeviceChanged if there is no AudioStream. r=jwwang, a=lizzard MozReview-Commit-ID: HLByqFWqCdn
dom/media/AudioNotificationReceiver.cpp
--- a/dom/media/AudioNotificationReceiver.cpp
+++ b/dom/media/AudioNotificationReceiver.cpp
@@ -63,16 +63,22 @@ AudioNotificationReceiver::Unregister(Au
 }
 
 /* static */ void
 AudioNotificationReceiver::NotifyDefaultDeviceChanged()
 {
   MOZ_ASSERT(XRE_IsContentProcess());
 
   StaticMutexAutoLock lock(sMutex);
+
+  // Do nothing when there is no AudioStream.
+  if (!sSubscribers) {
+    return;
+  }
+
   for (AudioStream* stream : *sSubscribers) {
     ANR_LOG("Notify the AudioStream: %p that the default device has been changed.", stream);
     stream->ResetDefaultDevice();
   }
 }
 
 } // namespace audio
-} // namespace mozilla
\ No newline at end of file
+} // namespace mozilla