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

Commit 76816eea authored by Yogesh Sadhu's avatar Yogesh Sadhu Committed by Arne Coucheron
Browse files

frameworks/base: AudioPolicyManager fixes

Change-Id: I12c8ec98191d7a9d6db2a043961bc1c479cb100d
CRs-Fixed: 269879
parent 997e1773
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -264,7 +264,9 @@ void AudioPolicyManagerBase::setPhoneState(int state)
    // store previous phone state for management of sonification strategy below
    int oldState = mPhoneState;
    mPhoneState = state;
    bool force = false;
    // force routing command to audio hardware when starting call
    // even if no device change is needed
    bool force = (mPhoneState == AudioSystem::MODE_IN_CALL);

    // are we entering or starting a call
    if (!isStateInCall(oldState) && isStateInCall(state)) {
@@ -298,6 +300,7 @@ void AudioPolicyManagerBase::setPhoneState(int state)
    // even if no device change is needed
    if (isStateInCall(oldState) && newDevice == 0) {
        newDevice = hwOutputDesc->device();
        force = true;
    }

    // when changing from ring tone to in call mode, mute the ringing tone
@@ -699,13 +702,13 @@ audio_io_handle_t AudioPolicyManagerBase::getInput(int inputSource,
    // adapt channel selection to input source
    switch(inputSource) {
    case AUDIO_SOURCE_VOICE_UPLINK:
        channels = AudioSystem::CHANNEL_IN_VOICE_UPLINK;
        channels |= AudioSystem::CHANNEL_IN_VOICE_UPLINK;
        break;
    case AUDIO_SOURCE_VOICE_DOWNLINK:
        channels = AudioSystem::CHANNEL_IN_VOICE_DNLINK;
        channels |= AudioSystem::CHANNEL_IN_VOICE_DNLINK;
        break;
    case AUDIO_SOURCE_VOICE_CALL:
        channels = (AudioSystem::CHANNEL_IN_VOICE_UPLINK | AudioSystem::CHANNEL_IN_VOICE_DNLINK);
        channels |= (AudioSystem::CHANNEL_IN_VOICE_UPLINK | AudioSystem::CHANNEL_IN_VOICE_DNLINK);
        break;
    default:
        break;
@@ -1729,8 +1732,13 @@ uint32_t AudioPolicyManagerBase::getDeviceForStrategy(routing_strategy strategy,

        // device is DEVICE_OUT_SPEAKER if we come from case STRATEGY_SONIFICATION, 0 otherwise
        device |= device2;
        if (device == 0) {
            LOGE("getDeviceForStrategy() speaker device not found");
        // Do not play media stream if in call and the requested device would change the hardware
        // output routing
        if (mPhoneState == AudioSystem::MODE_IN_CALL &&
            !AudioSystem::isA2dpDevice((AudioSystem::audio_devices)device) &&
            device != getDeviceForStrategy(STRATEGY_PHONE)) {
            device = 0;
            LOGV("getDeviceForStrategy() incompatible media and phone devices");
        }
        } break;

@@ -1965,7 +1973,7 @@ status_t AudioPolicyManagerBase::checkAndSetVolume(int stream, int index, audio_
#ifdef HAVE_FM_RADIO
            (stream == AudioSystem::FM) ||
#endif
            force) {
            (stream == AudioSystem::VOICE_CALL) || force) {
        mOutputs.valueFor(output)->mCurVolume[stream] = volume;
        LOGV("setStreamVolume() for output %d stream %d, volume %f, delay %d", output, stream, volume, delayMs);
        if (stream == AudioSystem::VOICE_CALL ||