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

--HG--
extra : rebase_source : 171106da4e662c3514b80b7d83bc0637afc2caab
This commit is contained in:
Paul Adenot 2018-04-17 16:45:33 +02:00
Родитель dbd89b9ce3
Коммит 2062de82ff
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -200,17 +200,17 @@ void PrefChanged(const char* aPref, void* aClosure)
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
@ -234,6 +234,7 @@ void PrefChanged(const char* aPref, void* aClosure)
cubebLog->SetLevel(LogLevel::Disabled);
}
} else if (strcmp(aPref, PREF_CUBEB_BACKEND) == 0) {
StaticMutexAutoLock lock(sMutex);
nsAutoCString value;
Preferences::GetCString(aPref, value);
if (value.IsEmpty()) {