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

Commit befb51e0 authored by Weiyin Jiang's avatar Weiyin Jiang Committed by Mingming Yin
Browse files

policy_hal: handle incall sonification without checking output refCount

Call handleIncallSonification in startSource and stopSource without
checking mRefCount to make sure ringtone mute/unmute is called for
multiple active stream.

Change-Id: I52290f9ae09dff3619ac3a36c8969da6c07853ec
CRs-Fixed: 972582
parent 692a5cc9
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 * Not a contribution.
 *
 * Copyright (C) 2009 The Android Open Source Project
@@ -397,6 +397,7 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d
    ALOGW("setDeviceConnectionState() invalid device: %x", device);
    return BAD_VALUE;
}

// This function checks for the parameters which can be offloaded.
// This can be enhanced depending on the capability of the DSP and policy
// of the system.
@@ -568,6 +569,7 @@ bool AudioPolicyManagerCustom::isOffloadSupported(const audio_offload_info_t& of
    ALOGV("isOffloadSupported() profile %sfound", profile != 0 ? "" : "NOT ");
    return (profile != 0);
}

audio_devices_t AudioPolicyManagerCustom::getNewOutputDevice(const sp<AudioOutputDescriptor>& outputDesc,
                                                       bool fromCache)
{
@@ -633,6 +635,7 @@ audio_devices_t AudioPolicyManagerCustom::getNewOutputDevice(const sp<AudioOutpu
    ALOGV("getNewOutputDevice() selected device %x", device);
    return device;
}

void AudioPolicyManagerCustom::setPhoneState(audio_mode_t state)
{
    ALOGV("setPhoneState() state %d", state);
@@ -968,7 +971,7 @@ status_t AudioPolicyManagerCustom::stopSource(sp<AudioOutputDescriptor> outputDe
    handleEventForBeacon(stream == AUDIO_STREAM_TTS ? STOPPING_BEACON : STOPPING_OUTPUT);

    // handle special case for sonification while in call
    if (isInCall() && (outputDesc->mRefCount[stream] == 1)) {
    if (isInCall()) {
        if (outputDesc->isDuplicated()) {
            handleIncallSonification(stream, false, false, outputDesc->subOutput1()->mIoHandle);
            handleIncallSonification(stream, false, false, outputDesc->subOutput2()->mIoHandle);
@@ -1023,6 +1026,7 @@ status_t AudioPolicyManagerCustom::stopSource(sp<AudioOutputDescriptor> outputDe
        return INVALID_OPERATION;
    }
}

status_t AudioPolicyManagerCustom::startSource(sp<AudioOutputDescriptor> outputDesc,
                                             audio_stream_type_t stream,
                                             audio_devices_t device,
@@ -1115,6 +1119,7 @@ status_t AudioPolicyManagerCustom::startSource(sp<AudioOutputDescriptor> outputD
    }
    return NO_ERROR;
}

void AudioPolicyManagerCustom::handleIncallSonification(audio_stream_type_t stream,
                                                      bool starting, bool stateChange,
                                                      audio_io_handle_t output)
@@ -1167,6 +1172,7 @@ void AudioPolicyManagerCustom::handleIncallSonification(audio_stream_type_t stre
        }
    }
}

void AudioPolicyManagerCustom::handleNotificationRoutingForStream(audio_stream_type_t stream) {
    switch(stream) {
    case AUDIO_STREAM_MUSIC:
@@ -1177,6 +1183,7 @@ void AudioPolicyManagerCustom::handleNotificationRoutingForStream(audio_stream_t
        break;
    }
}

status_t AudioPolicyManagerCustom::checkAndSetVolume(audio_stream_type_t stream,
                                                   int index,
                                                   const sp<AudioOutputDescriptor>& outputDesc,
@@ -1246,6 +1253,7 @@ status_t AudioPolicyManagerCustom::checkAndSetVolume(audio_stream_type_t stream,

    return NO_ERROR;
}

bool AudioPolicyManagerCustom::isDirectOutput(audio_io_handle_t output) {
    for (size_t i = 0; i < mOutputs.size(); i++) {
        audio_io_handle_t curOutput = mOutputs.keyAt(i);
@@ -1799,6 +1807,7 @@ status_t AudioPolicyManagerCustom::getInputForAttr(const audio_attributes_t *att
                                               selectedDeviceId,
                                               inputType);
}

status_t AudioPolicyManagerCustom::startInput(audio_io_handle_t input,
                                        audio_session_t session)
{
@@ -1922,6 +1931,7 @@ status_t AudioPolicyManagerCustom::startInput(audio_io_handle_t input,
#endif
    return NO_ERROR;
}

status_t AudioPolicyManagerCustom::stopInput(audio_io_handle_t input,
                                       audio_session_t session)
{