summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-07-18 20:18:41 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-07-18 20:18:41 -0700
commitc64c1cbef4d52cbd82c38485be3270eddf743f98 (patch)
treed804a91c887c6edd749e012a1c3158d081f8058c /media
parentee443b2819e70718ef98eaca65f6c8f1e0fcd398 (diff)
parentd1a0a53eec141b615697652b3a8907a60298a414 (diff)
downloadframeworks_base-c64c1cbef4d52cbd82c38485be3270eddf743f98.zip
frameworks_base-c64c1cbef4d52cbd82c38485be3270eddf743f98.tar.gz
frameworks_base-c64c1cbef4d52cbd82c38485be3270eddf743f98.tar.bz2
am d1a0a53e: am 5d478b9c: Merge "Changed to obtain a parcel in each notify() call in jni." into jb-dev
* commit 'd1a0a53eec141b615697652b3a8907a60298a414': Changed to obtain a parcel in each notify() call in jni.
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MediaPlayer.java1
-rw-r--r--media/jni/android_media_MediaPlayer.cpp12
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,