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

Commit 29e6cecd authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: do not prevent routing to A2DP when suspended.

Allow A2DP sink selection even if A2DP is suspended.
It is not because use of A2DP is temporarily disabled by SCO
selection that the policy rule routing a given use case
to A2DP should be altered. The source will be routed to A2DP
but it will remain silent until suspend condition is cleared
which is the purpose of suspend mode.

Also make sure that accessibility prompts are audible while in call
by forcing stream type to STREAM_VOICE_CALL.
Fix inconsistent logic between AudioTrack::setStreamTypeFromAttributes()
and AudioPolicyManager::getStrategyForAttr()

Bug: 18095151.
Change-Id: I1c75dd8288ed3dd494eb942060eac9c9660dca50
parent 88ec9e99
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2149,6 +2149,11 @@ void AudioTrack::setStreamTypeFromAttributes(audio_attributes_t& aa) {
            mStreamType = AUDIO_STREAM_ALARM;
            break;
        }
        audio_mode_t phoneState = AudioSystem::getPhoneState();
        if (phoneState == AUDIO_MODE_IN_CALL || phoneState == AUDIO_MODE_IN_COMMUNICATION) {
            mStreamType = AUDIO_STREAM_VOICE_CALL;
            break;
        }
    }    /// FALL THROUGH
    case AUDIO_USAGE_MEDIA:
    case AUDIO_USAGE_GAME:
+12 −4
Original line number Diff line number Diff line
@@ -3983,9 +3983,17 @@ uint32_t AudioPolicyManager::getStrategyForAttr(const audio_attributes_t *attr)

    // usage to strategy mapping
    switch (attr->usage) {
    case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY:
        if (isStreamActive(AUDIO_STREAM_RING) || isStreamActive(AUDIO_STREAM_ALARM)) {
            return (uint32_t) STRATEGY_SONIFICATION;
        }
        if (isInCall()) {
            return (uint32_t) STRATEGY_PHONE;
        }
        // FALL THROUGH

    case AUDIO_USAGE_MEDIA:
    case AUDIO_USAGE_GAME:
    case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY:
    case AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
    case AUDIO_USAGE_ASSISTANCE_SONIFICATION:
        return (uint32_t) STRATEGY_MEDIA;
@@ -4185,7 +4193,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
            // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP
            if (!isInCall() &&
                    (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
                    (getA2dpOutput() != 0) && !mA2dpSuspended) {
                    (getA2dpOutput() != 0)) {
                device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
                if (device) break;
                device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
@@ -4220,7 +4228,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
            // A2DP speaker when forcing to speaker output
            if (!isInCall() &&
                    (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
                    (getA2dpOutput() != 0) && !mA2dpSuspended) {
                    (getA2dpOutput() != 0)) {
                device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
                if (device) break;
            }
@@ -4282,7 +4290,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
        }
        if ((device2 == AUDIO_DEVICE_NONE) &&
                (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
                (getA2dpOutput() != 0) && !mA2dpSuspended) {
                (getA2dpOutput() != 0)) {
            device2 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
            if (device2 == AUDIO_DEVICE_NONE) {
                device2 = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;