Loading core/jni/android_media_AudioRecord.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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)) { Loading Loading @@ -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; Loading @@ -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); } Loading core/jni/android_media_AudioTrack.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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, Loading @@ -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; } // ---------------------------------------------------------------------------- Loading Loading
core/jni/android_media_AudioRecord.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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)) { Loading Loading @@ -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; Loading @@ -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); } Loading
core/jni/android_media_AudioTrack.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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, Loading @@ -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; } // ---------------------------------------------------------------------------- Loading