diff options
author | Glenn Kasten <gkasten@google.com> | 2014-03-31 23:06:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-03-31 23:06:50 +0000 |
commit | b9b07b8c48dca71c0aa6adf77baabcea0285215e (patch) | |
tree | 3c1e1fbd27f2a395cddc3fdc6157fb8d9b2daa41 | |
parent | 30cac644f161433fca92ca65edcb26b351a04e5a (diff) | |
parent | 5b8fd44365f03601aaba41879ac18e70ce814a0f (diff) | |
download | frameworks_base-b9b07b8c48dca71c0aa6adf77baabcea0285215e.zip frameworks_base-b9b07b8c48dca71c0aa6adf77baabcea0285215e.tar.gz frameworks_base-b9b07b8c48dca71c0aa6adf77baabcea0285215e.tar.bz2 |
Merge "AudioTrack and AudioRecord JNI cleanup"
-rw-r--r-- | core/jni/android_media_AudioRecord.cpp | 12 | ||||
-rw-r--r-- | core/jni/android_media_AudioTrack.cpp | 10 |
2 files changed, 11 insertions, 11 deletions
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp index 9449bac..d8faaf3 100644 --- a/core/jni/android_media_AudioRecord.cpp +++ b/core/jni/android_media_AudioRecord.cpp @@ -166,7 +166,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, ALOGE("Error creating AudioRecord: channel mask %#x is not valid.", channelMask); return (jint) AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK; } - uint32_t nbChannels = popcount(channelMask); + uint32_t channelCount = popcount(channelMask); // compare the format against the Java constants audio_format_t format = audioFormatToNative(audioFormat); @@ -181,7 +181,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, ALOGE("Error creating AudioRecord: frameCount is 0."); return (jint) AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT; } - size_t frameSize = nbChannels * bytesPerSample; + size_t frameSize = channelCount * bytesPerSample; size_t frameCount = buffSizeInBytes / frameSize; if ((uint32_t(source) >= AUDIO_SOURCE_CNT) && (uint32_t(source) != AUDIO_SOURCE_HOTWORD)) { @@ -500,17 +500,17 @@ static jint android_media_AudioRecord_get_pos_update_period(JNIEnv *env, jobjec // returns 0 if the parameter combination is not supported. // return -1 if there was an error querying the buffer size. static jint android_media_AudioRecord_get_min_buff_size(JNIEnv *env, jobject thiz, - jint sampleRateInHertz, jint nbChannels, jint audioFormat) { + jint sampleRateInHertz, jint channelCount, jint audioFormat) { ALOGV(">> android_media_AudioRecord_get_min_buff_size(%d, %d, %d)", - sampleRateInHertz, nbChannels, audioFormat); + sampleRateInHertz, channelCount, audioFormat); size_t frameCount = 0; audio_format_t format = audioFormatToNative(audioFormat); status_t result = AudioRecord::getMinFrameCount(&frameCount, sampleRateInHertz, format, - audio_channel_in_mask_from_count(nbChannels)); + audio_channel_in_mask_from_count(channelCount)); if (result == BAD_VALUE) { return 0; @@ -518,7 +518,7 @@ static jint android_media_AudioRecord_get_min_buff_size(JNIEnv *env, jobject th if (result != NO_ERROR) { return -1; } - return frameCount * nbChannels * audio_bytes_per_sample(format); + return frameCount * channelCount * audio_bytes_per_sample(format); } diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index d79b2a4..79a46fa 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -219,14 +219,14 @@ android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject weak_this, // 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; + audio_channel_mask_t nativeChannelMask = ((uint32_t)javaChannelMask) >> 2; if (!audio_is_output_channel(nativeChannelMask)) { ALOGE("Error creating AudioTrack: invalid channel mask %#x.", javaChannelMask); return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK; } - int nbChannels = popcount(nativeChannelMask); + uint32_t channelCount = popcount(nativeChannelMask); // check the stream type audio_stream_type_t atStreamType; @@ -269,7 +269,7 @@ android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject weak_this, // compute the frame count const size_t bytesPerSample = audio_bytes_per_sample(format); - size_t frameCount = buffSizeInBytes / (nbChannels * bytesPerSample); + size_t frameCount = buffSizeInBytes / (channelCount * bytesPerSample); jclass clazz = env->GetObjectClass(thiz); if (clazz == NULL) { @@ -872,7 +872,7 @@ static jint android_media_AudioTrack_get_output_sample_rate(JNIEnv *env, jobjec // returns the minimum required size for the successful creation of a streaming AudioTrack // returns -1 if there was an error querying the hardware. static jint android_media_AudioTrack_get_min_buff_size(JNIEnv *env, jobject thiz, - jint sampleRateInHertz, jint nbChannels, jint audioFormat) { + jint sampleRateInHertz, jint channelCount, jint audioFormat) { size_t frameCount; const status_t status = AudioTrack::getMinFrameCount(&frameCount, AUDIO_STREAM_DEFAULT, @@ -884,7 +884,7 @@ static jint android_media_AudioTrack_get_min_buff_size(JNIEnv *env, jobject thi } const audio_format_t format = audioFormatToNative(audioFormat); const size_t bytesPerSample = audio_bytes_per_sample(format); - return frameCount * nbChannels * bytesPerSample; + return frameCount * channelCount * bytesPerSample; } // ---------------------------------------------------------------------------- |