Merge "fix memory leak in initilization and finalization" into sc-dev am: d2b280408b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15238059

Change-Id: I03ba005451e105265cf7bcf6455153b368bb575d
This commit is contained in:
Henry Fang
2021-07-09 15:50:47 +00:00
committed by Automerger Merge Worker

View File

@@ -339,6 +339,12 @@ MediaEvent::~MediaEvent() {
if (pC2Buffer != NULL) {
pC2Buffer->unregisterOnDestroyNotify(&DestroyCallback, this);
}
if (mLinearBlockObj != NULL) {
env->DeleteWeakGlobalRef(mLinearBlockObj);
mLinearBlockObj = NULL;
}
mFilterClient = NULL;
}
@@ -2450,7 +2456,10 @@ static sp<JTuner> setTuner(JNIEnv *env, jobject thiz, const sp<JTuner> &tuner) {
if (old != NULL) {
old->decStrong(thiz);
}
env->SetLongField(thiz, gFields.tunerContext, (jlong)tuner.get());
if (tuner != NULL) {
env->SetLongField(thiz, gFields.tunerContext, (jlong)tuner.get());
}
return old;
}
@@ -4042,6 +4051,7 @@ static jint android_media_tv_Tuner_open_demux(JNIEnv* env, jobject thiz, jint ha
static jint android_media_tv_Tuner_close_tuner(JNIEnv* env, jobject thiz) {
sp<JTuner> tuner = getTuner(env, thiz);
setTuner(env, thiz, NULL);
return (jint) tuner->close();
}