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

Commit 9d482768 authored by Vlad Popa's avatar Vlad Popa
Browse files

CSD: get stream db without double attenuation

When calling compute volume from getStreamDb do not apply the double
attenuation logic. In this case it is enough to query the value returned
from the volume curves.

Flag: EXEMPT bugfix
Test: manual
Bug: 348579505
Change-Id: I4e15809c96a7c34423f31487a0bcda89dca7420e
parent 0e7f1f13
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -5891,7 +5891,8 @@ status_t AudioPolicyManager::getMasterMono(bool *mono)
float AudioPolicyManager::getStreamVolumeDB(
        audio_stream_type_t stream, int index, audio_devices_t device)
{
    return computeVolume(getVolumeCurves(stream), toVolumeSource(stream), index, {device});
    return computeVolume(getVolumeCurves(stream), toVolumeSource(stream), index,
                         {device}, /* adjustAttenuation= */false);
}

status_t AudioPolicyManager::getSurroundFormats(unsigned int *numSurroundFormats,
@@ -8069,9 +8070,15 @@ float AudioPolicyManager::computeVolume(IVolumeCurves &curves,
                                        VolumeSource volumeSource,
                                        int index,
                                        const DeviceTypeSet& deviceTypes,
                                        bool adjustAttenuation,
                                        bool computeInternalInteraction)
{
    float volumeDb = adjustDeviceAttenuationForAbsVolume(curves, volumeSource, index, deviceTypes);
    float volumeDb;
    if (adjustAttenuation) {
        volumeDb = adjustDeviceAttenuationForAbsVolume(curves, volumeSource, index, deviceTypes);
    } else {
        volumeDb = curves.volIndexToDb(Volume::getDeviceCategory(deviceTypes), index);
    }
    ALOGV("%s volume source %d, index %d,  devices %s, compute internal %b ", __func__,
          volumeSource, index, dumpDeviceTypes(deviceTypes).c_str(), computeInternalInteraction);

@@ -8092,6 +8099,7 @@ float AudioPolicyManager::computeVolume(IVolumeCurves &curves,
            mOutputs.isActive(ringVolumeSrc, 0)) {
        auto &ringCurves = getVolumeCurves(AUDIO_STREAM_RING);
        const float ringVolumeDb = computeVolume(ringCurves, ringVolumeSrc, index, deviceTypes,
                                                 adjustAttenuation,
                                                 /* computeInternalInteraction= */false);
        return ringVolumeDb - 4 > volumeDb ? ringVolumeDb - 4 : volumeDb;
    }
@@ -8110,7 +8118,7 @@ float AudioPolicyManager::computeVolume(IVolumeCurves &curves,
        int voiceVolumeIndex = voiceCurves.getVolumeIndex(deviceTypes);
        const float maxVoiceVolDb =
                computeVolume(voiceCurves, callVolumeSrc, voiceVolumeIndex, deviceTypes,
                              /* computeInternalInteraction= */ false)
                        adjustAttenuation, /* computeInternalInteraction= */false)
                + IN_CALL_EARPIECE_HEADROOM_DB;
        // FIXME: Workaround for call screening applications until a proper audio mode is defined
        // to support this scenario : Exempt the RING stream from the audio cap if the audio was
@@ -8163,6 +8171,7 @@ float AudioPolicyManager::computeVolume(IVolumeCurves &curves,
                                             musicVolumeSrc,
                                             musicCurves.getVolumeIndex(musicDevice),
                                             musicDevice,
                                              adjustAttenuation,
                                              /* computeInternalInteraction= */ false);
            float minVolDb = (musicVolDb > SONIFICATION_HEADSET_VOLUME_MIN_DB) ?
                        musicVolDb : SONIFICATION_HEADSET_VOLUME_MIN_DB;
+3 −0
Original line number Diff line number Diff line
@@ -591,6 +591,8 @@ protected:
         * @param index index to match in the volume curves for the calculation
         * @param deviceTypes devices that should be considered in the volume curves for the
         *        calculation
         * @param adjustAttenuation boolean indicating whether we should adjust the value to
         *        avoid double attenuation when controlling an avrcp device
         * @param computeInternalInteraction boolean indicating whether recursive volume computation
         *        should continue within the volume computation. Defaults to {@code true} so the
         *        volume interactions can be computed. Calls within the method should always set the
@@ -599,6 +601,7 @@ protected:
         */
        virtual float computeVolume(IVolumeCurves &curves, VolumeSource volumeSource,
                               int index, const DeviceTypeSet& deviceTypes,
                               bool adjustAttenuation = true,
                               bool computeInternalInteraction = true);

        // rescale volume index from srcStream within range of dstStream