Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1a0a53e authored by James Dong's avatar James Dong Committed by Android Git Automerger
Browse files

am 5d478b9c: Merge "Changed to obtain a parcel in each notify() call in jni." into jb-dev

* commit '5d478b9c':
  Changed to obtain a parcel in each notify() call in jni.
parents d173b10a 5d478b9c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2026,6 +2026,7 @@ public class MediaPlayer
                    if (msg.obj instanceof Parcel) {
                        Parcel parcel = (Parcel)msg.obj;
                        TimedText text = new TimedText(parcel);
                        parcel.recycle();
                        mOnTimedTextListener.onTimedText(mMediaPlayer, text);
                    }
                }
+4 −8
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@ private:
    JNIMediaPlayerListener();
    jclass      mClass;     // Reference to MediaPlayer class
    jobject     mObject;    // Weak ref to MediaPlayer Java object to call on
    jobject     mParcel;
};

JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz)
@@ -91,7 +90,6 @@ JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobjec
    // We use a weak reference so the MediaPlayer object can be garbage collected.
    // The reference is only used as a proxy for callbacks.
    mObject  = env->NewGlobalRef(weak_thiz);
    mParcel = env->NewGlobalRef(createJavaParcelObject(env));
}

JNIMediaPlayerListener::~JNIMediaPlayerListener()
@@ -100,20 +98,18 @@ JNIMediaPlayerListener::~JNIMediaPlayerListener()
    JNIEnv *env = AndroidRuntime::getJNIEnv();
    env->DeleteGlobalRef(mObject);
    env->DeleteGlobalRef(mClass);

    recycleJavaParcelObject(env, mParcel);
    env->DeleteGlobalRef(mParcel);
}

void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *obj)
{
    JNIEnv *env = AndroidRuntime::getJNIEnv();
    if (obj && obj->dataSize() > 0) {
        if (mParcel != NULL) {
            Parcel* nativeParcel = parcelForJavaObject(env, mParcel);
        jobject jParcel = createJavaParcelObject(env);
        if (jParcel != NULL) {
            Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
            nativeParcel->setData(obj->data(), obj->dataSize());
            env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
                    msg, ext1, ext2, mParcel);
                    msg, ext1, ext2, jParcel);
        }
    } else {
        env->CallStaticVoidMethod(mClass, fields.post_event, mObject,