130 lines
5.0 KiB
Diff
130 lines
5.0 KiB
Diff
From f303633bdac9176d45ca8a9073f2f9850406ebf8 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 09/17] 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 | 91 +++++++++++++++++++
|
|
1 file changed, 91 insertions(+)
|
|
|
|
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
|
index 9f2bdc4b3..9c7e5c49d 100644
|
|
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
|
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
|
@@ -607,6 +607,96 @@ Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSer
|
|
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() == String8("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() == String8("Telephony Tx")) {
|
|
+ foundTelephony = true;
|
|
+ continue;
|
|
+ }
|
|
+ if(sink->getTagName() == String8("BT SCO Headset")) {
|
|
+ foundScoHeadsetRoute = true;
|
|
+ break;
|
|
+ }
|
|
+ for(const auto& source: route->getSources()) {
|
|
+ ALOGE("... With source %s\n", source->getTagName().c_str());
|
|
+ if(source->getTagName() == String8("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(String8("BT SCO Headset"));
|
|
+ ALOGE("Got sink %p\n", sink.get());
|
|
+ newRoute->setSink(sink);
|
|
+
|
|
+ AudioPortVector sources;
|
|
+ for(const auto& sourceName: {
|
|
+ "primary output",
|
|
+ "deep_buffer",
|
|
+ "compressed_offload",
|
|
+ "Telephony Rx"
|
|
+ }) {
|
|
+ auto source = ctx->findPortByTagName(String8(sourceName));
|
|
+ ALOGE("Got source %p\n", source.get());
|
|
+ sources.add(source);
|
|
+ source->addRoute(newRoute);
|
|
+ }
|
|
+
|
|
+ newRoute->setSources(sources);
|
|
+
|
|
+ sink->addRoute(newRoute);
|
|
+
|
|
+ auto ret = routes.add(newRoute);
|
|
+ ALOGE("route add returned %zd", ret);
|
|
+}
|
|
+
|
|
Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrSerializingCtx ctx)
|
|
{
|
|
std::string name = getXmlAttribute(cur, Attributes::name);
|
|
@@ -646,6 +736,7 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
|
|
if (status != NO_ERROR) {
|
|
return Status::fromStatusT(status);
|
|
}
|
|
+ fixupQualcommBtScoRoute(routes, devicePorts, module.get());
|
|
module->setRoutes(routes);
|
|
|
|
for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
|
|
--
|
|
2.25.1
|
|
|