107 lines
5.2 KiB
Diff
107 lines
5.2 KiB
Diff
From 8100be359a6806e589c0b8846e34daac00a450ed Mon Sep 17 00:00:00 2001
|
|
From: Peter Cai <peter@typeblog.net>
|
|
Date: Tue, 19 Oct 2021 21:16:55 -0400
|
|
Subject: [PATCH 1/2] APM: Restore R and Q behavior respectively for telephony
|
|
audio
|
|
|
|
This conditionally reverts part of 51c9cc (S) and afd4ce (R) when the
|
|
VNDK version is equal to or before R and Q respectively.
|
|
|
|
On R, commit afd4ce made it so that both HW and SW bridging go through
|
|
`createAudioPatch()`, which is broken on some devices such as on MTK Q
|
|
vendor, because their HAL do not support HW patching via the newer
|
|
`createAudioPatch()` method. Instead, the patching on Q was done through
|
|
`setOutputDevices()`.
|
|
|
|
On S, commit 51c9cc refactored the related code again such that HW
|
|
bridging for the Rx direction is essentially removed, replaced with SW
|
|
bridging through `startAudioSource()`. This is, again, broken on MTK R
|
|
vendor devices.
|
|
|
|
Both of these commits rely on assumptions that are not tested through
|
|
VTS and just presumed to be true. Although we can blame MTK for not
|
|
supporting all the possible cases in their HAL, it will not fix
|
|
anything, and really frameworks code should not depend on such untested
|
|
assumptions.
|
|
|
|
To work around said issues, we restore old behavior from R and Q relying
|
|
on the value of `ro.vndk.version`.
|
|
|
|
Change-Id: I56d36d2aef4319935cb88a3e4771b23c6d5b2145
|
|
---
|
|
.../managerdefault/AudioPolicyManager.cpp | 31 ++++++++++++++++---
|
|
.../managerdefault/AudioPolicyManager.h | 1 +
|
|
2 files changed, 28 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
|
index e334532ebc..5a15e235e0 100644
|
|
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
|
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
|
@@ -601,6 +601,11 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
|
|
rxDevices.itemAt(0)->toString().c_str(), txSourceDevice->toString().c_str());
|
|
|
|
disconnectTelephonyRxAudioSource();
|
|
+ // release existing RX patch if any
|
|
+ if (mCallRxPatch != 0) {
|
|
+ releaseAudioPatchInternal(mCallRxPatch->getHandle());
|
|
+ mCallRxPatch.clear();
|
|
+ }
|
|
// release TX patch if any
|
|
if (mCallTxPatch != 0) {
|
|
releaseAudioPatchInternal(mCallTxPatch->getHandle());
|
|
@@ -629,9 +634,20 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
|
|
ALOGE("%s() no telephony Tx and/or RX device", __func__);
|
|
return INVALID_OPERATION;
|
|
}
|
|
- // createAudioPatchInternal now supports both HW / SW bridging
|
|
- createRxPatch = true;
|
|
- createTxPatch = true;
|
|
+ if (property_get_int32("ro.vndk.version", 31) >= 30) {
|
|
+ // createAudioPatchInternal now supports both HW / SW bridging
|
|
+ createRxPatch = true;
|
|
+ createTxPatch = true;
|
|
+ } else {
|
|
+ // pre-R behavior: some devices before VNDK 30 do not support createAudioPatch correctly
|
|
+ // for HW bridging even though they declare support for it
|
|
+ // do not create a patch (aka Sw Bridging) if Primary HW module has declared supporting a
|
|
+ // route between telephony RX to Sink device and Source device to telephony TX
|
|
+ ALOGI("%s() Using pre-R behavior for createRxPatch and createTxPatch", __func__);
|
|
+ const auto &primaryModule = telephonyRxModule;
|
|
+ createRxPatch = !primaryModule->supportsPatch(rxSourceDevice, rxDevices.itemAt(0));
|
|
+ createTxPatch = !primaryModule->supportsPatch(txSourceDevice, txSinkDevice);
|
|
+ }
|
|
} else {
|
|
// If the RX device is on the primary HW module, then use legacy routing method for
|
|
// voice calls via setOutputDevice() on primary output.
|
|
@@ -648,7 +664,14 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
|
|
if (!createRxPatch) {
|
|
muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
|
|
} else { // create RX path audio patch
|
|
- connectTelephonyRxAudioSource();
|
|
+ if (property_get_int32("ro.vndk.version", 31) >= 31) {
|
|
+ connectTelephonyRxAudioSource();
|
|
+ } else {
|
|
+ // pre-S behavior: some devices do not support SW bridging correctly when HW bridge is
|
|
+ // available through createAudioPatch(); startAudioSource() forces SW bridging.
|
|
+ ALOGI("%s() Using pre-S behavior to create HW Rx patch", __func__);
|
|
+ mCallRxPatch = createTelephonyPatch(true /*isRx*/, rxDevices.itemAt(0), delayMs);
|
|
+ }
|
|
// 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
|
|
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
|
|
index 967aa10441..a1e875f559 100644
|
|
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
|
|
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
|
|
@@ -839,6 +839,7 @@ protected:
|
|
SoundTriggerSessionCollection mSoundTriggerSessions;
|
|
|
|
sp<AudioPatch> mCallTxPatch;
|
|
+ sp<AudioPatch> mCallRxPatch;
|
|
|
|
HwAudioOutputCollection mHwOutputs;
|
|
SourceClientCollection mAudioSources;
|
|
--
|
|
2.36.1
|
|
|