Merge "audio policy: fix channel match rule for input profiles" into qt-dev am: d4e2ab1785
am: 8d00c0e01c
Change-Id: Id5ec679ef7e2c857553cb7e175472edf6de2ce24
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioProfile.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioProfile.cpp
index a645e02..69d6b0c 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioProfile.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioProfile.cpp
@@ -178,6 +178,7 @@
const bool isRecordThread = portType == AUDIO_PORT_TYPE_MIX && portRole == AUDIO_PORT_ROLE_SINK;
const bool isIndex = audio_channel_mask_get_representation(channelMask)
== AUDIO_CHANNEL_REPRESENTATION_INDEX;
+ const uint32_t channelCount = audio_channel_count_from_in_mask(channelMask);
int bestMatch = 0;
for (size_t i = 0; i < mChannelMasks.size(); i ++) {
audio_channel_mask_t supported = mChannelMasks[i];
@@ -201,11 +202,15 @@
// OR
// match score += 100 if the channel mask representations match
// match score += number of channels matched.
+ // match score += 100 if the channel mask representations DO NOT match
+ // but the profile has positional channel mask and less than 2 channels.
+ // This is for audio HAL convention to not list index masks for less than 2 channels
//
// If there are no matched channels, the mask may still be accepted
// but the playback or record will be silent.
const bool isSupportedIndex = (audio_channel_mask_get_representation(supported)
== AUDIO_CHANNEL_REPRESENTATION_INDEX);
+ const uint32_t supportedChannelCount = audio_channel_count_from_in_mask(supported);
int match;
if (isIndex && isSupportedIndex) {
// index equivalence
@@ -213,13 +218,14 @@
audio_channel_mask_get_bits(channelMask)
& audio_channel_mask_get_bits(supported));
} else if (isIndex && !isSupportedIndex) {
- const uint32_t equivalentBits =
- (1 << audio_channel_count_from_in_mask(supported)) - 1 ;
+ const uint32_t equivalentBits = (1 << supportedChannelCount) - 1 ;
match = __builtin_popcount(
audio_channel_mask_get_bits(channelMask) & equivalentBits);
+ if (supportedChannelCount <= FCC_2) {
+ match += 100;
+ }
} else if (!isIndex && isSupportedIndex) {
- const uint32_t equivalentBits =
- (1 << audio_channel_count_from_in_mask(channelMask)) - 1;
+ const uint32_t equivalentBits = (1 << channelCount) - 1;
match = __builtin_popcount(
equivalentBits & audio_channel_mask_get_bits(supported));
} else {