Bug 1300446 - Check return value from GetCubebContextUnlocked - r=kinetik
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 30 Aug 2016 17:08:06 -0700
changeset 312661 f0a2a1052c7fcfef5bdbb192c84f081e90814694
parent 312660 c3b79bc8557c2976522aaa948b47e8fa14b7ca04
child 312662 03056868056e209bb08eece43061972c66ef4742
push id32003
push usergsquelart@mozilla.com
push dateMon, 05 Sep 2016 06:57:58 +0000
treeherderautoland@03056868056e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1300446
milestone51.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 1300446 - Check return value from GetCubebContextUnlocked - r=kinetik MozReview-Commit-ID: LaXsymagjGW
dom/media/CubebUtils.cpp
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -127,21 +127,25 @@ cubeb* GetCubebContext()
 {
   StaticMutexAutoLock lock(sMutex);
   return GetCubebContextUnlocked();
 }
 
 void InitPreferredSampleRate()
 {
   StaticMutexAutoLock lock(sMutex);
-  if (sPreferredSampleRate == 0 &&
-      cubeb_get_preferred_sample_rate(GetCubebContextUnlocked(),
-                                      &sPreferredSampleRate) != CUBEB_OK) {
-    // Query failed, use a sensible default.
-    sPreferredSampleRate = 44100;
+  if (sPreferredSampleRate == 0) {
+    cubeb* context = GetCubebContextUnlocked();
+    if (context) {
+      if (cubeb_get_preferred_sample_rate(context,
+                                          &sPreferredSampleRate) != CUBEB_OK) {
+        // Query failed, use a sensible default.
+        sPreferredSampleRate = 44100;
+      }
+    }
   }
 }
 
 void InitBrandName()
 {
   if (sBrandName) {
     return;
   }