summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2011-07-26 09:27:53 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-26 09:27:53 -0700
commitaf20eacc2170a0641749bad822926d86161431c7 (patch)
tree0c140af4735c0d6942d8941b153e024b2d2c72c5 /core/jni
parent1bfe9a9b02f64cea13a07565e77c0ea006b49928 (diff)
parentd9ae1c573e37e245c7f4f0480a8fa925e57bd49d (diff)
downloadframeworks_base-af20eacc2170a0641749bad822926d86161431c7.zip
frameworks_base-af20eacc2170a0641749bad822926d86161431c7.tar.gz
frameworks_base-af20eacc2170a0641749bad822926d86161431c7.tar.bz2
Merge "Fix bug 4319552 Java to native channel mask translation"
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_media_AudioTrack.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index bd70dad..2929056 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -167,11 +167,11 @@ static void audioCallback(int event, void* user, void *info) {
// ----------------------------------------------------------------------------
static int
android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_this,
- jint streamType, jint sampleRateInHertz, jint channels,
+ jint streamType, jint sampleRateInHertz, jint javaChannelMask,
jint audioFormat, jint buffSizeInBytes, jint memoryMode, jintArray jSession)
{
- LOGV("sampleRate=%d, audioFormat(from Java)=%d, channels=%x, buffSize=%d",
- sampleRateInHertz, audioFormat, channels, buffSizeInBytes);
+ LOGV("sampleRate=%d, audioFormat(from Java)=%d, channel mask=%x, buffSize=%d",
+ sampleRateInHertz, audioFormat, javaChannelMask, buffSizeInBytes);
int afSampleRate;
int afFrameCount;
@@ -184,11 +184,16 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
}
- if (!audio_is_output_channel(channels)) {
+ // Java channel masks don't map directly to the native definition, but it's a simple shift
+ // to skip the two deprecated channel configurations "default" and "mono".
+ uint32_t nativeChannelMask = ((uint32_t)javaChannelMask) >> 2;
+
+ if (!audio_is_output_channel(nativeChannelMask)) {
LOGE("Error creating AudioTrack: invalid channel mask.");
return AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
}
- int nbChannels = popcount(channels);
+
+ int nbChannels = popcount(nativeChannelMask);
// check the stream type
audio_stream_type_t atStreamType;
@@ -285,7 +290,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
atStreamType,// stream type
sampleRateInHertz,
format,// word length, PCM
- channels,
+ nativeChannelMask,
frameCount,
0,// flags
audioCallback, &(lpJniStorage->mCallbackData),//callback, callback data (user)
@@ -306,7 +311,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
atStreamType,// stream type
sampleRateInHertz,
format,// word length, PCM
- channels,
+ nativeChannelMask,
frameCount,
0,// flags
audioCallback, &(lpJniStorage->mCallbackData),//callback, callback data (user));