Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f121362 authored by Eric Laurent's avatar Eric Laurent
Browse files

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
parent 1222bb9d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -373,6 +373,7 @@ status_t AudioPolicyService::initStreamVolume(audio_stream_type_t stream,
    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 @@ status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream,
    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 @@ status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream,
    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,