free weakref to linearblock when it is destroy
bug: 168331789 Test: Manual Change-Id: Iee1b2618bd5c970b728dbc0301b84ff43debde58 Merged-In: Iee1b2618bd5c970b728dbc0301b84ff43debde58
This commit is contained in:
@@ -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)));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user