Remove automatic addition of AC3, IEC61937 to HDMI outputs
Historically, the automatic addition of AC3 and IEC61937 formats
to the list of supported formats for HDMI output ports was a
workaround for the problem occuring in certain TV setups that
don't report supported formats properly. It was found out that
this workaround creates confusion in setups which report
supported formats properly. This is why automatic addition is
being removed now.
It's still possible to restore the historic behavior if required:
- on vendor side, by adding
'encodedFormats="AUDIO_FORMAT_AC3 AUDIO_FORMAT_IEC61937"' to the
HDMI output device port in the APM config file;
- on user side, by going to "Surround Sound" settings and
enabling "Dolby Digital" manually.
Bug: 201089251
Test: atest audiopolicy_tests
Test: manual test on an Android TV dongle
Change-Id: I54d9a2c2f203db9fb462ef6d1206ce17043ab997
diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
index 1722032..c9c8ede 100644
--- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
@@ -58,15 +58,6 @@
mDeclaredAddress(DeviceDescriptorBase::address())
{
mCurrentEncodedFormat = AUDIO_FORMAT_DEFAULT;
- /* If framework runs against a pre 5.0 Audio HAL, encoded formats are absent from the config.
- * FIXME: APM should know the version of the HAL and don't add the formats for V5.0.
- * For now, the workaround to remove AC3 and IEC61937 support on HDMI is to declare
- * something like 'encodedFormats="AUDIO_FORMAT_PCM_16_BIT"' on the HDMI devicePort.
- */
- if (mDeviceTypeAddr.mType == AUDIO_DEVICE_OUT_HDMI && mEncodedFormats.empty()) {
- mEncodedFormats.push_back(AUDIO_FORMAT_AC3);
- mEncodedFormats.push_back(AUDIO_FORMAT_IEC61937);
- }
}
void DeviceDescriptor::attach(const sp<HwModule>& module)
diff --git a/services/audiopolicy/tests/audiopolicymanager_tests.cpp b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
index 6a6d75a..9c1adc6 100644
--- a/services/audiopolicy/tests/audiopolicymanager_tests.cpp
+++ b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
@@ -827,7 +827,7 @@
void AudioPolicyManagerTestForHdmi::SetUp() {
ASSERT_NO_FATAL_FAILURE(AudioPolicyManagerTest::SetUp());
- // Note that 'AC3' isn't added as it is handled automatically by APM.
+ mClient->addSupportedFormat(AUDIO_FORMAT_AC3);
mClient->addSupportedFormat(AUDIO_FORMAT_E_AC3);
mManager->setDeviceConnectionState(
AUDIO_DEVICE_OUT_HDMI, AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
@@ -1392,7 +1392,8 @@
if (type == AUDIO_DEVICE_OUT_HDMI) {
// Set device connection state failed due to no device descriptor found
// For HDMI case, it is easier to simulate device descriptor not found error
- // by using a undeclared encoded format.
+ // by using an encoded format which isn't listed in the 'encodedFormats'
+ // attribute for this devicePort.
ASSERT_EQ(INVALID_OPERATION, mManager->setDeviceConnectionState(
type, AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
address.c_str(), name.c_str(), AUDIO_FORMAT_MAT_2_1));
diff --git a/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml b/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
index 87f0ab9..41ed70c 100644
--- a/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
+++ b/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
@@ -50,7 +50,8 @@
</devicePort>
<devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
</devicePort>
- <devicePort tagName="Hdmi" type="AUDIO_DEVICE_OUT_HDMI" role="sink">
+ <devicePort tagName="Hdmi" type="AUDIO_DEVICE_OUT_HDMI" role="sink"
+ encodedFormats="AUDIO_FORMAT_AC3">
</devicePort>
<devicePort tagName="Hdmi-In Mic" type="AUDIO_DEVICE_IN_HDMI" role="source">
</devicePort>