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

Commit 4a6853d4 authored by Eric Laurent's avatar Eric Laurent Committed by Automerger Merge Worker
Browse files

Merge "audio: ble: modify ble volume in voicecall/voip" into main am: 027e8a38

parents 3b704f54 027e8a38
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -3584,7 +3584,9 @@ status_t AudioPolicyManager::setVolumeIndexForAttributes(const audio_attributes_
        if (isVolumeConsistentForCalls(vs, {mCallRxSourceClient->sinkDevice()->type()},
                isVoiceVolSrc, isBtScoVolSrc, __func__)
                && (isVoiceVolSrc || isBtScoVolSrc)) {
            setVoiceVolume(index, curves, isVoiceVolSrc, 0);
            bool voiceVolumeManagedByHost = isVoiceVolSrc &&
                    !audio_is_ble_out_device(mCallRxSourceClient->sinkDevice()->type());
            setVoiceVolume(index, curves, voiceVolumeManagedByHost, 0);
        }
    }

@@ -8257,9 +8259,10 @@ status_t AudioPolicyManager::checkAndSetVolume(IVolumeCurves &curves,

    float volumeDb = computeVolume(curves, volumeSource, index, deviceTypes);
    if (outputDesc->isFixedVolume(deviceTypes) ||
            // Force VoIP volume to max for bluetooth SCO device except if muted
            // Force VoIP volume to max for bluetooth SCO/BLE device except if muted
            (index != 0 && (isVoiceVolSrc || isBtScoVolSrc) &&
                    isSingleDeviceType(deviceTypes, audio_is_bluetooth_out_sco_device))) {
                    (isSingleDeviceType(deviceTypes, audio_is_bluetooth_out_sco_device)
                    || isSingleDeviceType(deviceTypes, audio_is_ble_out_device)))) {
        volumeDb = 0.0f;
    }
    const bool muted = (index == 0) && (volumeDb != 0.0f);
@@ -8267,17 +8270,19 @@ status_t AudioPolicyManager::checkAndSetVolume(IVolumeCurves &curves,
            deviceTypes, delayMs, force, isVoiceVolSrc);

    if (outputDesc == mPrimaryOutput && (isVoiceVolSrc || isBtScoVolSrc)) {
        setVoiceVolume(index, curves, isVoiceVolSrc, delayMs);
        bool voiceVolumeManagedByHost = isVoiceVolSrc &&
                !isSingleDeviceType(deviceTypes, audio_is_ble_out_device);
        setVoiceVolume(index, curves, voiceVolumeManagedByHost, delayMs);
    }
    return NO_ERROR;
}

void AudioPolicyManager::setVoiceVolume(
        int index, IVolumeCurves &curves, bool isVoiceVolSrc, int delayMs) {
        int index, IVolumeCurves &curves, bool voiceVolumeManagedByHost, int delayMs) {
    float voiceVolume;
    // Force voice volume to max or mute for Bluetooth SCO as other attenuations are managed
    // Force voice volume to max or mute for Bluetooth SCO/BLE as other attenuations are managed
    // by the headset
    if (isVoiceVolSrc) {
    if (voiceVolumeManagedByHost) {
        voiceVolume = (float)index/(float)curves.getVolumeIndexMax();
    } else {
        voiceVolume = index == 0 ? 0.0 : 1.0;