audio policy: select output with best sample format match
Add rules allowing selection of the output stream with the sample
format offering the best match to the client track sample format
when more than one output is compatible with a request.
Bug: 27210844
Change-Id: I31981940be5d1c06d713d52187cfb0a7bf355773
diff --git a/services/audiopolicy/common/include/policy.h b/services/audiopolicy/common/include/policy.h
index e3ee4e5..18acb23 100755
--- a/services/audiopolicy/common/include/policy.h
+++ b/services/audiopolicy/common/include/policy.h
@@ -126,3 +126,18 @@
}
return 0;
}
+
+/* Indicates if audio formats are equivalent when considering a match between
+ * audio HAL supported formats and client requested formats
+ */
+static inline bool audio_formats_match(audio_format_t format1,
+ audio_format_t format2)
+{
+ if (audio_is_linear_pcm(format1) &&
+ (audio_bytes_per_sample(format1) > 2) &&
+ audio_is_linear_pcm(format2) &&
+ (audio_bytes_per_sample(format2) > 2)) {
+ return true;
+ }
+ return format1 == format2;
+}