diff options
author | Eric Laurent <elaurent@google.com> | 2014-09-11 17:25:51 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-11 17:25:51 +0000 |
commit | c206aa58fecaabbed91d1ca556ccf75f0256bd41 (patch) | |
tree | 6bc84b4c73b4a20436129ff8884467fe28ba1caa /media/jni | |
parent | 10dcaa134f613c010ef78fecdf818a00bb4ab94b (diff) | |
parent | 8cfe0394c1d76e9dd029af8763f61d41c6ec5954 (diff) | |
download | frameworks_base-c206aa58fecaabbed91d1ca556ccf75f0256bd41.zip frameworks_base-c206aa58fecaabbed91d1ca556ccf75f0256bd41.tar.gz frameworks_base-c206aa58fecaabbed91d1ca556ccf75f0256bd41.tar.bz2 |
am 7a3c88e0: am 6bc4e4b4: am 0b381432: Merge "AudioEffect JNI: fix queryEffects()" into lmp-dev
* commit '7a3c88e004b664d3bb20b56b029d29d629541399':
AudioEffect JNI: fix queryEffects()
Diffstat (limited to 'media/jni')
-rw-r--r-- | media/jni/audioeffect/android_media_AudioEffect.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp index be37aa8..c9cefbd 100644 --- a/media/jni/audioeffect/android_media_AudioEffect.cpp +++ b/media/jni/audioeffect/android_media_AudioEffect.cpp @@ -705,11 +705,12 @@ command_Exit: } static jobjectArray -android_media_AudioEffect_native_queryEffects(JNIEnv *env, jclass clazz) +android_media_AudioEffect_native_queryEffects(JNIEnv *env, jclass clazz __unused) { effect_descriptor_t desc; char str[EFFECT_STRING_LEN_MAX]; - uint32_t numEffects = 0; + uint32_t totalEffectsCount = 0; + uint32_t returnedEffectsCount = 0; uint32_t i = 0; jstring jdescType; jstring jdescUuid; @@ -717,19 +718,20 @@ android_media_AudioEffect_native_queryEffects(JNIEnv *env, jclass clazz) jstring jdescName; jstring jdescImplementor; jobject jdesc; + jobjectArray ret; - if (AudioEffect::queryNumberEffects(&numEffects) != NO_ERROR) { + if (AudioEffect::queryNumberEffects(&totalEffectsCount) != NO_ERROR) { return NULL; } - jobjectArray ret = env->NewObjectArray(numEffects, fields.clazzDesc, NULL); - if (ret == NULL) { - return ret; + jobjectArray temp = env->NewObjectArray(totalEffectsCount, fields.clazzDesc, NULL); + if (temp == NULL) { + return temp; } - ALOGV("queryEffects() numEffects: %d", numEffects); + ALOGV("queryEffects() totalEffectsCount: %d", totalEffectsCount); - for (i = 0; i < numEffects; i++) { + for (i = 0; i < totalEffectsCount; i++) { if (AudioEffect::queryEffect(i, &desc) != NO_ERROR) { goto queryEffects_failure; } @@ -770,15 +772,26 @@ android_media_AudioEffect_native_queryEffects(JNIEnv *env, jclass clazz) goto queryEffects_failure; } - env->SetObjectArrayElement(ret, i, jdesc); + env->SetObjectArrayElement(temp, returnedEffectsCount++, jdesc); } + if (returnedEffectsCount == 0) { + goto queryEffects_failure; + } + ret = env->NewObjectArray(returnedEffectsCount, fields.clazzDesc, NULL); + if (ret == NULL) { + goto queryEffects_failure; + } + for (i = 0; i < returnedEffectsCount; i++) { + env->SetObjectArrayElement(ret, i, env->GetObjectArrayElement(temp, i)); + } + env->DeleteLocalRef(temp); return ret; queryEffects_failure: - if (ret != NULL) { - env->DeleteLocalRef(ret); + if (temp != NULL) { + env->DeleteLocalRef(temp); } return NULL; @@ -787,7 +800,8 @@ queryEffects_failure: static jobjectArray -android_media_AudioEffect_native_queryPreProcessings(JNIEnv *env, jclass clazz, jint audioSession) +android_media_AudioEffect_native_queryPreProcessings(JNIEnv *env, jclass clazz __unused, + jint audioSession) { // kDefaultNumEffects is a "reasonable" value ensuring that only one query will be enough on // most devices to get all active audio pre processing on a given session. @@ -895,7 +909,7 @@ int register_android_media_AudioEffect(JNIEnv *env) return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } -jint JNI_OnLoad(JavaVM* vm, void* reserved) +jint JNI_OnLoad(JavaVM* vm, void* reserved __unused) { JNIEnv* env = NULL; |