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

Commit fc5ee4b4 authored by Narsinga Rao Chella's avatar Narsinga Rao Chella Committed by Steve Kondik
Browse files

audiopolicy: fix for voice call to work on USB headset during concurrency

When an input stream is active on USB headset and if a voice call
is received, the proxy_open() for voice call fails and the screen freezes.
All active inputs must be closed before opening input stream for
voice call and also all new requests to open input stream must be
blocked.

Change-Id: I3fb0d482a77495ff6fe9fcdc8a1f8915ade52c9a
CRs-fixed: 876993
parent bdd042dd
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -800,6 +800,14 @@ void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs
        // request to reuse existing output stream if one is already opened to reach the TX
        // path output device
        if (output != AUDIO_IO_HANDLE_NONE) {
            // close active input (if any) before opening new input
            audio_io_handle_t activeInput = getActiveInput();
            if (activeInput != 0) {
                ALOGV("updateCallRouting() close active input before opening new input");
                sp<AudioInputDescriptor> activeDesc = mInputs.valueFor(activeInput);
                stopInput(activeInput, activeDesc->mSessions.itemAt(0));
                releaseInput(activeInput, activeDesc->mSessions.itemAt(0));
            }
            sp<AudioOutputDescriptor> outputDesc = mOutputs.valueFor(output);
            ALOG_ASSERT(!outputDesc->isDuplicated(),
                        "updateCallRouting() RX device output is duplicated");
@@ -2252,6 +2260,12 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr,
            ALOGW("getInputForAttr() could not find device for source %d", inputSource);
            return BAD_VALUE;
        }
        // block request to open input on USB during voice call
        if((AUDIO_MODE_IN_CALL == mPhoneState) &&
            (device == AUDIO_DEVICE_IN_USB_DEVICE)) {
            ALOGV("getInputForAttr(): blocking the request to open input on USB device");
            return BAD_VALUE;
        }
        if (policyMix != NULL) {
            address = policyMix->mRegistrationId;
            if (policyMix->mMixType == MIX_TYPE_RECORDERS) {