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

Commit f54d5846 authored by Vlad Popa's avatar Vlad Popa Committed by Android (Google) Code Review
Browse files

Merge "CSD: get stream db without double attenuation" into main

parents cd5fe6b0 9d482768
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -6014,7 +6014,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,
@@ -8192,9 +8193,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);

@@ -8215,6 +8222,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;
    }
@@ -8233,7 +8241,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
@@ -8286,6 +8294,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
@@ -590,6 +590,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
@@ -598,6 +600,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