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

Commit a536eb3e authored by Vlad Popa's avatar Vlad Popa
Browse files

Improve robustness when deleting abs volume device

Flag: com.android.media.audio.abs_volume_index_fix
Test: manual
Bug: 350103953
Change-Id: I9673b05aac488bd43803e5c88059ef71eaefb1ea
parent a8e0b582
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -3508,6 +3508,11 @@ status_t AudioPolicyManager::setDeviceAbsoluteVolumeEnabled(audio_devices_t devi
                                                            bool enabled,
                                                            audio_stream_type_t streamToDriveAbs)
{
    if (!enabled) {
        mAbsoluteVolumeDrivingStreams.erase(deviceType);
        return NO_ERROR;
    }

    audio_attributes_t attributesToDriveAbs = mEngine->getAttributesForStreamType(streamToDriveAbs);
    if (attributesToDriveAbs == AUDIO_ATTRIBUTES_INITIALIZER) {
        ALOGW("%s: no attributes for stream %s, bailing out", __func__,
@@ -3515,12 +3520,7 @@ status_t AudioPolicyManager::setDeviceAbsoluteVolumeEnabled(audio_devices_t devi
        return BAD_VALUE;
    }

    if (enabled) {
    mAbsoluteVolumeDrivingStreams[deviceType] = attributesToDriveAbs;
    } else {
        mAbsoluteVolumeDrivingStreams.erase(deviceType);
    }

    return NO_ERROR;
}