audio policy: acquire lock for volume functions
Acquire the AudioPolicyService mutex when executing
setStreamVolumeIndex() and getStreamVolumeIndex().
These functions have become more complex and iterate on the
list of opened outputs and it is safer to acquire the
AudioPolicyService mutex to avoid concurrency with other
functions.
Bug 6626532.
Change-Id: Ifdcbbbf13338fd9a59f694d43faa7ade143f94bf
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 0d13970..c32fc6b 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -373,6 +373,7 @@
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
+ Mutex::Autolock _l(mLock);
mpAudioPolicy->init_stream_volume(mpAudioPolicy, stream, indexMin, indexMax);
return NO_ERROR;
}
@@ -390,7 +391,7 @@
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
-
+ Mutex::Autolock _l(mLock);
if (mpAudioPolicy->set_stream_volume_index_for_device) {
return mpAudioPolicy->set_stream_volume_index_for_device(mpAudioPolicy,
stream,
@@ -411,6 +412,7 @@
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
+ Mutex::Autolock _l(mLock);
if (mpAudioPolicy->get_stream_volume_index_for_device) {
return mpAudioPolicy->get_stream_volume_index_for_device(mpAudioPolicy,
stream,