diff options
author | Ashok Bhat <ashok.bhat@arm.com> | 2013-12-17 12:42:00 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-01-07 12:47:51 +0000 |
commit | ea7861c918567d17d40a762b38f97c053d88b839 (patch) | |
tree | 9537ff48b8f13fecd39454e3b2922958c07ed186 /media | |
parent | 74675f29133ff36dccc95387392bf3654dc94e15 (diff) | |
download | frameworks_base-ea7861c918567d17d40a762b38f97c053d88b839.zip frameworks_base-ea7861c918567d17d40a762b38f97c053d88b839.tar.gz frameworks_base-ea7861c918567d17d40a762b38f97c053d88b839.tar.bz2 |
AArch64: Use long for pointers in audio effect classes
For storing pointers, long is used in AudioEffect
and Visualizer classes, as native pointers can be 64-bit.
In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)
Change-Id: Ief49bbe5baef663e268c7f6d70ac33a4df45621c
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Diffstat (limited to 'media')
4 files changed, 65 insertions, 57 deletions
diff --git a/media/java/android/media/audiofx/AudioEffect.java b/media/java/android/media/audiofx/AudioEffect.java index 1e1ef8c..cc121a3 100644 --- a/media/java/android/media/audiofx/AudioEffect.java +++ b/media/java/android/media/audiofx/AudioEffect.java @@ -315,8 +315,8 @@ public class AudioEffect { private int mId; // accessed by native methods - private int mNativeAudioEffect; - private int mJniData; + private long mNativeAudioEffect; + private long mJniData; /** * Effect descriptor diff --git a/media/java/android/media/audiofx/Visualizer.java b/media/java/android/media/audiofx/Visualizer.java index fb7f718..ff04201 100644 --- a/media/java/android/media/audiofx/Visualizer.java +++ b/media/java/android/media/audiofx/Visualizer.java @@ -184,8 +184,8 @@ public class Visualizer { private OnServerDiedListener mServerDiedListener = null; // accessed by native methods - private int mNativeVisualizer; - private int mJniData; + private long mNativeVisualizer; + private long mJniData; //-------------------------------------------------------------------------- // Constructor, Finalize diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp index bcab4f3..be37aa8 100644 --- a/media/jni/audioeffect/android_media_AudioEffect.cpp +++ b/media/jni/audioeffect/android_media_AudioEffect.cpp @@ -214,7 +214,7 @@ android_media_AudioEffect_native_init(JNIEnv *env) // nativeTrackInJavaObj fields.fidNativeAudioEffect = env->GetFieldID( fields.clazzEffect, - "mNativeAudioEffect", "I"); + "mNativeAudioEffect", "J"); if (fields.fidNativeAudioEffect == NULL) { ALOGE("Can't find AudioEffect.%s", "mNativeAudioEffect"); return; @@ -222,7 +222,7 @@ android_media_AudioEffect_native_init(JNIEnv *env) // fidJniData; fields.fidJniData = env->GetFieldID( fields.clazzEffect, - "mJniData", "I"); + "mJniData", "J"); if (fields.fidJniData == NULL) { ALOGE("Can't find AudioEffect.%s", "mJniData"); return; @@ -388,11 +388,11 @@ android_media_AudioEffect_native_setup(JNIEnv *env, jobject thiz, jobject weak_t env->SetObjectArrayElement(javadesc, 0, jdesc); - env->SetIntField(thiz, fields.fidNativeAudioEffect, (int)lpAudioEffect); + env->SetLongField(thiz, fields.fidNativeAudioEffect, (jlong)lpAudioEffect); - env->SetIntField(thiz, fields.fidJniData, (int)lpJniStorage); + env->SetLongField(thiz, fields.fidJniData, (jlong)lpJniStorage); - return AUDIOEFFECT_SUCCESS; + return (jint) AUDIOEFFECT_SUCCESS; // failures: setup_failure: @@ -404,12 +404,12 @@ setup_failure: if (lpAudioEffect) { delete lpAudioEffect; } - env->SetIntField(thiz, fields.fidNativeAudioEffect, 0); + env->SetLongField(thiz, fields.fidNativeAudioEffect, 0); if (lpJniStorage) { delete lpJniStorage; } - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidJniData, 0); if (uuidStr != NULL) { env->ReleaseStringUTFChars(uuid, uuidStr); @@ -419,27 +419,27 @@ setup_failure: env->ReleaseStringUTFChars(type, typeStr); } - return lStatus; + return (jint)lStatus; } // ---------------------------------------------------------------------------- static void android_media_AudioEffect_native_finalize(JNIEnv *env, jobject thiz) { - ALOGV("android_media_AudioEffect_native_finalize jobject: %x\n", (int)thiz); + ALOGV("android_media_AudioEffect_native_finalize jobject: %p\n", thiz); // delete the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect) { - ALOGV("deleting AudioEffect: %x\n", (int)lpAudioEffect); + ALOGV("deleting AudioEffect: %p\n", lpAudioEffect); delete lpAudioEffect; } // delete the JNI data - AudioEffectJniStorage* lpJniStorage = (AudioEffectJniStorage *)env->GetIntField( + AudioEffectJniStorage* lpJniStorage = (AudioEffectJniStorage *)env->GetLongField( thiz, fields.fidJniData); if (lpJniStorage) { - ALOGV("deleting pJniStorage: %x\n", (int)lpJniStorage); + ALOGV("deleting pJniStorage: %p\n", lpJniStorage); delete lpJniStorage; } } @@ -451,15 +451,15 @@ static void android_media_AudioEffect_native_release(JNIEnv *env, jobject thiz) android_media_AudioEffect_native_finalize(env, thiz); // + reset the native resources in the Java object so any attempt to access // them after a call to release fails. - env->SetIntField(thiz, fields.fidNativeAudioEffect, 0); - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidNativeAudioEffect, 0); + env->SetLongField(thiz, fields.fidJniData, 0); } static jint android_media_AudioEffect_native_setEnabled(JNIEnv *env, jobject thiz, jboolean enabled) { // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { @@ -468,23 +468,27 @@ android_media_AudioEffect_native_setEnabled(JNIEnv *env, jobject thiz, jboolean return AUDIOEFFECT_ERROR_NO_INIT; } - return translateError(lpAudioEffect->setEnabled(enabled)); + return (jint) translateError(lpAudioEffect->setEnabled(enabled)); } static jboolean android_media_AudioEffect_native_getEnabled(JNIEnv *env, jobject thiz) { // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "Unable to retrieve AudioEffect pointer for getEnabled()"); - return false; + return JNI_FALSE; } - return (jboolean)lpAudioEffect->getEnabled(); + if (lpAudioEffect->getEnabled()) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } @@ -492,24 +496,24 @@ static jboolean android_media_AudioEffect_native_hasControl(JNIEnv *env, jobject thiz) { // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *)env->GetIntField( + AudioEffect* lpAudioEffect = (AudioEffect *)env->GetLongField( thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "Unable to retrieve AudioEffect pointer for hasControl()"); - return false; + return JNI_FALSE; } if (lpAudioEffect->initCheck() == NO_ERROR) { - return true; + return JNI_TRUE; } else { - return false; + return JNI_FALSE; } } static jint android_media_AudioEffect_native_setParameter(JNIEnv *env, - jobject thiz, int psize, jbyteArray pJavaParam, int vsize, + jobject thiz, jint psize, jbyteArray pJavaParam, jint vsize, jbyteArray pJavaValue) { // retrieve the AudioEffect object jbyte* lpValue = NULL; @@ -518,7 +522,7 @@ static jint android_media_AudioEffect_native_setParameter(JNIEnv *env, effect_param_t *p; int voffset; - AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz, + AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { @@ -567,7 +571,7 @@ setParameter_Exit: if (lpValue != NULL) { env->ReleasePrimitiveArrayCritical(pJavaValue, lpValue, 0); } - return translateError(lStatus); + return (jint) translateError(lStatus); } static jint @@ -581,7 +585,7 @@ android_media_AudioEffect_native_getParameter(JNIEnv *env, effect_param_t *p; int voffset; - AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz, + AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { @@ -637,7 +641,7 @@ getParameter_Exit: if (lStatus == NO_ERROR) { return vsize; } - return translateError(lStatus); + return (jint) translateError(lStatus); } static jint android_media_AudioEffect_native_command(JNIEnv *env, jobject thiz, @@ -648,7 +652,7 @@ static jint android_media_AudioEffect_native_command(JNIEnv *env, jobject thiz, jint lStatus = AUDIOEFFECT_ERROR_BAD_VALUE; // retrieve the AudioEffect object - AudioEffect* lpAudioEffect = (AudioEffect *) env->GetIntField(thiz, + AudioEffect* lpAudioEffect = (AudioEffect *) env->GetLongField(thiz, fields.fidNativeAudioEffect); if (lpAudioEffect == NULL) { diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp index 40cd06b..8463d94 100644 --- a/media/jni/audioeffect/android_media_Visualizer.cpp +++ b/media/jni/audioeffect/android_media_Visualizer.cpp @@ -231,7 +231,7 @@ static void captureCallback(void* user, static Visualizer *getVisualizer(JNIEnv* env, jobject thiz) { - Visualizer *v = (Visualizer *)env->GetIntField( + Visualizer *v = (Visualizer *)env->GetLongField( thiz, fields.fidNativeVisualizer); if (v == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -282,7 +282,7 @@ android_media_visualizer_native_init(JNIEnv *env) // nativeTrackInJavaObj fields.fidNativeVisualizer = env->GetFieldID( fields.clazzEffect, - "mNativeVisualizer", "I"); + "mNativeVisualizer", "J"); if (fields.fidNativeVisualizer == NULL) { ALOGE("Can't find Visualizer.%s", "mNativeVisualizer"); return; @@ -290,7 +290,7 @@ android_media_visualizer_native_init(JNIEnv *env) // fidJniData; fields.fidJniData = env->GetFieldID( fields.clazzEffect, - "mJniData", "I"); + "mJniData", "J"); if (fields.fidJniData == NULL) { ALOGE("Can't find Visualizer.%s", "mJniData"); return; @@ -391,9 +391,9 @@ android_media_visualizer_native_setup(JNIEnv *env, jobject thiz, jobject weak_th env->ReleasePrimitiveArrayCritical(jId, nId, 0); nId = NULL; - env->SetIntField(thiz, fields.fidNativeVisualizer, (int)lpVisualizer); + env->SetLongField(thiz, fields.fidNativeVisualizer, (jlong)lpVisualizer); - env->SetIntField(thiz, fields.fidJniData, (int)lpJniStorage); + env->SetLongField(thiz, fields.fidJniData, (jlong)lpJniStorage); return VISUALIZER_SUCCESS; @@ -407,33 +407,33 @@ setup_failure: if (lpVisualizer) { delete lpVisualizer; } - env->SetIntField(thiz, fields.fidNativeVisualizer, 0); + env->SetLongField(thiz, fields.fidNativeVisualizer, 0); if (lpJniStorage) { delete lpJniStorage; } - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidJniData, 0); - return lStatus; + return (jint) lStatus; } // ---------------------------------------------------------------------------- static void android_media_visualizer_native_finalize(JNIEnv *env, jobject thiz) { - ALOGV("android_media_visualizer_native_finalize jobject: %x\n", (int)thiz); + ALOGV("android_media_visualizer_native_finalize jobject: %p\n", thiz); // delete the Visualizer object - Visualizer* lpVisualizer = (Visualizer *)env->GetIntField( + Visualizer* lpVisualizer = (Visualizer *)env->GetLongField( thiz, fields.fidNativeVisualizer); if (lpVisualizer) { - ALOGV("deleting Visualizer: %x\n", (int)lpVisualizer); + ALOGV("deleting Visualizer: %p\n", lpVisualizer); delete lpVisualizer; } // delete the JNI data - visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField( + visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField( thiz, fields.fidJniData); if (lpJniStorage) { - ALOGV("deleting pJniStorage: %x\n", (int)lpJniStorage); + ALOGV("deleting pJniStorage: %p\n", lpJniStorage); delete lpJniStorage; } } @@ -445,8 +445,8 @@ static void android_media_visualizer_native_release(JNIEnv *env, jobject thiz) android_media_visualizer_native_finalize(env, thiz); // + reset the native resources in the Java object so any attempt to access // them after a call to release fails. - env->SetIntField(thiz, fields.fidNativeVisualizer, 0); - env->SetIntField(thiz, fields.fidJniData, 0); + env->SetLongField(thiz, fields.fidNativeVisualizer, 0); + env->SetLongField(thiz, fields.fidJniData, 0); } static jint @@ -460,7 +460,7 @@ android_media_visualizer_native_setEnabled(JNIEnv *env, jobject thiz, jboolean e jint retVal = translateError(lpVisualizer->setEnabled(enabled)); if (!enabled) { - visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField( + visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField( thiz, fields.fidJniData); if (NULL != lpJniStorage) @@ -475,10 +475,14 @@ android_media_visualizer_native_getEnabled(JNIEnv *env, jobject thiz) { Visualizer* lpVisualizer = getVisualizer(env, thiz); if (lpVisualizer == NULL) { - return false; + return JNI_FALSE; } - return (jboolean)lpVisualizer->getEnabled(); + if (lpVisualizer->getEnabled()) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } static jintArray @@ -496,7 +500,7 @@ android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject thiz) static jint android_media_visualizer_native_getMaxCaptureRate(JNIEnv *env, jobject thiz) { - return Visualizer::getMaxCaptureRate(); + return (jint) Visualizer::getMaxCaptureRate(); } static jint @@ -517,7 +521,7 @@ android_media_visualizer_native_getCaptureSize(JNIEnv *env, jobject thiz) if (lpVisualizer == NULL) { return -1; } - return lpVisualizer->getCaptureSize(); + return (jint) lpVisualizer->getCaptureSize(); } static jint @@ -538,7 +542,7 @@ android_media_visualizer_native_getScalingMode(JNIEnv *env, jobject thiz) if (lpVisualizer == NULL) { return -1; } - return lpVisualizer->getScalingMode(); + return (jint)lpVisualizer->getScalingMode(); } static jint @@ -568,7 +572,7 @@ android_media_visualizer_native_getSamplingRate(JNIEnv *env, jobject thiz) if (lpVisualizer == NULL) { return -1; } - return lpVisualizer->getSamplingRate(); + return (jint) lpVisualizer->getSamplingRate(); } static jint @@ -634,7 +638,7 @@ android_media_setPeriodicCapture(JNIEnv *env, jobject thiz, jint rate, jboolean if (lpVisualizer == NULL) { return VISUALIZER_ERROR_NO_INIT; } - visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetIntField(thiz, + visualizerJniStorage* lpJniStorage = (visualizerJniStorage *)env->GetLongField(thiz, fields.fidJniData); if (lpJniStorage == NULL) { return VISUALIZER_ERROR_NO_INIT; |