Bug 1404977 - Part 1 - Add missing lock to the PREF_CUBEB_BACKEND branch of the pref callback in CubebUtils.cpp. r?pehrsons
MozReview-Commit-ID: CBAmQKDq36z
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -195,27 +195,27 @@ void PrefChanged(const char* aPref, void
Preferences::GetCString(aPref, value);
StaticMutexAutoLock lock(sMutex);
if (value.IsEmpty()) {
sVolumeScale = 1.0;
} else {
sVolumeScale = std::max<double>(0, PR_strtod(value.get(), nullptr));
}
} else if (strcmp(aPref, PREF_CUBEB_LATENCY_PLAYBACK) == 0) {
+ StaticMutexAutoLock lock(sMutex);
// Arbitrary default stream latency of 100ms. The higher this
// value, the longer stream volume changes will take to become
// audible.
sCubebPlaybackLatencyPrefSet = Preferences::HasUserValue(aPref);
uint32_t value = Preferences::GetUint(aPref, CUBEB_NORMAL_LATENCY_MS);
- StaticMutexAutoLock lock(sMutex);
sCubebPlaybackLatencyInMilliseconds = std::min<uint32_t>(std::max<uint32_t>(value, 1), 1000);
} else if (strcmp(aPref, PREF_CUBEB_LATENCY_MSG) == 0) {
+ StaticMutexAutoLock lock(sMutex);
sCubebMSGLatencyPrefSet = Preferences::HasUserValue(aPref);
uint32_t value = Preferences::GetUint(aPref, CUBEB_NORMAL_LATENCY_FRAMES);
- StaticMutexAutoLock lock(sMutex);
// 128 is the block size for the Web Audio API, which limits how low the
// latency can be here.
// We don't want to limit the upper limit too much, so that people can
// experiment.
sCubebMSGLatencyInFrames = std::min<uint32_t>(std::max<uint32_t>(value, 128), 1e6);
} else if (strcmp(aPref, PREF_CUBEB_FORCE_SAMPLE_RATE) == 0) {
StaticMutexAutoLock lock(sMutex);
sCubebForcedSampleRate = Preferences::GetUint(aPref);
@@ -229,16 +229,17 @@ void PrefChanged(const char* aPref, void
} else if (value.EqualsLiteral("normal")) {
cubeb_set_log_callback(CUBEB_LOG_NORMAL, CubebLogCallback);
cubebLog->SetLevel(LogLevel::Error);
} else if (value.IsEmpty()) {
cubeb_set_log_callback(CUBEB_LOG_DISABLED, nullptr);
cubebLog->SetLevel(LogLevel::Disabled);
}
} else if (strcmp(aPref, PREF_CUBEB_BACKEND) == 0) {
+ StaticMutexAutoLock lock(sMutex);
nsAutoCString value;
Preferences::GetCString(aPref, value);
if (value.IsEmpty()) {
sCubebBackendName = nullptr;
} else {
sCubebBackendName = new char[value.Length() + 1];
PodCopy(sCubebBackendName.get(), value.get(), value.Length());
sCubebBackendName[value.Length()] = 0;