Loading core/jni/android_media_AudioTrack.cpp +12 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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) Loading @@ -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)); Loading media/java/android/media/AudioFormat.java +2 −2 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ public class AudioFormat { /** Default audio channel mask */ public static final int CHANNEL_OUT_DEFAULT = 1; // Channel mask definitions must be kept in sync with native values // in /system/core/include/system/audio.h // Channel mask definitions below are translated to the native values defined in // in /system/core/include/system/audio.h in the JNI code of AudioTrack public static final int CHANNEL_OUT_FRONT_LEFT = 0x4; public static final int CHANNEL_OUT_FRONT_RIGHT = 0x8; public static final int CHANNEL_OUT_FRONT_CENTER = 0x10; Loading Loading
core/jni/android_media_AudioTrack.cpp +12 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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) Loading @@ -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)); Loading
media/java/android/media/AudioFormat.java +2 −2 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ public class AudioFormat { /** Default audio channel mask */ public static final int CHANNEL_OUT_DEFAULT = 1; // Channel mask definitions must be kept in sync with native values // in /system/core/include/system/audio.h // Channel mask definitions below are translated to the native values defined in // in /system/core/include/system/audio.h in the JNI code of AudioTrack public static final int CHANNEL_OUT_FRONT_LEFT = 0x4; public static final int CHANNEL_OUT_FRONT_RIGHT = 0x8; public static final int CHANNEL_OUT_FRONT_CENTER = 0x10; Loading