79 lines
4.0 KiB
Diff
79 lines
4.0 KiB
Diff
From 7bb3de067cec0c8c3bd5341bf9ad42b808fefd39 Mon Sep 17 00:00:00 2001
|
|
From: Peter Cai <peter@typeblog.net>
|
|
Date: Wed, 14 Apr 2021 11:09:12 +0800
|
|
Subject: [PATCH 40/40] APM: Fall back to legacy voice call routing if creating
|
|
audio patch failed
|
|
|
|
* On some MT6771 Q vendor devices, in-call audio is broken due to APM
|
|
failing to create an HW audio patch for RX / TX devices.
|
|
|
|
> 03-28 11:56:42.300 1345 1345 W DeviceHAL: Error from HAL Device in
|
|
function create_audio_patch: Function not implemented
|
|
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
|
|
createAudioPatchInternal patch panel could not connect device patch,
|
|
error -38
|
|
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
|
|
createTelephonyPatch() error -38 creating RX audio patch
|
|
|
|
* Our previous attempt at fixing this by falling back to SW bridging was
|
|
wrong, because SW bridging requires a corresponding audio policy
|
|
configuration that includes said SW bridges, which is not the case on
|
|
these devices.
|
|
|
|
* The sole reason why this was broken at all is that the new R behavior
|
|
tries to use the newer `createAudioPatch` interface of the audio HAL,
|
|
which is broken on these devices for telephony inputs and outputs,
|
|
even though the HAL claims to support it.
|
|
|
|
* Let's fall back to pre-R behavior (i.e. using the legacy
|
|
setOutputDevices() interface) whenever the new method fails. The
|
|
legacy method takes care of TX (Mic input) as well, so we don't need
|
|
to create the TX patch either.
|
|
---
|
|
.../managerdefault/AudioPolicyManager.cpp | 23 +++++++++++++++----
|
|
1 file changed, 18 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
|
index 63dcd538b1..124c6ca6ef 100644
|
|
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
|
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
|
@@ -575,17 +575,30 @@ uint32_t AudioPolicyManager::updateCallRouting(const DeviceVector &rxDevices, ui
|
|
createTxPatch = !(availablePrimaryModuleInputDevices().contains(txSourceDevice)) &&
|
|
(txSinkDevice != 0);
|
|
}
|
|
- // Use legacy routing method for voice calls via setOutputDevice() on primary output.
|
|
- // Otherwise, create two audio patches for TX and RX path.
|
|
- if (!createRxPatch) {
|
|
- muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
|
|
- } else { // create RX path audio patch
|
|
+ if (createRxPatch) { // create RX path audio patch
|
|
mCallRxPatch = createTelephonyPatch(true /*isRx*/, rxDevices.itemAt(0), delayMs);
|
|
|
|
+ if (mCallRxPatch == nullptr) {
|
|
+ // Fall back to legacy routing for voice calls if the new patching method
|
|
+ // failed. setOutputDevice() will take care of TX in this case, so don't
|
|
+ // create the TX patch either.
|
|
+ // This is seen on some MT6771 devices on Q vendor, where the HAL claims
|
|
+ // support for HW patch between telephony inputs and outputs, but fails
|
|
+ // to create one when called with the createAudioPatch() method. SW audio
|
|
+ // bridges are also broken on them due to improperly configured audio policy.
|
|
+ ALOGW("Failed to create RX path audio patch, falling back to pre-R behavior");
|
|
+ createRxPatch = false;
|
|
+ createTxPatch = false;
|
|
+ }
|
|
+
|
|
// If the TX device is on the primary HW module but RX device is
|
|
// on other HW module, SinkMetaData of telephony input should handle it
|
|
// assuming the device uses audio HAL V5.0 and above
|
|
}
|
|
+ // Use legacy routing method for voice calls via setOutputDevice() on primary output.
|
|
+ if (!createRxPatch) {
|
|
+ muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
|
|
+ }
|
|
if (createTxPatch) { // create TX path audio patch
|
|
// terminate active capture if on the same HW module as the call TX source device
|
|
// FIXME: would be better to refine to only inputs whose profile connects to the
|
|
--
|
|
2.25.1
|
|
|