mirror of
https://github.com/yurisieucuti/treble_evolution.git
synced 2024-11-28 04:44:30 +00:00
88 lines
3.8 KiB
Diff
88 lines
3.8 KiB
Diff
From 810c9acd67552db3d2fbf598908ebf48398f661e 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/25] 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 53fabcc71e..83eafc2f79 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;
|
|
}
|
|
@@ -882,6 +895,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.25.1
|
|
|