mirror of
https://github.com/yurisieucuti/treble_evolution.git
synced 2024-11-28 04:44:30 +00:00
132 lines
5.0 KiB
Diff
132 lines
5.0 KiB
Diff
From 1386ffd1f821784d820b663573a712cd07331bf1 Mon Sep 17 00:00:00 2001
|
|
From: Pierre-Hugues Husson <phh@phh.me>
|
|
Date: Mon, 5 Aug 2019 18:09:50 +0200
|
|
Subject: [PATCH 02/25] Fix BT in-call on CAF devices
|
|
|
|
See https://github.com/phhusson/treble_experimentations/issues/374
|
|
|
|
In Qualcomm's BSP audio_policy_configuration.xml, one route is missing,
|
|
from primary output and telephony to BT SCO.
|
|
|
|
Add it if we detect telephony and bt sco, but no such route.
|
|
|
|
Change-Id: Ifea0f88276ec9a0811f3cb1973c4b06f2c82077b
|
|
---
|
|
.../managerdefinitions/src/Serializer.cpp | 93 +++++++++++++++++++
|
|
1 file changed, 93 insertions(+)
|
|
|
|
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
|
index 3d5c1d2e42..5ca409cfe7 100644
|
|
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
|
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
|
@@ -663,6 +663,98 @@ std::variant<status_t, RouteTraits::Element> PolicySerializer::deserialize<Route
|
|
return route;
|
|
}
|
|
|
|
+static void fixupQualcommBtScoRoute(RouteTraits::Collection& routes, DevicePortTraits::Collection& devicePorts, HwModule* ctx) {
|
|
+ // On many Qualcomm devices, there is a BT SCO Headset Mic => primary input mix
|
|
+ // But Telephony Rx => BT SCO Headset route is missing
|
|
+ // When we detect such case, add the missing route
|
|
+
|
|
+ // If we have:
|
|
+ // <route type="mix" sink="Telephony Tx" sources="voice_tx"/>
|
|
+ // <route type="mix" sink="primary input" sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
|
|
+ // <devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink" />
|
|
+ // And no <route type="mix" sink="BT SCO Headset" />
|
|
+
|
|
+ // Add:
|
|
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
|
|
+ bool foundBtScoHeadsetDevice = false;
|
|
+ for(const auto& device: devicePorts) {
|
|
+ if(device->getTagName() == "BT SCO Headset") {
|
|
+ foundBtScoHeadsetDevice = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ if(!foundBtScoHeadsetDevice) {
|
|
+ ALOGE("No BT SCO Headset device found, don't patch policy");
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ bool foundTelephony = false;
|
|
+ bool foundBtScoInput = false;
|
|
+ bool foundScoHeadsetRoute = false;
|
|
+ for(const auto& route: routes) {
|
|
+ ALOGE("Looking at route %d\n", route->getType());
|
|
+ if(route->getType() != AUDIO_ROUTE_MIX)
|
|
+ continue;
|
|
+ auto sink = route->getSink();
|
|
+ ALOGE("... With sink %s\n", sink->getTagName().c_str());
|
|
+ if(sink->getTagName() == "Telephony Tx") {
|
|
+ foundTelephony = true;
|
|
+ continue;
|
|
+ }
|
|
+ if(sink->getTagName() == "BT SCO Headset") {
|
|
+ foundScoHeadsetRoute = true;
|
|
+ break;
|
|
+ }
|
|
+ for(const auto& source: route->getSources()) {
|
|
+ ALOGE("... With source %s\n", source->getTagName().c_str());
|
|
+ if(source->getTagName() == "BT SCO Headset Mic") {
|
|
+ foundBtScoInput = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ //The route we want to add is already there
|
|
+ ALOGE("Done looking for existing routes");
|
|
+ if(foundScoHeadsetRoute)
|
|
+ return;
|
|
+
|
|
+ ALOGE("No existing route found... %d %d", foundTelephony ? 1 : 0, foundBtScoInput ? 1 : 0);
|
|
+ //We couldn't find the routes we assume are required for the function we want to add
|
|
+ if(!foundTelephony || !foundBtScoInput)
|
|
+ return;
|
|
+ ALOGE("Adding our own.");
|
|
+
|
|
+ // Add:
|
|
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
|
|
+ AudioRoute *newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
|
|
+
|
|
+ auto sink = ctx->findPortByTagName("BT SCO Headset");
|
|
+ ALOGE("Got sink %p\n", sink.get());
|
|
+ newRoute->setSink(sink);
|
|
+
|
|
+ Vector<sp<PolicyAudioPort>> sources;
|
|
+ for(const auto& sourceName: {
|
|
+ "primary output",
|
|
+ "deep_buffer",
|
|
+ "compressed_offload",
|
|
+ "Telephony Rx"
|
|
+ }) {
|
|
+ auto source = ctx->findPortByTagName(sourceName);
|
|
+ ALOGE("Got source %p\n", source.get());
|
|
+ if (source.get() != nullptr) {
|
|
+ sources.add(source);
|
|
+ source->addRoute(newRoute);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ newRoute->setSources(sources);
|
|
+
|
|
+ sink->addRoute(newRoute);
|
|
+
|
|
+ auto ret = routes.add(newRoute);
|
|
+ ALOGE("route add returned %zd", ret);
|
|
+}
|
|
+
|
|
template<>
|
|
std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<ModuleTraits>(
|
|
const xmlNode *cur, ModuleTraits::PtrSerializingCtx ctx)
|
|
@@ -710,6 +802,7 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
|
|
if (status != NO_ERROR) {
|
|
return status;
|
|
}
|
|
+ fixupQualcommBtScoRoute(routes, devicePorts, module.get());
|
|
module->setRoutes(routes);
|
|
|
|
for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
|
|
--
|
|
2.25.1
|
|
|