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

Commit 985d15a9 authored by nobuaki tanaka's avatar nobuaki tanaka Committed by Tomoharu Kasahara
Browse files

Apply stream volume for the correct device

During music playback via headset, if sonification stream sounds,
sonification volume is limited to music volume in computeVolume().
However if application plays sonification stream continuously,
setStreamVolumeIndex can be called before previous sonification
sound stops.
This behavior leads unexpected volume settings then
sonification volume is not limited to music volume.
This fix sets the correct device which is not filtered by
Volume::getDeviceForVolume then avoid to update incorrect device volume.

Bug: 118098429
Test: Repeat alarm during music playback from headset

Change-Id: I92f9bd070dd9d5b7b523147e6c2ca1f233a53eb4
parent efd99ec8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2277,7 +2277,7 @@ status_t AudioPolicyManager::setStreamVolumeIndex(audio_stream_type_t stream,
    status_t status = NO_ERROR;
    for (size_t i = 0; i < mOutputs.size(); i++) {
        sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
        audio_devices_t curDevice = Volume::getDeviceForVolume(desc->device());
        audio_devices_t curDevice = desc->device();
        for (int curStream = 0; curStream < AUDIO_STREAM_FOR_POLICY_CNT; curStream++) {
            if (!streamsMatchForvolume(stream, (audio_stream_type_t)curStream)) {
                continue;
@@ -2296,7 +2296,7 @@ status_t AudioPolicyManager::setStreamVolumeIndex(audio_stream_type_t stream,
            bool applyVolume;
            if (device != AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME) {
                curStreamDevice |= device;
                applyVolume = (curDevice & curStreamDevice) != 0;
                applyVolume = (Volume::getDeviceForVolume(curDevice) & curStreamDevice) != 0;
            } else {
                applyVolume = !mVolumeCurves->hasVolumeIndexForDevice(
                        stream, curStreamDevice);