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
--- 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()