Bug 1286341 - Initialize sBrandName before layout startup when initializing the cubeb. r?jesup draft
authorPaul Adenot <paul@paul.cx>
Tue, 19 Jul 2016 16:28:56 +0200
changeset 389493 e5d1056dcbb426ecd05bcadebe105960b43dd2c1
parent 389281 feaaf1af1065257b9178faca8b67eed9657b4a17
child 389914 6a04e4b659843b6eeb2e734db26781fdc5430039
push id23436
push userpaul@paul.cx
push dateTue, 19 Jul 2016 14:29:14 +0000
reviewersjesup
bugs1286341
milestone50.0a1
Bug 1286341 - Initialize sBrandName before layout startup when initializing the cubeb. r?jesup We call `cubeb_init` quite early these days because the sandbox is enabled a short time after, so we'd call GetCubebContext before InitBrandName, thus showing the warning. MozReview-Commit-ID: 4gmN8GKq4qd
dom/media/CubebUtils.cpp
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -162,17 +162,22 @@ void InitBrandName()
 
 cubeb* GetCubebContextUnlocked()
 {
   sMutex.AssertCurrentThreadOwns();
   if (sCubebContext) {
     return sCubebContext;
   }
 
-  NS_WARN_IF_FALSE(sBrandName, "Could not get brandName?");
+  if (!sBrandName && NS_IsMainThread()) {
+    InitBrandName();
+  } else {
+    NS_WARN_IF_FALSE(sBrandName,
+        "Did not initialize sbrandName, and not on the main thread?");
+  }
 
   DebugOnly<int> rv = cubeb_init(&sCubebContext, sBrandName);
   NS_WARN_IF_FALSE(rv == CUBEB_OK, "Could not get a cubeb context.");
 
   return sCubebContext;
 }
 
 void ReportCubebBackendUsed()