From edad5db98d9014f7cb4cd2654bfb6c4b1ba2df80 Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Mon, 9 Sep 2019 10:39:56 -0700 Subject: [PATCH] Require HW AV sync flag match for compatible output IOProfile Previously, Audio HAL implementers need all HW A/V sync profiles declared after non HW A/V sync profiles in their audio policy configurations, otherwise a HW A/V sync profile match could be found for a non HW A/V sync (e.g. direct only) request, the Audio HAL output stream would be opened with the HW A/V sync flag, and Audio HALs typically fail to process the stream as they are setup to parse in-band HW A/V sync headers (even if they don't receive keyStreamHwAvSync AudioParameter). Test: atest audiopolicy_tests AudioPolicyManagerTVTest#MatchOutputNoHwAvSync fails w/o IOProfile change, passes with the change. Bug: 140447125 Merged-In: Icfc806497b5b23013e63621a585c28d1d7a9882a Change-Id: Icfc806497b5b23013e63621a585c28d1d7a9882a --- .../audiopolicy/common/managerdefinitions/src/IOProfile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp index fe2eaee244..6e1c0fa34d 100644 --- a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp @@ -79,7 +79,9 @@ bool IOProfile::isCompatibleProfile(const DeviceVector &devices, } } - if (isPlaybackThread && (getFlags() & flags) != flags) { + const uint32_t mustMatchOutputFlags = AUDIO_OUTPUT_FLAG_HW_AV_SYNC; + if (isPlaybackThread && (((getFlags() ^ flags) & mustMatchOutputFlags) + || (getFlags() & flags) != flags)) { return false; } // The only input flag that is allowed to be different is the fast flag.