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

Commit 1a8b45f4 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: workaround for call signalling tones with hearing aids

When an hearing aid is connected, Telecom will specify stream
BLUETOOTH_SCO whe playing tones with the ToneGenerator.
This causes a mismatch in AudioPolicyManager::checkAndSetVolume()
resulting in muted tones.
Telecom should never use stream BLUETOOTH SCO when creating a
ToneGenerator: this stream type is reserved for volume control.

This CL is a workaround to apply a correct volume until Telecom
fixes this behavior.

Bug: 192520750
Test: repro steps in the bug.
Change-Id: Ie799526aad176563e07faeded83f0495e3b758f5
parent 87b781f8
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -5539,6 +5539,7 @@ status_t AudioPolicyManager::initialize() {
        return status;
    }

    mEngine->updateDeviceSelectionCache();
    mCommunnicationStrategy = mEngine->getProductStrategyForAttributes(
        mEngine->getAttributesForStreamType(AUDIO_STREAM_VOICE_CALL));

@@ -6432,6 +6433,18 @@ bool AudioPolicyManager::isScoRequestedForComm() const {
    return false;
}

bool AudioPolicyManager::isHearingAidUsedForComm() const {
    DeviceVector devices = mEngine->getOutputDevicesForStream(AUDIO_STREAM_VOICE_CALL,
                                                       true /*fromCache*/);
    for (const auto &device : devices) {
        if (device->type() == AUDIO_DEVICE_OUT_HEARING_AID) {
            return true;
        }
    }
    return false;
}


void AudioPolicyManager::checkA2dpSuspend()
{
    audio_io_handle_t a2dpOutput = mOutputs.getA2dpOutput();
@@ -7229,11 +7242,13 @@ status_t AudioPolicyManager::checkAndSetVolume(IVolumeCurves &curves,
    bool isBtScoVolSrc = (volumeSource != VOLUME_SOURCE_NONE) && (btScoVolSrc == volumeSource);

    bool isScoRequested = isScoRequestedForComm();
    bool isHAUsed = isHearingAidUsedForComm();

    // do not change in call volume if bluetooth is connected and vice versa
    // if sco and call follow same curves, bypass forceUseForComm
    if ((callVolSrc != btScoVolSrc) &&
            ((isVoiceVolSrc && isScoRequested) ||
             (isBtScoVolSrc && !isScoRequested))) {
             (isBtScoVolSrc && !(isScoRequested || isHAUsed)))) {
        ALOGV("%s cannot set volume group %d volume when is%srequested for comm", __func__,
             volumeSource, isScoRequested ? " " : " not ");
        // Do not return an error here as AudioService will always set both voice call
+2 −0
Original line number Diff line number Diff line
@@ -1189,6 +1189,8 @@ private:

        bool isScoRequestedForComm() const;

        bool isHearingAidUsedForComm() const;

        bool areAllActiveTracksRerouted(const sp<SwAudioOutputDescriptor>& output);

        /**