summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2012-04-25 11:09:01 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2012-04-25 11:12:37 -0700
commit1b8f499a14a4340d3422d95c7f6fdc8c0c72b3a4 (patch)
tree57a447f816b1659b81f5383e3742ea504ecb8327
parent7725180c646d1976a2a2097735862a75ec47c544 (diff)
downloadframeworks_base-1b8f499a14a4340d3422d95c7f6fdc8c0c72b3a4.zip
frameworks_base-1b8f499a14a4340d3422d95c7f6fdc8c0c72b3a4.tar.gz
frameworks_base-1b8f499a14a4340d3422d95c7f6fdc8c0c72b3a4.tar.bz2
Allow multichannel configurations in android.media.AudioTrack
Compare the channel configuration against a mask of the public channel masks in AudioFormat for up to 5.1 with back channels, and allow combinations within this mask. Change-Id: I84b72dfd88d4490f0c67bf10d13151a9eb06f6a8
-rw-r--r--media/java/android/media/AudioTrack.java32
1 files changed, 26 insertions, 6 deletions
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 7d4c282..f51a24a 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -340,6 +340,15 @@ public class AudioTrack
}
}
+ // mask of all the channels supported by this implementation
+ private static final int SUPPORTED_OUT_CHANNELS =
+ AudioFormat.CHANNEL_OUT_FRONT_LEFT |
+ AudioFormat.CHANNEL_OUT_FRONT_RIGHT |
+ AudioFormat.CHANNEL_OUT_FRONT_CENTER |
+ AudioFormat.CHANNEL_OUT_LOW_FREQUENCY |
+ AudioFormat.CHANNEL_OUT_BACK_LEFT |
+ AudioFormat.CHANNEL_OUT_BACK_RIGHT |
+ AudioFormat.CHANNEL_OUT_BACK_CENTER;
// Convenience method for the constructor's parameter checks.
// This is where constructor IllegalArgumentException-s are thrown
@@ -392,10 +401,16 @@ public class AudioTrack
mChannels = AudioFormat.CHANNEL_OUT_STEREO;
break;
default:
- mChannelCount = 0;
- mChannels = AudioFormat.CHANNEL_INVALID;
- mChannelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_INVALID;
- throw(new IllegalArgumentException("Unsupported channel configuration."));
+ if ((channelConfig & SUPPORTED_OUT_CHANNELS) != channelConfig) {
+ // input channel configuration features unsupported channels
+ mChannelCount = 0;
+ mChannels = AudioFormat.CHANNEL_INVALID;
+ mChannelConfiguration = AudioFormat.CHANNEL_INVALID;
+ throw(new IllegalArgumentException("Unsupported channel configuration."));
+ } else {
+ mChannels = channelConfig;
+ mChannelCount = Integer.bitCount(channelConfig);
+ }
}
//--------------
@@ -623,8 +638,13 @@ public class AudioTrack
channelCount = 2;
break;
default:
- loge("getMinBufferSize(): Invalid channel configuration.");
- return AudioTrack.ERROR_BAD_VALUE;
+ if ((channelConfig & SUPPORTED_OUT_CHANNELS) != channelConfig) {
+ // input channel configuration features unsupported channels
+ loge("getMinBufferSize(): Invalid channel configuration.");
+ return AudioTrack.ERROR_BAD_VALUE;
+ } else {
+ channelCount = Integer.bitCount(channelConfig);
+ }
}
if ((audioFormat != AudioFormat.ENCODING_PCM_16BIT)