diff options
Diffstat (limited to 'media/jni')
20 files changed, 419 insertions, 309 deletions
diff --git a/media/jni/android_media_AmrInputStream.cpp b/media/jni/android_media_AmrInputStream.cpp index b5220fe..3df6530 100644 --- a/media/jni/android_media_AmrInputStream.cpp +++ b/media/jni/android_media_AmrInputStream.cpp @@ -49,17 +49,17 @@ struct GsmAmrEncoderState { int32_t mLastModeUsed; }; -static jint android_media_AmrInputStream_GsmAmrEncoderNew +static jlong android_media_AmrInputStream_GsmAmrEncoderNew (JNIEnv *env, jclass clazz) { GsmAmrEncoderState* gae = new GsmAmrEncoderState(); if (gae == NULL) { jniThrowRuntimeException(env, "Out of memory"); } - return (jint)gae; + return (jlong)gae; } static void android_media_AmrInputStream_GsmAmrEncoderInitialize - (JNIEnv *env, jclass clazz, jint gae) { + (JNIEnv *env, jclass clazz, jlong gae) { GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; int32_t nResult = AMREncodeInit(&state->mEncState, &state->mSidState, false); if (nResult != OK) { @@ -70,7 +70,7 @@ static void android_media_AmrInputStream_GsmAmrEncoderInitialize static jint android_media_AmrInputStream_GsmAmrEncoderEncode (JNIEnv *env, jclass clazz, - jint gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) { + jlong gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) { jbyte inBuf[BYTES_PER_FRAME]; jbyte outBuf[MAX_OUTPUT_BUFFER_SIZE]; @@ -86,7 +86,7 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode if (length < 0) { jniThrowExceptionFmt(env, "java/io/IOException", "Failed to encode a frame with error code: %d", length); - return -1; + return (jint)-1; } // The 1st byte of PV AMR frames are WMF (Wireless Multimedia Forum) @@ -101,30 +101,30 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode env->SetByteArrayRegion(amr, amrOffset, length, outBuf); - return length; + return (jint)length; } static void android_media_AmrInputStream_GsmAmrEncoderCleanup - (JNIEnv *env, jclass clazz, jint gae) { - GsmAmrEncoderState *state = (GsmAmrEncoderState *)gae; + (JNIEnv *env, jclass clazz, jlong gae) { + GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; AMREncodeExit(&state->mEncState, &state->mSidState); state->mEncState = NULL; state->mSidState = NULL; } static void android_media_AmrInputStream_GsmAmrEncoderDelete - (JNIEnv *env, jclass clazz, jint gae) { + (JNIEnv *env, jclass clazz, jlong gae) { delete (GsmAmrEncoderState*)gae; } // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { - {"GsmAmrEncoderNew", "()I", (void*)android_media_AmrInputStream_GsmAmrEncoderNew}, - {"GsmAmrEncoderInitialize", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderInitialize}, - {"GsmAmrEncoderEncode", "(I[BI[BI)I", (void*)android_media_AmrInputStream_GsmAmrEncoderEncode}, - {"GsmAmrEncoderCleanup", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderCleanup}, - {"GsmAmrEncoderDelete", "(I)V", (void*)android_media_AmrInputStream_GsmAmrEncoderDelete}, + {"GsmAmrEncoderNew", "()J", (void*)android_media_AmrInputStream_GsmAmrEncoderNew}, + {"GsmAmrEncoderInitialize", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderInitialize}, + {"GsmAmrEncoderEncode", "(J[BI[BI)I", (void*)android_media_AmrInputStream_GsmAmrEncoderEncode}, + {"GsmAmrEncoderCleanup", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderCleanup}, + {"GsmAmrEncoderDelete", "(J)V", (void*)android_media_AmrInputStream_GsmAmrEncoderDelete}, }; diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index b8d437c..221ea57 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -328,20 +328,20 @@ using namespace android; static sp<JMediaCodec> setMediaCodec( JNIEnv *env, jobject thiz, const sp<JMediaCodec> &codec) { - sp<JMediaCodec> old = (JMediaCodec *)env->GetIntField(thiz, gFields.context); + sp<JMediaCodec> old = (JMediaCodec *)env->GetLongField(thiz, gFields.context); if (codec != NULL) { codec->incStrong(thiz); } if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)codec.get()); + env->SetLongField(thiz, gFields.context, (jlong)codec.get()); return old; } static sp<JMediaCodec> getMediaCodec(JNIEnv *env, jobject thiz) { - return (JMediaCodec *)env->GetIntField(thiz, gFields.context); + return (JMediaCodec *)env->GetLongField(thiz, gFields.context); } static void android_media_MediaCodec_release(JNIEnv *env, jobject thiz) { @@ -710,7 +710,7 @@ static jint android_media_MediaCodec_dequeueInputBuffer( status_t err = codec->dequeueInputBuffer(&index, timeoutUs); if (err == OK) { - return index; + return (jint) index; } return throwExceptionAsNecessary(env, err); @@ -732,7 +732,7 @@ static jint android_media_MediaCodec_dequeueOutputBuffer( env, bufferInfo, &index, timeoutUs); if (err == OK) { - return index; + return (jint) index; } return throwExceptionAsNecessary(env, err); @@ -885,7 +885,7 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) { env, env->FindClass("android/media/MediaCodec")); CHECK(clazz.get() != NULL); - gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "I"); + gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "J"); CHECK(gFields.context != NULL); clazz.reset(env->FindClass("android/media/MediaCodec$CryptoInfo")); diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp index d0f56ea..a6f8dcd 100644 --- a/media/jni/android_media_MediaCrypto.cpp +++ b/media/jni/android_media_MediaCrypto.cpp @@ -38,7 +38,7 @@ struct fields_t { static fields_t gFields; static sp<JCrypto> getCrypto(JNIEnv *env, jobject thiz) { - return (JCrypto *)env->GetIntField(thiz, gFields.context); + return (JCrypto *)env->GetLongField(thiz, gFields.context); } JCrypto::JCrypto( @@ -146,14 +146,14 @@ using namespace android; static sp<JCrypto> setCrypto( JNIEnv *env, jobject thiz, const sp<JCrypto> &crypto) { - sp<JCrypto> old = (JCrypto *)env->GetIntField(thiz, gFields.context); + sp<JCrypto> old = (JCrypto *)env->GetLongField(thiz, gFields.context); if (crypto != NULL) { crypto->incStrong(thiz); } if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)crypto.get()); + env->SetLongField(thiz, gFields.context, (jlong)crypto.get()); return old; } @@ -166,7 +166,7 @@ static void android_media_MediaCrypto_native_init(JNIEnv *env) { jclass clazz = env->FindClass("android/media/MediaCrypto"); CHECK(clazz != NULL); - gFields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + gFields.context = env->GetFieldID(clazz, "mNativeContext", "J"); CHECK(gFields.context != NULL); } @@ -232,7 +232,7 @@ static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative( env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } jboolean isCopy; @@ -243,27 +243,27 @@ static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative( env->ReleaseByteArrayElements(uuidObj, uuid, 0); uuid = NULL; - return result; + return result ? JNI_TRUE : JNI_FALSE; } static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent( JNIEnv *env, jobject thiz, jstring mimeObj) { if (mimeObj == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } sp<JCrypto> crypto = getCrypto(env, thiz); if (crypto == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } const char *mime = env->GetStringUTFChars(mimeObj, NULL); if (mime == NULL) { - return false; + return JNI_FALSE; } bool result = crypto->requiresSecureDecoderComponent(mime); @@ -271,7 +271,7 @@ static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent( env->ReleaseStringUTFChars(mimeObj, mime); mime = NULL; - return result; + return result ? JNI_TRUE : JNI_FALSE; } static JNINativeMethod gMethods[] = { diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index bbb74d2..4fbd2a4 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -100,6 +100,16 @@ struct KeyTypes { jint kKeyTypeRelease; } gKeyTypes; +struct CertificateTypes { + jint kCertificateTypeNone; + jint kCertificateTypeX509; +} gCertificateTypes; + +struct CertificateFields { + jfieldID wrappedPrivateKey; + jfieldID certificateData; +}; + struct fields_t { jfieldID context; jmethodID post_event; @@ -110,6 +120,11 @@ struct fields_t { SetFields set; IteratorFields iterator; EntryFields entry; + CertificateFields certificate; + jclass certificateClassId; + jclass hashmapClassId; + jclass arraylistClassId; + jclass stringClassId; }; static fields_t gFields; @@ -186,6 +201,7 @@ void JNIDrmListener::notify(DrmPlugin::EventType eventType, int extra, nativeParcel->setData(obj->data(), obj->dataSize()); env->CallStaticVoidMethod(mClass, gFields.post_event, mObject, jeventType, extra, jParcel); + env->DeleteLocalRef(jParcel); } } @@ -267,7 +283,7 @@ static bool throwExceptionAsNecessary( } static sp<IDrm> GetDrm(JNIEnv *env, jobject thiz) { - JDrm *jdrm = (JDrm *)env->GetIntField(thiz, gFields.context); + JDrm *jdrm = (JDrm *)env->GetLongField(thiz, gFields.context); return jdrm ? jdrm->getDrm() : NULL; } @@ -281,8 +297,6 @@ JDrm::JDrm( } JDrm::~JDrm() { - mDrm.clear(); - JNIEnv *env = AndroidRuntime::getJNIEnv(); env->DeleteWeakGlobalRef(mObject); @@ -347,6 +361,13 @@ void JDrm::notify(DrmPlugin::EventType eventType, int extra, const Parcel *obj) } } +void JDrm::disconnect() { + if (mDrm != NULL) { + mDrm->destroyPlugin(); + mDrm.clear(); + } +} + // static bool JDrm::IsCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType) { @@ -405,8 +426,7 @@ static String8 JStringToString8(JNIEnv *env, jstring const &jstr) { */ static KeyedVector<String8, String8> HashMapToKeyedVector(JNIEnv *env, jobject &hashMap) { - jclass clazz; - FIND_CLASS(clazz, "java/lang/String"); + jclass clazz = gFields.stringClassId; KeyedVector<String8, String8> keyedVector; jobject entrySet = env->CallObjectMethod(hashMap, gFields.hashmap.entrySet); @@ -449,8 +469,7 @@ static KeyedVector<String8, String8> HashMapToKeyedVector(JNIEnv *env, jobject & } static jobject KeyedVectorToHashMap (JNIEnv *env, KeyedVector<String8, String8> const &map) { - jclass clazz; - FIND_CLASS(clazz, "java/util/HashMap"); + jclass clazz = gFields.hashmapClassId; jobject hashMap = env->NewObject(clazz, gFields.hashmap.init); for (size_t i = 0; i < map.size(); ++i) { jstring jkey = env->NewStringUTF(map.keyAt(i).string()); @@ -464,8 +483,7 @@ static jobject KeyedVectorToHashMap (JNIEnv *env, KeyedVector<String8, String8> static jobject ListOfVectorsToArrayListOfByteArray(JNIEnv *env, List<Vector<uint8_t> > list) { - jclass clazz; - FIND_CLASS(clazz, "java/util/ArrayList"); + jclass clazz = gFields.arraylistClassId; jobject arrayList = env->NewObject(clazz, gFields.arraylist.init); List<Vector<uint8_t> >::iterator iter = list.begin(); while (iter != list.end()) { @@ -484,14 +502,14 @@ using namespace android; static sp<JDrm> setDrm( JNIEnv *env, jobject thiz, const sp<JDrm> &drm) { - sp<JDrm> old = (JDrm *)env->GetIntField(thiz, gFields.context); + sp<JDrm> old = (JDrm *)env->GetLongField(thiz, gFields.context); if (drm != NULL) { drm->incStrong(thiz); } if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)drm.get()); + env->SetLongField(thiz, gFields.context, reinterpret_cast<jlong>(drm.get())); return old; } @@ -514,13 +532,14 @@ static void android_media_MediaDrm_release(JNIEnv *env, jobject thiz) { sp<JDrm> drm = setDrm(env, thiz, NULL); if (drm != NULL) { drm->setListener(NULL); + drm->disconnect(); } } static void android_media_MediaDrm_native_init(JNIEnv *env) { jclass clazz; FIND_CLASS(clazz, "android/media/MediaDrm"); - GET_FIELD_ID(gFields.context, clazz, "mNativeContext", "I"); + GET_FIELD_ID(gFields.context, clazz, "mNativeContext", "J"); GET_STATIC_METHOD_ID(gFields.post_event, clazz, "postEventFromNative", "(Ljava/lang/Object;IILjava/lang/Object;)V"); @@ -541,6 +560,11 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) { GET_STATIC_FIELD_ID(field, clazz, "KEY_TYPE_RELEASE", "I"); gKeyTypes.kKeyTypeRelease = env->GetStaticIntField(clazz, field); + GET_STATIC_FIELD_ID(field, clazz, "CERTIFICATE_TYPE_NONE", "I"); + gCertificateTypes.kCertificateTypeNone = env->GetStaticIntField(clazz, field); + GET_STATIC_FIELD_ID(field, clazz, "CERTIFICATE_TYPE_X509", "I"); + gCertificateTypes.kCertificateTypeX509 = env->GetStaticIntField(clazz, field); + FIND_CLASS(clazz, "android/media/MediaDrm$KeyRequest"); GET_FIELD_ID(gFields.keyRequest.data, clazz, "mData", "[B"); GET_FIELD_ID(gFields.keyRequest.defaultUrl, clazz, "mDefaultUrl", "Ljava/lang/String;"); @@ -549,6 +573,11 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) { GET_FIELD_ID(gFields.provisionRequest.data, clazz, "mData", "[B"); GET_FIELD_ID(gFields.provisionRequest.defaultUrl, clazz, "mDefaultUrl", "Ljava/lang/String;"); + FIND_CLASS(clazz, "android/media/MediaDrm$Certificate"); + GET_FIELD_ID(gFields.certificate.wrappedPrivateKey, clazz, "mWrappedKey", "[B"); + GET_FIELD_ID(gFields.certificate.certificateData, clazz, "mCertificateData", "[B"); + gFields.certificateClassId = static_cast<jclass>(env->NewGlobalRef(clazz)); + FIND_CLASS(clazz, "java/util/ArrayList"); GET_METHOD_ID(gFields.arraylist.init, clazz, "<init>", "()V"); GET_METHOD_ID(gFields.arraylist.add, clazz, "add", "(Ljava/lang/Object;)Z"); @@ -570,6 +599,15 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) { FIND_CLASS(clazz, "java/util/Map$Entry"); GET_METHOD_ID(gFields.entry.getKey, clazz, "getKey", "()Ljava/lang/Object;"); GET_METHOD_ID(gFields.entry.getValue, clazz, "getValue", "()Ljava/lang/Object;"); + + FIND_CLASS(clazz, "java/util/HashMap"); + gFields.hashmapClassId = static_cast<jclass>(env->NewGlobalRef(clazz)); + + FIND_CLASS(clazz, "java/lang/String"); + gFields.stringClassId = static_cast<jclass>(env->NewGlobalRef(clazz)); + + FIND_CLASS(clazz, "java/util/ArrayList"); + gFields.arraylistClassId = static_cast<jclass>(env->NewGlobalRef(clazz)); } static void android_media_MediaDrm_native_setup( @@ -825,8 +863,8 @@ static jobject android_media_MediaDrm_queryKeyStatus( return KeyedVectorToHashMap(env, infoMap); } -static jobject android_media_MediaDrm_getProvisionRequest( - JNIEnv *env, jobject thiz) { +static jobject android_media_MediaDrm_getProvisionRequestNative( + JNIEnv *env, jobject thiz, jint jcertType, jstring jcertAuthority) { sp<IDrm> drm = GetDrm(env, thiz); if (drm == NULL) { @@ -838,7 +876,17 @@ static jobject android_media_MediaDrm_getProvisionRequest( Vector<uint8_t> request; String8 defaultUrl; - status_t err = drm->getProvisionRequest(request, defaultUrl); + String8 certType; + if (jcertType == gCertificateTypes.kCertificateTypeX509) { + certType = "X.509"; + } else if (jcertType == gCertificateTypes.kCertificateTypeNone) { + certType = "none"; + } else { + certType = "invalid"; + } + + String8 certAuthority = JStringToString8(env, jcertAuthority); + status_t err = drm->getProvisionRequest(certType, certAuthority, request, defaultUrl); if (throwExceptionAsNecessary(env, err, "Failed to get provision request")) { return NULL; @@ -862,27 +910,43 @@ static jobject android_media_MediaDrm_getProvisionRequest( return provisionObj; } -static void android_media_MediaDrm_provideProvisionResponse( +static jobject android_media_MediaDrm_provideProvisionResponseNative( JNIEnv *env, jobject thiz, jbyteArray jresponse) { sp<IDrm> drm = GetDrm(env, thiz); if (drm == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "MediaDrm obj is null"); - return; + return NULL; } if (jresponse == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", "provision response is null"); - return; + return NULL; } Vector<uint8_t> response(JByteArrayToVector(env, jresponse)); + Vector<uint8_t> certificate, wrappedKey; + + status_t err = drm->provideProvisionResponse(response, certificate, wrappedKey); + + // Fill out return obj + jclass clazz = gFields.certificateClassId; - status_t err = drm->provideProvisionResponse(response); + jobject certificateObj = NULL; + + if (clazz && certificate.size() && wrappedKey.size()) { + certificateObj = env->AllocObject(clazz); + jbyteArray jcertificate = VectorToJByteArray(env, certificate); + env->SetObjectField(certificateObj, gFields.certificate.certificateData, jcertificate); + + jbyteArray jwrappedKey = VectorToJByteArray(env, wrappedKey); + env->SetObjectField(certificateObj, gFields.certificate.wrappedPrivateKey, jwrappedKey); + } throwExceptionAsNecessary(env, err, "Failed to handle provision response"); + return certificateObj; } static jobject android_media_MediaDrm_getSecureStops( @@ -1208,6 +1272,38 @@ static jboolean android_media_MediaDrm_verifyNative( } +static jbyteArray android_media_MediaDrm_signRSANative( + JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + jstring jalgorithm, jbyteArray jwrappedKey, jbyteArray jmessage) { + + sp<IDrm> drm = GetDrm(env, jdrm); + + if (!CheckSession(env, drm, jsessionId)) { + return NULL; + } + + if (jalgorithm == NULL || jwrappedKey == NULL || jmessage == NULL) { + jniThrowException(env, "java/lang/IllegalArgumentException", + "required argument is null"); + return NULL; + } + + Vector<uint8_t> sessionId(JByteArrayToVector(env, jsessionId)); + String8 algorithm = JStringToString8(env, jalgorithm); + Vector<uint8_t> wrappedKey(JByteArrayToVector(env, jwrappedKey)); + Vector<uint8_t> message(JByteArrayToVector(env, jmessage)); + Vector<uint8_t> signature; + + status_t err = drm->signRSA(sessionId, algorithm, message, wrappedKey, signature); + + if (throwExceptionAsNecessary(env, err, "Failed to sign")) { + return NULL; + } + + return VectorToJByteArray(env, signature); +} + + static JNINativeMethod gMethods[] = { { "release", "()V", (void *)android_media_MediaDrm_release }, { "native_init", "()V", (void *)android_media_MediaDrm_native_init }, @@ -1243,11 +1339,11 @@ static JNINativeMethod gMethods[] = { { "queryKeyStatus", "([B)Ljava/util/HashMap;", (void *)android_media_MediaDrm_queryKeyStatus }, - { "getProvisionRequest", "()Landroid/media/MediaDrm$ProvisionRequest;", - (void *)android_media_MediaDrm_getProvisionRequest }, + { "getProvisionRequestNative", "(ILjava/lang/String;)Landroid/media/MediaDrm$ProvisionRequest;", + (void *)android_media_MediaDrm_getProvisionRequestNative }, - { "provideProvisionResponse", "([B)V", - (void *)android_media_MediaDrm_provideProvisionResponse }, + { "provideProvisionResponseNative", "([B)Landroid/media/MediaDrm$Certificate;", + (void *)android_media_MediaDrm_provideProvisionResponseNative }, { "getSecureStops", "()Ljava/util/List;", (void *)android_media_MediaDrm_getSecureStops }, @@ -1286,6 +1382,9 @@ static JNINativeMethod gMethods[] = { { "verifyNative", "(Landroid/media/MediaDrm;[B[B[B[B)Z", (void *)android_media_MediaDrm_verifyNative }, + + { "signRSANative", "(Landroid/media/MediaDrm;[BLjava/lang/String;[B[B)[B", + (void *)android_media_MediaDrm_signRSANative }, }; int register_android_media_Drm(JNIEnv *env) { diff --git a/media/jni/android_media_MediaDrm.h b/media/jni/android_media_MediaDrm.h index 620ad28..b7b8e5d 100644 --- a/media/jni/android_media_MediaDrm.h +++ b/media/jni/android_media_MediaDrm.h @@ -47,6 +47,8 @@ struct JDrm : public BnDrmClient { void notify(DrmPlugin::EventType, int extra, const Parcel *obj); status_t setListener(const sp<DrmListener>& listener); + void disconnect(); + protected: virtual ~JDrm(); diff --git a/media/jni/android_media_MediaExtractor.cpp b/media/jni/android_media_MediaExtractor.cpp index 1ac45d4..705de88 100644 --- a/media/jni/android_media_MediaExtractor.cpp +++ b/media/jni/android_media_MediaExtractor.cpp @@ -88,7 +88,7 @@ class JavaDataSourceBridge : public DataSource { env->GetByteArrayRegion(byteArrayObj, 0, size, (jbyte*) buffer); env->DeleteLocalRef(byteArrayObj); if (env->ExceptionCheck()) { - ALOGW("Exception occurred while reading %d at %lld", size, offset); + ALOGW("Exception occurred while reading %zu at %lld", size, offset); LOGW_EX(env); env->ExceptionClear(); return -1; @@ -198,7 +198,7 @@ status_t JMediaExtractor::readSampleData( void *dst = env->GetDirectBufferAddress(byteBuf); - jlong dstSize; + size_t dstSize; jbyteArray byteArray = NULL; if (dst == NULL) { @@ -219,9 +219,9 @@ status_t JMediaExtractor::readSampleData( jboolean isCopy; dst = env->GetByteArrayElements(byteArray, &isCopy); - dstSize = env->GetArrayLength(byteArray); + dstSize = (size_t) env->GetArrayLength(byteArray); } else { - dstSize = env->GetDirectBufferCapacity(byteBuf); + dstSize = (size_t) env->GetDirectBufferCapacity(byteBuf); } if (dstSize < offset) { @@ -299,7 +299,7 @@ using namespace android; static sp<JMediaExtractor> setMediaExtractor( JNIEnv *env, jobject thiz, const sp<JMediaExtractor> &extractor) { sp<JMediaExtractor> old = - (JMediaExtractor *)env->GetIntField(thiz, gFields.context); + (JMediaExtractor *)env->GetLongField(thiz, gFields.context); if (extractor != NULL) { extractor->incStrong(thiz); @@ -307,13 +307,13 @@ static sp<JMediaExtractor> setMediaExtractor( if (old != NULL) { old->decStrong(thiz); } - env->SetIntField(thiz, gFields.context, (int)extractor.get()); + env->SetLongField(thiz, gFields.context, (jlong)extractor.get()); return old; } static sp<JMediaExtractor> getMediaExtractor(JNIEnv *env, jobject thiz) { - return (JMediaExtractor *)env->GetIntField(thiz, gFields.context); + return (JMediaExtractor *)env->GetLongField(thiz, gFields.context); } static void android_media_MediaExtractor_release(JNIEnv *env, jobject thiz) { @@ -329,7 +329,7 @@ static jint android_media_MediaExtractor_getTrackCount( return -1; } - return extractor->countTracks(); + return (jint) extractor->countTracks(); } static jobject android_media_MediaExtractor_getTrackFormatNative( @@ -430,19 +430,19 @@ static jboolean android_media_MediaExtractor_advance( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } status_t err = extractor->advance(); if (err == ERROR_END_OF_STREAM) { - return false; + return JNI_FALSE; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return JNI_FALSE; } - return true; + return JNI_TRUE; } static jint android_media_MediaExtractor_readSampleData( @@ -461,10 +461,10 @@ static jint android_media_MediaExtractor_readSampleData( return -1; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1; } - return sampleSize; + return (jint) sampleSize; } static jint android_media_MediaExtractor_getSampleTrackIndex( @@ -483,10 +483,10 @@ static jint android_media_MediaExtractor_getSampleTrackIndex( return -1; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1; } - return trackIndex; + return (jint) trackIndex; } static jlong android_media_MediaExtractor_getSampleTime( @@ -505,10 +505,10 @@ static jlong android_media_MediaExtractor_getSampleTime( return -1ll; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1ll; } - return sampleTimeUs; + return (jlong) sampleTimeUs; } static jint android_media_MediaExtractor_getSampleFlags( @@ -517,20 +517,20 @@ static jint android_media_MediaExtractor_getSampleFlags( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return -1ll; + return -1; } uint32_t sampleFlags; status_t err = extractor->getSampleFlags(&sampleFlags); if (err == ERROR_END_OF_STREAM) { - return -1ll; + return -1; } else if (err != OK) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); - return false; + return -1; } - return sampleFlags; + return (jint) sampleFlags; } static jboolean android_media_MediaExtractor_getSampleCryptoInfo( @@ -539,27 +539,27 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return -1ll; + return JNI_FALSE; } sp<MetaData> meta; status_t err = extractor->getSampleMeta(&meta); if (err != OK) { - return false; + return JNI_FALSE; } uint32_t type; const void *data; size_t size; if (!meta->findData(kKeyEncryptedSizes, &type, &data, &size)) { - return false; + return JNI_FALSE; } size_t numSubSamples = size / sizeof(size_t); if (numSubSamples == 0) { - return false; + return JNI_FALSE; } jintArray numBytesOfEncryptedDataObj = env->NewIntArray(numSubSamples); @@ -576,7 +576,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (meta->findData(kKeyPlainSizes, &type, &data, &size)) { if (size != encSize) { // The two must be of the same length. - return false; + return JNI_FALSE; } numBytesOfPlainDataObj = env->NewIntArray(numSubSamples); @@ -593,7 +593,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (meta->findData(kKeyCryptoKey, &type, &data, &size)) { if (size != 16) { // Keys must be 16 bytes in length. - return false; + return JNI_FALSE; } keyObj = env->NewByteArray(size); @@ -608,7 +608,7 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( if (meta->findData(kKeyCryptoIV, &type, &data, &size)) { if (size != 16) { // IVs must be 16 bytes in length. - return false; + return JNI_FALSE; } ivObj = env->NewByteArray(size); @@ -634,14 +634,14 @@ static jboolean android_media_MediaExtractor_getSampleCryptoInfo( ivObj, mode); - return true; + return JNI_TRUE; } static void android_media_MediaExtractor_native_init(JNIEnv *env) { jclass clazz = env->FindClass("android/media/MediaExtractor"); CHECK(clazz != NULL); - gFields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + gFields.context = env->GetFieldID(clazz, "mNativeContext", "J"); CHECK(gFields.context != NULL); clazz = env->FindClass("android/media/MediaCodec$CryptoInfo"); @@ -770,7 +770,7 @@ static jlong android_media_MediaExtractor_getCachedDurationUs( return -1ll; } - return cachedDurationUs; + return (jlong) cachedDurationUs; } static jboolean android_media_MediaExtractor_hasCacheReachedEOS( @@ -779,16 +779,16 @@ static jboolean android_media_MediaExtractor_hasCacheReachedEOS( if (extractor == NULL) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return true; + return JNI_TRUE; } int64_t cachedDurationUs; bool eos; if (!extractor->getCachedDuration(&cachedDurationUs, &eos)) { - return true; + return JNI_TRUE; } - return eos; + return eos ? JNI_TRUE : JNI_FALSE; } static void android_media_MediaExtractor_native_finalize( diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index 297dadf..a52b24d 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -67,15 +67,15 @@ static void process_media_retriever_call(JNIEnv *env, status_t opStatus, const c static MediaMetadataRetriever* getRetriever(JNIEnv* env, jobject thiz) { // No lock is needed, since it is called internally by other methods that are protected - MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context); + MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context); return retriever; } -static void setRetriever(JNIEnv* env, jobject thiz, int retriever) +static void setRetriever(JNIEnv* env, jobject thiz, MediaMetadataRetriever* retriever) { // No lock is needed, since it is called internally by other methods that are protected - MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context); - env->SetIntField(thiz, fields.context, retriever); + MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context); + env->SetLongField(thiz, fields.context, (jlong) retriever); } static void @@ -146,10 +146,10 @@ static void android_media_MediaMetadataRetriever_setDataSourceFD(JNIEnv *env, jo int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (offset < 0 || length < 0 || fd < 0) { if (offset < 0) { - ALOGE("negative offset (%lld)", offset); + ALOGE("negative offset (%lld)", (long long)offset); } if (length < 0) { - ALOGE("negative length (%lld)", length); + ALOGE("negative length (%lld)", (long long)length); } if (fd < 0) { ALOGE("invalid file descriptor"); @@ -264,7 +264,7 @@ static jobject android_media_MediaMetadataRetriever_getFrameAtTime(JNIEnv *env, config); SkBitmap *bitmap = - (SkBitmap *) env->GetIntField(jBitmap, fields.nativeBitmap); + (SkBitmap *) env->GetLongField(jBitmap, fields.nativeBitmap); bitmap->lockPixels(); rotate((uint16_t*)bitmap->getPixels(), @@ -359,7 +359,7 @@ static void android_media_MediaMetadataRetriever_release(JNIEnv *env, jobject th Mutex::Autolock lock(sLock); MediaMetadataRetriever* retriever = getRetriever(env, thiz); delete retriever; - setRetriever(env, thiz, 0); + setRetriever(env, thiz, (MediaMetadataRetriever*) 0); } static void android_media_MediaMetadataRetriever_native_finalize(JNIEnv *env, jobject thiz) @@ -379,7 +379,7 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } @@ -406,7 +406,7 @@ static void android_media_MediaMetadataRetriever_native_init(JNIEnv *env) if (fields.createScaledBitmapMethod == NULL) { return; } - fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "I"); + fields.nativeBitmap = env->GetFieldID(fields.bitmapClazz, "mNativeBitmap", "J"); if (fields.nativeBitmap == NULL) { return; } @@ -435,7 +435,7 @@ static void android_media_MediaMetadataRetriever_native_setup(JNIEnv *env, jobje jniThrowException(env, "java/lang/RuntimeException", "Out of memory"); return; } - setRetriever(env, thiz, (int)retriever); + setRetriever(env, thiz, retriever); } // JNI mapping between Java methods and native methods diff --git a/media/jni/android_media_MediaMuxer.cpp b/media/jni/android_media_MediaMuxer.cpp index 457b956..2c16a05 100644 --- a/media/jni/android_media_MediaMuxer.cpp +++ b/media/jni/android_media_MediaMuxer.cpp @@ -31,7 +31,6 @@ namespace android { struct fields_t { - jfieldID context; jmethodID arrayID; }; @@ -42,7 +41,7 @@ static fields_t gFields; using namespace android; static jint android_media_MediaMuxer_addTrack( - JNIEnv *env, jclass clazz, jint nativeObject, jobjectArray keys, + JNIEnv *env, jclass clazz, jlong nativeObject, jobjectArray keys, jobjectArray values) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -72,7 +71,7 @@ static jint android_media_MediaMuxer_addTrack( } static void android_media_MediaMuxer_writeSampleData( - JNIEnv *env, jclass clazz, jint nativeObject, jint trackIndex, + JNIEnv *env, jclass clazz, jlong nativeObject, jint trackIndex, jobject byteBuf, jint offset, jint size, jlong timeUs, jint flags) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -147,7 +146,7 @@ static jint android_media_MediaMuxer_native_setup( } static void android_media_MediaMuxer_setOrientationHint( - JNIEnv *env, jclass clazz, jint nativeObject, jint degrees) { + JNIEnv *env, jclass clazz, jlong nativeObject, jint degrees) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -177,7 +176,7 @@ static void android_media_MediaMuxer_setLocation( } static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz, - jint nativeObject) { + jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -195,7 +194,7 @@ static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz, } static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz, - jint nativeObject) { + jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -213,7 +212,7 @@ static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz, } static void android_media_MediaMuxer_native_release( - JNIEnv *env, jclass clazz, jint nativeObject) { + JNIEnv *env, jclass clazz, jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer != NULL) { muxer->decStrong(clazz); @@ -222,26 +221,26 @@ static void android_media_MediaMuxer_native_release( static JNINativeMethod gMethods[] = { - { "nativeAddTrack", "(I[Ljava/lang/String;[Ljava/lang/Object;)I", + { "nativeAddTrack", "(J[Ljava/lang/String;[Ljava/lang/Object;)I", (void *)android_media_MediaMuxer_addTrack }, - { "nativeSetOrientationHint", "(II)V", + { "nativeSetOrientationHint", "(JI)V", (void *)android_media_MediaMuxer_setOrientationHint}, - { "nativeSetLocation", "(III)V", + { "nativeSetLocation", "(JII)V", (void *)android_media_MediaMuxer_setLocation}, - { "nativeStart", "(I)V", (void *)android_media_MediaMuxer_start}, + { "nativeStart", "(J)V", (void *)android_media_MediaMuxer_start}, - { "nativeWriteSampleData", "(IILjava/nio/ByteBuffer;IIJI)V", + { "nativeWriteSampleData", "(JILjava/nio/ByteBuffer;IIJI)V", (void *)android_media_MediaMuxer_writeSampleData }, - { "nativeStop", "(I)V", (void *)android_media_MediaMuxer_stop}, + { "nativeStop", "(J)V", (void *)android_media_MediaMuxer_stop}, - { "nativeSetup", "(Ljava/io/FileDescriptor;I)I", + { "nativeSetup", "(Ljava/io/FileDescriptor;I)J", (void *)android_media_MediaMuxer_native_setup }, - { "nativeRelease", "(I)V", + { "nativeRelease", "(J)V", (void *)android_media_MediaMuxer_native_release }, }; @@ -252,12 +251,6 @@ int register_android_media_MediaMuxer(JNIEnv *env) { int err = AndroidRuntime::registerNativeMethods(env, "android/media/MediaMuxer", gMethods, NELEM(gMethods)); - jclass clazz = env->FindClass("android/media/MediaMuxer"); - CHECK(clazz != NULL); - - gFields.context = env->GetFieldID(clazz, "mNativeContext", "I"); - CHECK(gFields.context != NULL); - jclass byteBufClass = env->FindClass("java/nio/ByteBuffer"); CHECK(byteBufClass != NULL); diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 4be9cd6..9d0d5a6 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -133,21 +133,21 @@ void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *o static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); - MediaPlayer* const p = (MediaPlayer*)env->GetIntField(thiz, fields.context); + MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context); return sp<MediaPlayer>(p); } static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player) { Mutex::Autolock l(sLock); - sp<MediaPlayer> old = (MediaPlayer*)env->GetIntField(thiz, fields.context); + sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context); if (player.get()) { player->incStrong((void*)setMediaPlayer); } if (old != 0) { old->decStrong((void*)setMediaPlayer); } - env->SetIntField(thiz, fields.context, (int)player.get()); + env->SetLongField(thiz, fields.context, (jlong)player.get()); return old; } @@ -244,7 +244,7 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil static sp<IGraphicBufferProducer> getVideoSurfaceTexture(JNIEnv* env, jobject thiz) { - IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetIntField(thiz, fields.surface_texture); + IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture); return sp<IGraphicBufferProducer>(p); } @@ -293,7 +293,7 @@ setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlaye } } - env->SetIntField(thiz, fields.surface_texture, (int)new_st.get()); + env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get()); // This will fail if the media player has not been initialized yet. This // can be the case if setDisplay() on MediaPlayer.java has been called @@ -384,7 +384,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz) sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } const jboolean is_playing = mp->isPlaying(); @@ -393,7 +393,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz) } static void -android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec) +android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { @@ -404,7 +404,7 @@ android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec) process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL ); } -static int +static jint android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -418,10 +418,10 @@ android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz) w = 0; } ALOGV("getVideoWidth: %d", w); - return w; + return (jint) w; } -static int +static jint android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -435,11 +435,11 @@ android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz) h = 0; } ALOGV("getVideoHeight: %d", h); - return h; + return (jint) h; } -static int +static jint android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -450,10 +450,10 @@ android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz) int msec; process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL ); ALOGV("getCurrentPosition: %d (msec)", msec); - return msec; + return (jint) msec; } -static int +static jint android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -464,7 +464,7 @@ android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz) int msec; process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL ); ALOGV("getDuration: %d (msec)", msec); - return msec; + return (jint) msec; } static void @@ -480,7 +480,7 @@ android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz) } static void -android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, int streamtype) +android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype) { ALOGV("setAudioStreamType: %d", streamtype); sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -510,21 +510,21 @@ android_media_MediaPlayer_isLooping(JNIEnv *env, jobject thiz) sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } - return mp->isLooping(); + return mp->isLooping() ? JNI_TRUE : JNI_FALSE; } static void -android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, float leftVolume, float rightVolume) +android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume) { - ALOGV("setVolume: left %f right %f", leftVolume, rightVolume); + ALOGV("setVolume: left %f right %f", (float) leftVolume, (float) rightVolume); sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return; } - process_media_player_call( env, thiz, mp->setVolume(leftVolume, rightVolume), NULL, NULL ); + process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL ); } // Sends the request and reply parcels to the media player via the @@ -544,7 +544,7 @@ android_media_MediaPlayer_invoke(JNIEnv *env, jobject thiz, // Don't use process_media_player_call which use the async loop to // report errors, instead returns the status. - return media_player->invoke(*request, reply); + return (jint) media_player->invoke(*request, reply); } // Sends the new filter to the client. @@ -564,7 +564,7 @@ android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject r return UNKNOWN_ERROR; } - return media_player->setMetadataFilter(*filter); + return (jint) media_player->setMetadataFilter(*filter); } static jboolean @@ -574,14 +574,14 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update sp<MediaPlayer> media_player = getMediaPlayer(env, thiz); if (media_player == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } Parcel *metadata = parcelForJavaObject(env, reply); if (metadata == NULL ) { jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null"); - return false; + return JNI_FALSE; } metadata->freeData(); @@ -589,7 +589,11 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update // metadata. Note however that the parcel actually starts with the // return code so you should not rewind the parcel using // setDataPosition(0). - return media_player->getMetadata(update_only, apply_filter, metadata) == OK; + if (media_player->getMetadata(update_only, apply_filter, metadata) == OK) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } // This function gets some field IDs, which in turn causes class initialization. @@ -605,7 +609,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } @@ -616,7 +620,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env) return; } - fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I"); + fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J"); if (fields.surface_texture == NULL) { return; } @@ -696,7 +700,7 @@ static jint android_media_MediaPlayer_get_audio_session_id(JNIEnv *env, jobject return 0; } - return mp->getAudioSessionId(); + return (jint) mp->getAudioSessionId(); } static void @@ -733,7 +737,7 @@ android_media_MediaPlayer_pullBatteryData(JNIEnv *env, jobject thiz, jobject jav Parcel *reply = parcelForJavaObject(env, java_reply); - return service->pullBatteryData(reply); + return (jint) service->pullBatteryData(reply); } static jint @@ -772,7 +776,7 @@ android_media_MediaPlayer_setRetransmitEndpoint(JNIEnv *env, jobject thiz, jniThrowException(env, "java/lang/IllegalStateException", NULL); } - return ret; + return (jint) ret; } static void @@ -826,16 +830,19 @@ android_media_MediaPlayer_updateProxyConfig( jstring exclusionListObj = (jstring)env->CallObjectMethod( proxyProps, fields.proxyConfigGetExclusionList); - const char *exclusionList = - env->GetStringUTFChars(exclusionListObj, NULL); - if (host != NULL && exclusionListObj != NULL) { - thisplayer->updateProxyConfig(host, port, exclusionList); - } + const char *exclusionList = env->GetStringUTFChars(exclusionListObj, NULL); + + if (exclusionList != NULL) { + thisplayer->updateProxyConfig(host, port, exclusionList); - if (exclusionList != NULL) { - env->ReleaseStringUTFChars(exclusionListObj, exclusionList); - exclusionList = NULL; + env->ReleaseStringUTFChars(exclusionListObj, exclusionList); + exclusionList = NULL; + } else { + thisplayer->updateProxyConfig(host, port, ""); + } + } else if (host != NULL) { + thisplayer->updateProxyConfig(host, port, ""); } if (host != NULL) { diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp index 3fbb8ba..48a9132 100644 --- a/media/jni/android_media_MediaProfiles.cpp +++ b/media/jni/android_media_MediaProfiles.cpp @@ -48,7 +48,7 @@ static jint android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_file_formats"); - return sProfiles->getOutputFileFormats().size(); + return (jint) sProfiles->getOutputFileFormats().size(); } static jint @@ -119,7 +119,7 @@ static jint android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_audio_encoders"); - return sProfiles->getAudioEncoders().size(); + return (jint) sProfiles->getAudioEncoders().size(); } static jobject @@ -223,18 +223,18 @@ android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject th { ALOGV("native_has_camcorder_profile: %d %d", id, quality); if (!isCamcorderQualityKnown(quality)) { - return false; + return JNI_FALSE; } camcorder_quality q = static_cast<camcorder_quality>(quality); - return sProfiles->hasCamcorderProfile(id, q); + return sProfiles->hasCamcorderProfile(id, q) ? JNI_TRUE : JNI_FALSE; } static jint android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_video_decoders"); - return sProfiles->getVideoDecoders().size(); + return (jint) sProfiles->getVideoDecoders().size(); } static jint @@ -255,7 +255,7 @@ static jint android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz) { ALOGV("native_get_num_audio_decoders"); - return sProfiles->getAudioDecoders().size(); + return (jint) sProfiles->getAudioDecoders().size(); } static jint @@ -276,7 +276,7 @@ static jint android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId) { ALOGV("native_get_num_image_encoding_quality_levels"); - return sProfiles->getImageEncodingQualityLevels(cameraId).size(); + return (jint) sProfiles->getImageEncodingQualityLevels(cameraId).size(); } static jint @@ -284,7 +284,7 @@ android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env, { ALOGV("native_get_image_encoding_quality_level"); Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId); - if (index < 0 || index >= levels.size()) { + if (index < 0 || index >= (jint) levels.size()) { jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp index 9888591..0cfd2ff 100644 --- a/media/jni/android_media_MediaRecorder.cpp +++ b/media/jni/android_media_MediaRecorder.cpp @@ -128,21 +128,21 @@ static bool process_media_recorder_call(JNIEnv *env, status_t opStatus, const ch static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); - MediaRecorder* const p = (MediaRecorder*)env->GetIntField(thiz, fields.context); + MediaRecorder* const p = (MediaRecorder*)env->GetLongField(thiz, fields.context); return sp<MediaRecorder>(p); } static sp<MediaRecorder> setMediaRecorder(JNIEnv* env, jobject thiz, const sp<MediaRecorder>& recorder) { Mutex::Autolock l(sLock); - sp<MediaRecorder> old = (MediaRecorder*)env->GetIntField(thiz, fields.context); + sp<MediaRecorder> old = (MediaRecorder*)env->GetLongField(thiz, fields.context); if (recorder.get()) { recorder->incStrong(thiz); } if (old != 0) { old->decStrong(thiz); } - env->SetIntField(thiz, fields.context, (int)recorder.get()); + env->SetLongField(thiz, fields.context, (jlong)recorder.get()); return old; } @@ -334,14 +334,14 @@ android_media_MediaRecorder_prepare(JNIEnv *env, jobject thiz) process_media_recorder_call(env, mr->prepare(), "java/io/IOException", "prepare failed."); } -static int +static jint android_media_MediaRecorder_native_getMaxAmplitude(JNIEnv *env, jobject thiz) { ALOGV("getMaxAmplitude"); sp<MediaRecorder> mr = getMediaRecorder(env, thiz); int result = 0; process_media_recorder_call(env, mr->getMaxAmplitude(&result), "java/lang/RuntimeException", "getMaxAmplitude failed."); - return result; + return (jint) result; } static void @@ -392,7 +392,7 @@ android_media_MediaRecorder_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 4e3d14e..84028b7 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -226,12 +226,12 @@ private: static MediaScanner *getNativeScanner_l(JNIEnv* env, jobject thiz) { - return (MediaScanner *) env->GetIntField(thiz, fields.context); + return (MediaScanner *) env->GetLongField(thiz, fields.context); } static void setNativeScanner_l(JNIEnv* env, jobject thiz, MediaScanner *s) { - env->SetIntField(thiz, fields.context, (int)s); + env->SetLongField(thiz, fields.context, (jlong)s); } static void @@ -381,7 +381,7 @@ android_media_MediaScanner_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } @@ -398,7 +398,7 @@ android_media_MediaScanner_native_setup(JNIEnv *env, jobject thiz) return; } - env->SetIntField(thiz, fields.context, (int)mp); + env->SetLongField(thiz, fields.context, (jlong)mp); } static void diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp index f8fb144..4689867e 100644 --- a/media/jni/android_mtp_MtpDatabase.cpp +++ b/media/jni/android_mtp_MtpDatabase.cpp @@ -80,7 +80,7 @@ static jfieldID field_mStringValues; MtpDatabase* getMtpDatabase(JNIEnv *env, jobject database) { - return (MtpDatabase *)env->GetIntField(database, field_context); + return (MtpDatabase *)env->GetLongField(database, field_context); } // ---------------------------------------------------------------------------- @@ -1088,17 +1088,17 @@ static void android_mtp_MtpDatabase_setup(JNIEnv *env, jobject thiz) { MyMtpDatabase* database = new MyMtpDatabase(env, thiz); - env->SetIntField(thiz, field_context, (int)database); + env->SetLongField(thiz, field_context, (jlong)database); checkAndClearExceptionFromCallback(env, __FUNCTION__); } static void android_mtp_MtpDatabase_finalize(JNIEnv *env, jobject thiz) { - MyMtpDatabase* database = (MyMtpDatabase *)env->GetIntField(thiz, field_context); + MyMtpDatabase* database = (MyMtpDatabase *)env->GetLongField(thiz, field_context); database->cleanup(env); delete database; - env->SetIntField(thiz, field_context, 0); + env->SetLongField(thiz, field_context, 0); checkAndClearExceptionFromCallback(env, __FUNCTION__); } @@ -1230,7 +1230,7 @@ int register_android_mtp_MtpDatabase(JNIEnv *env) return -1; } - field_context = env->GetFieldID(clazz, "mNativeContext", "I"); + field_context = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_context == NULL) { ALOGE("Can't find MtpDatabase.mNativeContext"); return -1; diff --git a/media/jni/android_mtp_MtpDevice.cpp b/media/jni/android_mtp_MtpDevice.cpp index b61b66c..8e013a0 100644 --- a/media/jni/android_mtp_MtpDevice.cpp +++ b/media/jni/android_mtp_MtpDevice.cpp @@ -88,7 +88,7 @@ static jfieldID field_objectInfo_keywords; MtpDevice* get_device_from_object(JNIEnv* env, jobject javaDevice) { - return (MtpDevice*)env->GetIntField(javaDevice, field_context); + return (MtpDevice*)env->GetLongField(javaDevice, field_context); } static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) { @@ -106,15 +106,15 @@ android_mtp_MtpDevice_open(JNIEnv *env, jobject thiz, jstring deviceName, jint f { const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL); if (deviceNameStr == NULL) { - return false; + return JNI_FALSE; } MtpDevice* device = MtpDevice::open(deviceNameStr, fd); env->ReleaseStringUTFChars(deviceName, deviceNameStr); if (device) - env->SetIntField(thiz, field_context, (int)device); - return (device != NULL); + env->SetLongField(thiz, field_context, (jlong)device); + return (jboolean)(device != NULL); } static void @@ -124,7 +124,7 @@ android_mtp_MtpDevice_close(JNIEnv *env, jobject thiz) if (device) { device->close(); delete device; - env->SetIntField(thiz, field_context, 0); + env->SetLongField(thiz, field_context, 0); } } @@ -356,10 +356,11 @@ static jboolean android_mtp_MtpDevice_delete_object(JNIEnv *env, jobject thiz, jint object_id) { MtpDevice* device = get_device_from_object(env, thiz); - if (device) - return device->deleteObject(object_id); - else - return NULL; + if (device && device->deleteObject(object_id)) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } static jlong @@ -367,7 +368,7 @@ android_mtp_MtpDevice_get_parent(JNIEnv *env, jobject thiz, jint object_id) { MtpDevice* device = get_device_from_object(env, thiz); if (device) - return device->getParent(object_id); + return (jlong)device->getParent(object_id); else return -1; } @@ -377,7 +378,7 @@ android_mtp_MtpDevice_get_storage_id(JNIEnv *env, jobject thiz, jint object_id) { MtpDevice* device = get_device_from_object(env, thiz); if (device) - return device->getStorageID(object_id); + return (jlong)device->getStorageID(object_id); else return -1; } @@ -389,15 +390,15 @@ android_mtp_MtpDevice_import_file(JNIEnv *env, jobject thiz, jint object_id, jst if (device) { const char *destPathStr = env->GetStringUTFChars(dest_path, NULL); if (destPathStr == NULL) { - return false; + return JNI_FALSE; } - bool result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664); + jboolean result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664); env->ReleaseStringUTFChars(dest_path, destPathStr); return result; } - return false; + return JNI_FALSE; } // ---------------------------------------------------------------------------- @@ -618,7 +619,7 @@ int register_android_mtp_MtpDevice(JNIEnv *env) ALOGE("Can't find android/mtp/MtpDevice"); return -1; } - field_context = env->GetFieldID(clazz, "mNativeContext", "I"); + field_context = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_context == NULL) { ALOGE("Can't find MtpDevice.mNativeContext"); return -1; diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp index 5252a3a..9d7f1c2 100644 --- a/media/jni/android_mtp_MtpServer.cpp +++ b/media/jni/android_mtp_MtpServer.cpp @@ -53,7 +53,7 @@ static Mutex sMutex; extern MtpDatabase* getMtpDatabase(JNIEnv *env, jobject database); static inline MtpServer* getMtpServer(JNIEnv *env, jobject thiz) { - return (MtpServer*)env->GetIntField(thiz, field_MtpServer_nativeContext); + return (MtpServer*)env->GetLongField(thiz, field_MtpServer_nativeContext); } static void @@ -63,7 +63,7 @@ android_mtp_MtpServer_setup(JNIEnv *env, jobject thiz, jobject javaDatabase, jbo if (fd >= 0) { MtpServer* server = new MtpServer(fd, getMtpDatabase(env, javaDatabase), usePtp, AID_MEDIA_RW, 0664, 0775); - env->SetIntField(thiz, field_MtpServer_nativeContext, (int)server); + env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server); } else { ALOGE("could not open MTP driver, errno: %d", errno); } @@ -87,7 +87,7 @@ android_mtp_MtpServer_cleanup(JNIEnv *env, jobject thiz) MtpServer* server = getMtpServer(env, thiz); if (server) { delete server; - env->SetIntField(thiz, field_MtpServer_nativeContext, 0); + env->SetLongField(thiz, field_MtpServer_nativeContext, 0); } else { ALOGE("server is null in cleanup"); } @@ -226,7 +226,7 @@ int register_android_mtp_MtpServer(JNIEnv *env) ALOGE("Can't find android/mtp/MtpServer"); return -1; } - field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "I"); + field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "J"); if (field_MtpServer_nativeContext == NULL) { ALOGE("Can't find MtpServer.mNativeContext"); return -1; 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; diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp index d8099dd..d29fad3 100644 --- a/media/jni/mediaeditor/VideoEditorClasses.cpp +++ b/media/jni/mediaeditor/VideoEditorClasses.cpp @@ -609,7 +609,7 @@ VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(EffectSettings, EFFECT_SETTINGS_CLASS_NAME) VIDEOEDIT_JAVA_DEFINE_FIELDS(Engine) { - VIDEOEDIT_JAVA_FIELD_INIT("mManualEditContext", "I") + VIDEOEDIT_JAVA_FIELD_INIT("mManualEditContext", "J") }; VIDEOEDIT_JAVA_DEFINE_FIELD_CLASS(Engine, MANUAL_EDIT_ENGINE_CLASS_NAME) @@ -3096,7 +3096,7 @@ videoEditClasses_getContext( if (*pResult) { // Retrieve the context pointer. - pContext = (void *)pEnv->GetIntField(object, fieldIds.context); + pContext = (void *)pEnv->GetLongField(object, fieldIds.context); } // Return the context pointer. @@ -3132,15 +3132,15 @@ videoEditClasses_setContext( { // Set the context field. VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", - "The context value from JAVA before setting is = 0x%x", - pEnv->GetIntField(object, fieldIds.context)); + "The context value from JAVA before setting is = %p", + (void *)pEnv->GetLongField(object, fieldIds.context)); - pEnv->SetIntField(object, fieldIds.context, (int)pContext); - M4OSA_TRACE1_1("The context value in JNI is = 0x%x",pContext); + pEnv->SetLongField(object, fieldIds.context, (jlong)pContext); + M4OSA_TRACE1_1("The context value in JNI is = %p",pContext); VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES", - "The context value from JAVA after setting is = 0x%x", - pEnv->GetIntField(object, fieldIds.context)); + "The context value from JAVA after setting is = %p", + (void *)pEnv->GetLongField(object, fieldIds.context)); } } diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp index c1ad516..058012b 100644 --- a/media/jni/mediaeditor/VideoEditorMain.cpp +++ b/media/jni/mediaeditor/VideoEditorMain.cpp @@ -170,7 +170,7 @@ static void videoEditor_stopEncoding( static void videoEditor_release( JNIEnv* pEnv, jobject thiz); -static int videoEditor_getPixels( +static jint videoEditor_getPixels( JNIEnv* env, jobject thiz, jstring path, @@ -178,7 +178,7 @@ static int videoEditor_getPixels( M4OSA_UInt32 width, M4OSA_UInt32 height, M4OSA_UInt32 timeMS); -static int videoEditor_getPixelsList( +static jint videoEditor_getPixelsList( JNIEnv* env, jobject thiz, jstring path, @@ -209,7 +209,7 @@ videoEditor_populateSettings( jobject object, jobject audioSettingObject); -static int videoEditor_stopPreview(JNIEnv* pEnv, +static jint videoEditor_stopPreview(JNIEnv* pEnv, jobject thiz); static jobject @@ -218,7 +218,7 @@ videoEditor_getProperties( jobject thiz, jstring file); -static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jlong fromMs, @@ -231,7 +231,7 @@ static int videoEditor_registerManualEditMethods( static void jniPreviewProgressCallback(void* cookie, M4OSA_UInt32 msgType, void *argc); -static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jstring filePath, @@ -241,7 +241,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, jint surfaceHeight, jlong fromMs); -static int videoEditor_generateAudioWaveFormSync ( JNIEnv* pEnv, +static jint videoEditor_generateAudioWaveFormSync ( JNIEnv* pEnv, jobject thiz, jstring pcmfilePath, jstring outGraphfilePath, @@ -258,7 +258,7 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext, M4OSA_Char* infilePath, M4OSA_Char* pcmfilePath ); -static int +static jint videoEditor_generateClip( JNIEnv* pEnv, jobject thiz, @@ -572,7 +572,7 @@ static M4OSA_ERR checkClipVideoProfileAndLevel(M4DECODER_VideoDecoders *pDecoder return result; } -static int videoEditor_stopPreview(JNIEnv* pEnv, +static jint videoEditor_stopPreview(JNIEnv* pEnv, jobject thiz) { ManualEditContext* pContext = M4OSA_NULL; @@ -594,7 +594,7 @@ static int videoEditor_stopPreview(JNIEnv* pEnv, pContext->mOverlayFileName = NULL; } - return lastProgressTimeMs; + return (jint)lastProgressTimeMs; } static void videoEditor_clearSurface(JNIEnv* pEnv, @@ -654,7 +654,7 @@ static void videoEditor_clearSurface(JNIEnv* pEnv, } -static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jlong fromMs, @@ -976,10 +976,10 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, free(yuvPlane); } - return tnTimeMs; + return (jint)tnTimeMs; } -static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, +static jint videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, jobject thiz, jobject mSurface, jstring filePath, @@ -1033,7 +1033,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, /* get thumbnail*/ result = ThumbnailOpen(&tnContext,(const M4OSA_Char*)pString, M4OSA_TRUE); if (result != M4NO_ERROR || tnContext == M4OSA_NULL) { - return timeMs; + return (jint)timeMs; } framesizeYuv = ((frameWidth)*(frameHeight)*1.5); @@ -1046,7 +1046,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, ThumbnailClose(tnContext); pMessage = videoEditJava_getErrorName(M4ERR_ALLOC); jniThrowException(pEnv, "java/lang/RuntimeException", pMessage); - return timeMs; + return (jint)timeMs; } result = ThumbnailGetPixels16(tnContext, (M4OSA_Int16 *)pixelArray, @@ -1055,7 +1055,7 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, if (result != M4NO_ERROR) { free(pixelArray); ThumbnailClose(tnContext); - return fromMs; + return (jint)fromMs; } #ifdef DUMPTOFILESYSTEM @@ -1131,10 +1131,10 @@ static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv, pEnv->ReleaseStringUTFChars(filePath, pString); } - return timeMs; + return (jint)timeMs; } -int videoEditor_generateAudioRawFile( JNIEnv* pEnv, +jint videoEditor_generateAudioRawFile( JNIEnv* pEnv, jobject thiz, jstring infilePath, jstring pcmfilePath) @@ -1178,7 +1178,7 @@ int videoEditor_generateAudioRawFile( JNIEnv* pEnv, pEnv->ReleaseStringUTFChars(pcmfilePath, pStringOutPCMFilePath); } - return result; + return (jint)result; } M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext, @@ -2182,7 +2182,7 @@ videoEditor_getProperties( return object; } -static int videoEditor_getPixels( +static jint videoEditor_getPixels( JNIEnv* env, jobject thiz, jstring path, @@ -2234,10 +2234,10 @@ static int videoEditor_getPixels( env->ReleaseStringUTFChars(path, pString); } - return timeMS; + return (jint)timeMS; } -static int videoEditor_getPixelsList( +static jint videoEditor_getPixelsList( JNIEnv* env, jobject thiz, jstring path, @@ -2257,7 +2257,7 @@ static int videoEditor_getPixelsList( const char *pString = env->GetStringUTFChars(path, NULL); if (pString == M4OSA_NULL) { jniThrowException(env, "java/lang/RuntimeException", "Input string null"); - return M4ERR_ALLOC; + return (jint)M4ERR_ALLOC; } err = ThumbnailOpen(&mContext,(const M4OSA_Char*)pString, M4OSA_FALSE); @@ -2266,7 +2266,7 @@ static int videoEditor_getPixelsList( if (pString != NULL) { env->ReleaseStringUTFChars(path, pString); } - return err; + return (jint)err; } jlong duration = (endTime - startTime); @@ -2307,7 +2307,7 @@ static int videoEditor_getPixelsList( "ThumbnailGetPixels32 failed"); } - return err; + return (jint)err; } static M4OSA_ERR @@ -2892,7 +2892,7 @@ M4OSA_ERR videoEditor_processClip( } /*+ PROGRESS CB */ -static int +static jint videoEditor_generateClip( JNIEnv* pEnv, jobject thiz, @@ -2934,7 +2934,7 @@ videoEditor_generateClip( } ALOGV("videoEditor_generateClip END 0x%x", (unsigned int) result); - return result; + return (jint)result; } static void @@ -3556,7 +3556,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL, return err; } -static int videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz, +static jint videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz, jstring pcmfilePath, jstring outGraphfilePath, jint frameDuration, jint channels, @@ -3619,7 +3619,7 @@ out: VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", "videoEditor_generateAudioWaveFormSync pContext->bSkipState "); - return result; + return (jint)result; } /******** End Audio Graph *******/ diff --git a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp index 2604850..9cc55ab 100644 --- a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp +++ b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp @@ -34,11 +34,11 @@ static struct fields_t { } fields; static inline SoundPool* MusterSoundPool(JNIEnv *env, jobject thiz) { - return (SoundPool*)env->GetIntField(thiz, fields.mNativeContext); + return (SoundPool*)env->GetLongField(thiz, fields.mNativeContext); } // ---------------------------------------------------------------------------- -static int +static jint android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstring path, jint priority) { ALOGV("android_media_SoundPool_SoundPoolImpl_load_URL"); @@ -50,29 +50,29 @@ android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstrin const char* s = env->GetStringUTFChars(path, NULL); int id = ap->load(s, priority); env->ReleaseStringUTFChars(path, s); - return id; + return (jint) id; } -static int +static jint android_media_SoundPool_SoundPoolImpl_load_FD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length, jint priority) { ALOGV("android_media_SoundPool_SoundPoolImpl_load_FD"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return 0; - return ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor), + return (jint) ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor), int64_t(offset), int64_t(length), int(priority)); } -static bool +static jboolean android_media_SoundPool_SoundPoolImpl_unload(JNIEnv *env, jobject thiz, jint sampleID) { ALOGV("android_media_SoundPool_SoundPoolImpl_unload\n"); SoundPool *ap = MusterSoundPool(env, thiz); - if (ap == NULL) return 0; - return ap->unload(sampleID); + if (ap == NULL) return JNI_FALSE; + return ap->unload(sampleID) ? JNI_TRUE : JNI_FALSE; } -static int +static jint android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampleID, jfloat leftVolume, jfloat rightVolume, jint priority, jint loop, jfloat rate) @@ -80,7 +80,7 @@ android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampl ALOGV("android_media_SoundPool_SoundPoolImpl_play\n"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return 0; - return ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate); + return (jint) ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate); } static void @@ -130,22 +130,22 @@ android_media_SoundPool_SoundPoolImpl_stop(JNIEnv *env, jobject thiz, jint chann static void android_media_SoundPool_SoundPoolImpl_setVolume(JNIEnv *env, jobject thiz, jint channelID, - float leftVolume, float rightVolume) + jfloat leftVolume, jfloat rightVolume) { ALOGV("android_media_SoundPool_SoundPoolImpl_setVolume"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return; - ap->setVolume(channelID, leftVolume, rightVolume); + ap->setVolume(channelID, (float) leftVolume, (float) rightVolume); } static void android_media_SoundPool_SoundPoolImpl_setPriority(JNIEnv *env, jobject thiz, jint channelID, - int priority) + jint priority) { ALOGV("android_media_SoundPool_SoundPoolImpl_setPriority"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return; - ap->setPriority(channelID, priority); + ap->setPriority(channelID, (int) priority); } static void @@ -160,12 +160,12 @@ android_media_SoundPool_SoundPoolImpl_setLoop(JNIEnv *env, jobject thiz, jint ch static void android_media_SoundPool_SoundPoolImpl_setRate(JNIEnv *env, jobject thiz, jint channelID, - float rate) + jfloat rate) { ALOGV("android_media_SoundPool_SoundPoolImpl_setRate"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return; - ap->setRate(channelID, rate); + ap->setRate(channelID, (float) rate); } static void android_media_callback(SoundPoolEvent event, SoundPool* soundPool, void* user) @@ -185,7 +185,7 @@ android_media_SoundPool_SoundPoolImpl_native_setup(JNIEnv *env, jobject thiz, jo } // save pointer to SoundPool C++ object in opaque field in Java object - env->SetIntField(thiz, fields.mNativeContext, (int)ap); + env->SetLongField(thiz, fields.mNativeContext, (jlong) ap); // set callback with weak reference jobject globalWeakRef = env->NewGlobalRef(weakRef); @@ -208,7 +208,7 @@ android_media_SoundPool_SoundPoolImpl_release(JNIEnv *env, jobject thiz) // clear callback and native context ap->setCallback(NULL, NULL); - env->SetIntField(thiz, fields.mNativeContext, 0); + env->SetLongField(thiz, fields.mNativeContext, 0); delete ap; } } @@ -299,7 +299,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) goto bail; } - fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.mNativeContext == NULL) { ALOGE("Can't find SoundPoolImpl.mNativeContext"); goto bail; |