1
0
mirror of https://github.com/ponces/treble_aosp.git synced 2024-11-22 05:26:14 +00:00
treble_aosp/patches/trebledroid/platform_frameworks_av/0011-FIH-devices-Fix-Earpiece-audio-output.patch
2024-06-18 10:56:01 +01:00

88 lines
3.8 KiB
Diff

From eccabf3dc6744a39652b7b9aa9d900286e8edc54 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 24 Apr 2018 00:14:28 +0200
Subject: [PATCH 11/24] FIH devices: Fix "Earpiece" audio output
On some FIH devices (confirmed on Razer, and probably on Aquos SS2),
Earpiece is not listed in attachedDevices, and devicePort's profile
mentions it is AUDIO_CHANNEL_IN_MONO, instead of AUDIO_CHANNEL_OUT_MONO.
Detect such cases (output device, but got only AUDIO_CHANNEL_IN_MONO),
and fix both channelMasks and attachedDevices
Change-Id: I4a88ba6d34d0fcd346eeea2ca903772f0271040a
---
.../managerdefinitions/src/Serializer.cpp | 27 ++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 21d3282134..6ee076660b 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -416,23 +416,32 @@ std::variant<status_t, AudioGainTraits::Element> PolicySerializer::deserialize<A
}
}
+static bool fixedEarpieceChannels = false;
template<>
std::variant<status_t, AudioProfileTraits::Element>
PolicySerializer::deserialize<AudioProfileTraits>(
- const xmlNode *cur, AudioProfileTraits::PtrSerializingCtx /*serializingContext*/)
+ const xmlNode *cur, AudioProfileTraits::PtrSerializingCtx serializingContext)
{
using Attributes = AudioProfileTraits::Attributes;
+ bool isOutput = serializingContext != nullptr;
std::string samplingRates = getXmlAttribute(cur, Attributes::samplingRates);
std::string format = getXmlAttribute(cur, Attributes::format);
std::string channels = getXmlAttribute(cur, Attributes::channelMasks);
+ ChannelTraits::Collection channelsMask = channelMasksFromString(channels, mChannelMasksSeparator.c_str());
+
+ //Some Foxconn devices have wrong earpiece channel mask, leading to no channel mask
+ if(channelsMask.size() == 1 && *channelsMask.begin() == AUDIO_CHANNEL_IN_MONO && isOutput) {
+ fixedEarpieceChannels = true;
+ channelsMask = channelMasksFromString("AUDIO_CHANNEL_OUT_MONO", ",");
+ }
if (mIgnoreVendorExtensions && maybeVendorExtension(format)) {
ALOGI("%s: vendor extension format \"%s\" skipped", __func__, format.c_str());
return NO_INIT;
}
AudioProfileTraits::Element profile = new AudioProfile(formatFromString(format, gDynamicFormat),
- channelMasksFromString(channels, mChannelMasksSeparator.c_str()),
+ channelsMask,
samplingRatesFromString(samplingRates, mSamplingRatesSeparator.c_str()));
profile->setDynamicFormat(profile->getFormat() == gDynamicFormat);
@@ -571,7 +580,11 @@ std::variant<status_t, DevicePortTraits::Element> PolicySerializer::deserialize<
new DeviceDescriptor(type, name, address, encodedFormats);
AudioProfileTraits::Collection profiles;
- status_t status = deserializeCollection<AudioProfileTraits>(cur, &profiles, NULL);
+ status_t status;
+ if(audio_is_output_devices(type))
+ status = deserializeCollection<AudioProfileTraits>(cur, &profiles, (AudioProfileTraits::PtrSerializingCtx)1);
+ else
+ status = deserializeCollection<AudioProfileTraits>(cur, &profiles, NULL);
if (status != NO_ERROR) {
return status;
}
@@ -892,6 +905,14 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
}
}
}
+
+ if(fixedEarpieceChannels) {
+ sp<DeviceDescriptor> device =
+ module->getDeclaredDevices().getDeviceFromTagName("Earpiece");
+ if(device != 0)
+ ctx->addDevice(device);
+ fixedEarpieceChannels = false;
+ }
return module;
}
--
2.34.1