Merge "AArch64: Use long for pointers in audio effect classes"
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 @@
     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 @@
     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 @@
     //      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 @@
     //      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 @@
 
     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 @@
     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 @@
         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 @@
     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 @@
         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 @@
 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 @@
     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 @@
     if (lpValue != NULL) {
         env->ReleasePrimitiveArrayCritical(pJavaValue, lpValue, 0);
     }
-    return translateError(lStatus);
+    return (jint) translateError(lStatus);
 }
 
 static jint
@@ -581,7 +585,7 @@
     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 @@
     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 @@
     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 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 @@
     //      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 @@
     //      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 @@
     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 @@
     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 @@
     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 @@
     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 @@
 {
     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 @@
 static jint
 android_media_visualizer_native_getMaxCaptureRate(JNIEnv *env, jobject thiz)
 {
-    return Visualizer::getMaxCaptureRate();
+    return (jint) Visualizer::getMaxCaptureRate();
 }
 
 static jint
@@ -517,7 +521,7 @@
     if (lpVisualizer == NULL) {
         return -1;
     }
-    return lpVisualizer->getCaptureSize();
+    return (jint) lpVisualizer->getCaptureSize();
 }
 
 static jint
@@ -538,7 +542,7 @@
     if (lpVisualizer == NULL) {
         return -1;
     }
-    return lpVisualizer->getScalingMode();
+    return (jint)lpVisualizer->getScalingMode();
 }
 
 static jint
@@ -568,7 +572,7 @@
     if (lpVisualizer == NULL) {
         return -1;
     }
-    return lpVisualizer->getSamplingRate();
+    return (jint) lpVisualizer->getSamplingRate();
 }
 
 static jint
@@ -634,7 +638,7 @@
     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;