Merge "free weakref to linearblock when it is destroy" am: a4f4128f10

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ibe28578ed7dc7fd22abfe7520c450e350d5c8090
This commit is contained in:
Treehugger Robot
2020-12-31 00:01:49 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 1 deletions

View File

@@ -171,6 +171,12 @@ static int IP_V6_LENGTH = 16;
void DestroyCallback(const C2Buffer * /* buf */, void *arg) {
android::sp<android::MediaEvent> event = (android::MediaEvent *)arg;
if (event->mLinearBlockObj != NULL) {
JNIEnv *env = android::AndroidRuntime::getJNIEnv();
env->DeleteWeakGlobalRef(event->mLinearBlockObj);
event->mLinearBlockObj = NULL;
}
event->mAvHandleRefCnt--;
event->finalize();
}
@@ -182,6 +188,12 @@ LnbCallback::LnbCallback(jobject lnbObj, LnbId id) : mId(id) {
mLnb = env->NewWeakGlobalRef(lnbObj);
}
LnbCallback::~LnbCallback() {
JNIEnv *env = AndroidRuntime::getJNIEnv();
env->DeleteWeakGlobalRef(mLnb);
mLnb = NULL;
}
Return<void> LnbCallback::onEvent(LnbEventType lnbEventType) {
ALOGD("LnbCallback::onEvent, type=%d", lnbEventType);
JNIEnv *env = AndroidRuntime::getJNIEnv();
@@ -305,6 +317,7 @@ MediaEvent::MediaEvent(sp<IFilter> iFilter, hidl_handle avHandle,
JNIEnv *env = AndroidRuntime::getJNIEnv();
mMediaEventObj = env->NewWeakGlobalRef(obj);
mAvHandle = native_handle_clone(avHandle.getNativeHandle());
mLinearBlockObj = NULL;
}
MediaEvent::~MediaEvent() {
@@ -367,7 +380,7 @@ jobject MediaEvent::getLinearBlock() {
true);
mLinearBlockObj = env->NewWeakGlobalRef(linearBlock);
mAvHandleRefCnt++;
return mLinearBlockObj;
return linearBlock;
} else {
native_handle_close(const_cast<native_handle_t*>(
reinterpret_cast<const native_handle_t*>(mIonHandle)));

View File

@@ -73,6 +73,7 @@ namespace android {
struct LnbCallback : public ILnbCallback {
LnbCallback(jweak tunerObj, LnbId id);
~LnbCallback();
virtual Return<void> onEvent(LnbEventType lnbEventType);
virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
jweak mLnb;