From c40106ff12387a155eed450726828c0a7e1f002c Mon Sep 17 00:00:00 2001 From: Karthik Reddy Katta Date: Wed, 9 Sep 2015 19:56:52 +0530 Subject: 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 --- services/audiopolicy/managerdefault/AudioPolicyManager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'services/audiopolicy/managerdefault') diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index 4d9dbfe..8618b08 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -351,6 +351,14 @@ void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs AUDIO_OUTPUT_FLAG_NONE, AUDIO_FORMAT_INVALID); if (output != AUDIO_IO_HANDLE_NONE) { + // close active input (if any) before opening new input + audio_io_handle_t activeInput = mInputs.getActiveInput(); + if (activeInput != 0) { + ALOGV("updateCallRouting() close active input before opening new input"); + sp activeDesc = mInputs.valueFor(activeInput); + stopInput(activeInput, activeDesc->mSessions.itemAt(0)); + releaseInput(activeInput, activeDesc->mSessions.itemAt(0)); + } sp outputDesc = mOutputs.valueFor(output); ALOG_ASSERT(!outputDesc->isDuplicated(), "updateCallRouting() RX device output is duplicated"); @@ -1336,6 +1344,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 == mEngine->getPhoneState()) && + (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) { -- cgit v1.1