diff options
author | Paul McLean <pmclean@google.com> | 2015-08-04 13:57:29 -0600 |
---|---|---|
committer | Paul McLean <pmclean@google.com> | 2015-08-05 09:03:51 -0600 |
commit | 3115960bdeb89f23131c5abf6eebc8c7e0fd8b9c (patch) | |
tree | 6bf3f51de66948cbd17ccb88c66d07b96a5c4db6 | |
parent | 845d14db9066c3262f270237b52e315aa71508b2 (diff) | |
download | frameworks_base-3115960bdeb89f23131c5abf6eebc8c7e0fd8b9c.zip frameworks_base-3115960bdeb89f23131c5abf6eebc8c7e0fd8b9c.tar.gz frameworks_base-3115960bdeb89f23131c5abf6eebc8c7e0fd8b9c.tar.bz2 |
Consider channel index masks when calculating channel counts.
Bug: 22874806
Change-Id: I04b74f5939bb81350d9e37b9629f8bbc242bffe7
-rw-r--r-- | media/java/android/media/AudioDeviceInfo.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java index bdb1f58..c73f596 100644 --- a/media/java/android/media/AudioDeviceInfo.java +++ b/media/java/android/media/AudioDeviceInfo.java @@ -19,6 +19,8 @@ package android.media; import android.annotation.NonNull; import android.util.SparseIntArray; +import java.util.TreeSet; + /** * Class to provide information about the audio devices. */ @@ -185,13 +187,24 @@ public final class AudioDeviceInfo { * can be configured. */ public @NonNull int[] getChannelCounts() { - int[] masks = getChannelMasks(); - int[] counts = new int[masks.length]; - // TODO: consider channel index masks - for (int mask_index = 0; mask_index < masks.length; mask_index++) { - counts[mask_index] = isSink() - ? AudioFormat.channelCountFromOutChannelMask(masks[mask_index]) - : AudioFormat.channelCountFromInChannelMask(masks[mask_index]); + TreeSet<Integer> countSet = new TreeSet<Integer>(); + + // Channel Masks + for (int mask : getChannelMasks()) { + countSet.add(isSink() ? + AudioFormat.channelCountFromOutChannelMask(mask) + : AudioFormat.channelCountFromInChannelMask(mask)); + } + + // Index Masks + for (int index_mask : getChannelIndexMasks()) { + countSet.add(Integer.bitCount(index_mask)); + } + + int[] counts = new int[countSet.size()]; + int index = 0; + for (int count : countSet) { + counts[index++] = count; } return counts; } |