summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-11-14 09:44:14 -0800
committerGlenn Kasten <gkasten@google.com>2014-03-28 15:44:45 -0700
commit5b8fd44365f03601aaba41879ac18e70ce814a0f (patch)
treef2b0f393e6139c4954b2b4e8dbdbbe78aa1c9cd3
parent08c96b5515f061f61e13b348f6022ce7c586e4c4 (diff)
downloadframeworks_base-5b8fd44365f03601aaba41879ac18e70ce814a0f.zip
frameworks_base-5b8fd44365f03601aaba41879ac18e70ce814a0f.tar.gz
frameworks_base-5b8fd44365f03601aaba41879ac18e70ce814a0f.tar.bz2
AudioTrack and AudioRecord JNI cleanup
Rename nbChannels to our conventional channelCount, which should make code searches easier. Change-Id: I3c2791db302558a15bc8be198b6f3d482e0e0055
-rw-r--r--core/jni/android_media_AudioRecord.cpp12
-rw-r--r--core/jni/android_media_AudioTrack.cpp10
2 files changed, 11 insertions, 11 deletions
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index 0132b5f..cc49059 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)) {
@@ -501,17 +501,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;
@@ -519,7 +519,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 3a5b566..9f997c0 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -214,14 +214,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;
@@ -265,7 +265,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) {
@@ -867,7 +867,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,
@@ -879,7 +879,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;
}
// ----------------------------------------------------------------------------