Fix the logic of getting aaudio MMAP policy from collection of policy info.
When the HAL reports mmap policy per device type, the framework will set
the aaudio policy according to the values of the reported policies.
1. Uses AUTO if any of the policy is AUTO or ALWAYS
2. Uses NEVER if all of the policies are NEVER or UNSPECIFIED
3. Uses default policy if all of the policies are UNSPECIFIED
Bug: 342652379
Test: dump aaudio service
FLAG: EXEMPT bugfix
Change-Id: I93bae470e6d9fbdb6eca24108f3f33cb1499824e
diff --git a/media/libaaudio/src/utility/AAudioUtilities.h b/media/libaaudio/src/utility/AAudioUtilities.h
index d44bbab..7c351e1 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.h
+++ b/media/libaaudio/src/utility/AAudioUtilities.h
@@ -348,9 +348,19 @@
AAUDIO_CHANNEL_INDEX_MASK_24 = AAUDIO_CHANNEL_BIT_INDEX | (1 << 24) - 1,
};
-// The aaudio policy will be ALWAYS, NEVER, UNSPECIFIED only when all policy info are
-// ALWAYS, NEVER or UNSPECIFIED. Otherwise, the aaudio policy will be AUTO.
+/**
+ * Returns the aaudio mmap policy based on the vector of mmap policy info. The rule as
+ * 1. Returns AUTO if any of the policy is AUTO or ALWAYS
+ * 2. Returns NEVER if all of the policies are NEVER or UNSPECIFIED
+ * 3. Returns default policy if all of the policies are UNSPECIFIED
+ *
+ * @param policyInfos
+ * @param defaultPolicy
+ * @return
+ */
aaudio_policy_t AAudio_getAAudioPolicy(
- const std::vector<android::media::audio::common::AudioMMapPolicyInfo>& policyInfos);
+ const std::vector<android::media::audio::common::AudioMMapPolicyInfo>& policyInfos,
+ android::media::audio::common::AudioMMapPolicy defaultPolicy =
+ android::media::audio::common::AudioMMapPolicy::NEVER);
#endif //UTILITY_AAUDIO_UTILITIES_H