audio policy: fix flag matching in output selection
Make sure we don't pick an output profile with specific functional
requirements (e.g HW A/V sync) for a client not compatible with those
requriements.
Bug: 118704067
Test: Play Netflix and assistant simultaneously
Change-Id: I6529deb6aa322be9f76433b1ead307a8ba367768
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 64a2b8a..5b1a990 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1313,6 +1313,10 @@
audio_format_t bestFormat = AUDIO_FORMAT_INVALID;
audio_format_t bestFormatForFlags = AUDIO_FORMAT_INVALID;
+ // Flags which must be present on both the request and the selected output
+ static const audio_output_flags_t kMandatedFlags = (audio_output_flags_t)
+ (AUDIO_OUTPUT_FLAG_HW_AV_SYNC | AUDIO_OUTPUT_FLAG_MMAP_NOIRQ);
+
for (audio_io_handle_t output : outputs) {
sp<SwAudioOutputDescriptor> outputDesc = mOutputs.valueFor(output);
if (!outputDesc->isDuplicated()) {
@@ -1336,6 +1340,10 @@
continue;
}
}
+ if ((kMandatedFlags & flags) !=
+ (kMandatedFlags & outputDesc->mProfile->getFlags())) {
+ continue;
+ }
// if a valid format is specified, skip output if not compatible
if (format != AUDIO_FORMAT_INVALID) {