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

Commit 01ad3770 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "audio policy: fix BT SCO mute" into tm-qpr-dev

parents 5fc008b6 f9cccec4
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -3009,6 +3009,10 @@ status_t AudioPolicyManager::setVolumeIndexForAttributes(const audio_attributes_
    status_t status = NO_ERROR;
    IVolumeCurves &curves = getVolumeCurves(attributes);
    VolumeSource vs = toVolumeSource(group);
    // AUDIO_STREAM_BLUETOOTH_SCO is only used for volume control so we remap
    // to AUDIO_STREAM_VOICE_CALL to match with relevant playback activity
    VolumeSource activityVs = (vs == toVolumeSource(AUDIO_STREAM_BLUETOOTH_SCO, false)) ?
            toVolumeSource(AUDIO_STREAM_VOICE_CALL, false) : vs;
    product_strategy_t strategy = mEngine->getProductStrategyForAttributes(attributes);

    status = setVolumeCurveIndex(index, device, curves);
@@ -3047,7 +3051,8 @@ status_t AudioPolicyManager::setVolumeIndexForAttributes(const audio_attributes_
        if (curDevices.erase(AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
            curDevices.insert(AUDIO_DEVICE_OUT_SPEAKER);
        }
        if (!(desc->isActive(vs) || isInCall())) {

        if (!(desc->isActive(activityVs) || isInCallOrScreening())) {
            continue;
        }
        if (device != AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME &&
@@ -3081,7 +3086,7 @@ status_t AudioPolicyManager::setVolumeIndexForAttributes(const audio_attributes_
                bool isPreempted = false;
                bool isHigherPriority = productStrategy < strategy;
                for (const auto &client : activeClients) {
                    if (isHigherPriority && (client->volumeSource() != vs)) {
                    if (isHigherPriority && (client->volumeSource() != activityVs)) {
                        ALOGV("%s: Strategy=%d (\nrequester:\n"
                              " group %d, volumeGroup=%d attributes=%s)\n"
                              " higher priority source active:\n"
@@ -3094,7 +3099,7 @@ status_t AudioPolicyManager::setVolumeIndexForAttributes(const audio_attributes_
                        break;
                    }
                    // However, continue for loop to ensure no higher prio clients running on output
                    if (client->volumeSource() == vs) {
                    if (client->volumeSource() == activityVs) {
                        applyVolume = true;
                    }
                }
@@ -7499,14 +7504,18 @@ bool AudioPolicyManager::isStateInCall(int state) const {
    return is_state_in_call(state);
}

bool AudioPolicyManager::isCallAudioAccessible()
{
bool AudioPolicyManager::isCallAudioAccessible() const {
    audio_mode_t mode = mEngine->getPhoneState();
    return (mode == AUDIO_MODE_IN_CALL)
            || (mode == AUDIO_MODE_CALL_SCREEN)
            || (mode == AUDIO_MODE_CALL_REDIRECT);
}

bool AudioPolicyManager::isInCallOrScreening() const {
    audio_mode_t mode = mEngine->getPhoneState();
    return isStateInCall(mode) || mode == AUDIO_MODE_CALL_SCREEN;
}

void AudioPolicyManager::cleanUpForDevice(const sp<DeviceDescriptor>& deviceDesc)
{
    for (ssize_t i = (ssize_t)mAudioSources.size() - 1; i >= 0; i--)  {
+3 −1
Original line number Diff line number Diff line
@@ -602,7 +602,9 @@ protected:
        // true if given state represents a device in a telephony or VoIP call
        virtual bool isStateInCall(int state) const;
        // true if playback to call TX or capture from call RX is possible
        bool isCallAudioAccessible();
        bool isCallAudioAccessible() const;
        // true if device is in a telephony or VoIP call or call screening is active
        bool isInCallOrScreening() const;

        // when a device is connected, checks if an open output can be routed
        // to this device. If none is open, tries to open one of the available outputs.