diff options
author | Insun Kang <insun@google.com> | 2012-07-10 12:47:03 +0900 |
---|---|---|
committer | Insun Kang <insun@google.com> | 2012-07-10 22:23:01 +0900 |
commit | 333c09945e7399c6a2b1f4d9fdf981508e38db52 (patch) | |
tree | a74c4394795669e0e1e0df9f72c01d96b7577d28 /media | |
parent | 1ab2edbcff94d53856a87010e35ffa50ce4c0502 (diff) | |
download | frameworks_base-333c09945e7399c6a2b1f4d9fdf981508e38db52.zip frameworks_base-333c09945e7399c6a2b1f4d9fdf981508e38db52.tar.gz frameworks_base-333c09945e7399c6a2b1f4d9fdf981508e38db52.tar.bz2 |
Changed to obtain a parcel in each notify() call in jni.
Change-Id: I5faf0f5d1fdf76a5b4bd1cff37aa58df79d18e85
related-to-bug: 6785452
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaPlayer.java | 1 | ||||
-rw-r--r-- | media/jni/android_media_MediaPlayer.cpp | 12 |
2 files changed, 5 insertions, 8 deletions
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index e76d25a..870a4a9 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -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); } } diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index de22e09..c2a6889 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -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, |