Count channel mapping number from the back.
The channel mapping array may have leading UNUSED value. In that case, count the channel mapping number from the back to avoid lost channel mapping information. Bug: 183558363 Test: repo steps in the bug Test: atest android.hardware.audio@7.0-util_tests Change-Id: Ic4238e520c16eb1daad7c9e92555e92637f8e7c9
This commit is contained in:
parent
210e8ea1f6
commit
5f82f49d4f
1 changed files with 4 additions and 4 deletions
|
@ -66,13 +66,13 @@ status_t CoreUtils::microphoneInfoFromHal(
|
|||
CONVERT_CHECKED(
|
||||
deviceAddressFromHal(halMicInfo.device, halMicInfo.address, &micInfo->deviceAddress),
|
||||
result);
|
||||
size_t chCount;
|
||||
for (chCount = 0; chCount < AUDIO_CHANNEL_COUNT_MAX; ++chCount) {
|
||||
if (halMicInfo.channel_mapping[chCount] == AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED) {
|
||||
int chCount;
|
||||
for (chCount = AUDIO_CHANNEL_COUNT_MAX - 1; chCount >= 0; --chCount) {
|
||||
if (halMicInfo.channel_mapping[chCount] != AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
micInfo->channelMapping.resize(chCount);
|
||||
micInfo->channelMapping.resize(chCount + 1);
|
||||
for (size_t ch = 0; ch < micInfo->channelMapping.size(); ch++) {
|
||||
micInfo->channelMapping[ch] = AudioMicrophoneChannelMapping(halMicInfo.channel_mapping[ch]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue