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:
@@ -171,6 +171,12 @@ static int IP_V6_LENGTH = 16;
|
|||||||
|
|
||||||
void DestroyCallback(const C2Buffer * /* buf */, void *arg) {
|
void DestroyCallback(const C2Buffer * /* buf */, void *arg) {
|
||||||
android::sp<android::MediaEvent> event = (android::MediaEvent *)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->mAvHandleRefCnt--;
|
||||||
event->finalize();
|
event->finalize();
|
||||||
}
|
}
|
||||||
@@ -182,6 +188,12 @@ LnbCallback::LnbCallback(jobject lnbObj, LnbId id) : mId(id) {
|
|||||||
mLnb = env->NewWeakGlobalRef(lnbObj);
|
mLnb = env->NewWeakGlobalRef(lnbObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LnbCallback::~LnbCallback() {
|
||||||
|
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||||
|
env->DeleteWeakGlobalRef(mLnb);
|
||||||
|
mLnb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Return<void> LnbCallback::onEvent(LnbEventType lnbEventType) {
|
Return<void> LnbCallback::onEvent(LnbEventType lnbEventType) {
|
||||||
ALOGD("LnbCallback::onEvent, type=%d", lnbEventType);
|
ALOGD("LnbCallback::onEvent, type=%d", lnbEventType);
|
||||||
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||||
@@ -305,6 +317,7 @@ MediaEvent::MediaEvent(sp<IFilter> iFilter, hidl_handle avHandle,
|
|||||||
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||||
mMediaEventObj = env->NewWeakGlobalRef(obj);
|
mMediaEventObj = env->NewWeakGlobalRef(obj);
|
||||||
mAvHandle = native_handle_clone(avHandle.getNativeHandle());
|
mAvHandle = native_handle_clone(avHandle.getNativeHandle());
|
||||||
|
mLinearBlockObj = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaEvent::~MediaEvent() {
|
MediaEvent::~MediaEvent() {
|
||||||
@@ -367,7 +380,7 @@ jobject MediaEvent::getLinearBlock() {
|
|||||||
true);
|
true);
|
||||||
mLinearBlockObj = env->NewWeakGlobalRef(linearBlock);
|
mLinearBlockObj = env->NewWeakGlobalRef(linearBlock);
|
||||||
mAvHandleRefCnt++;
|
mAvHandleRefCnt++;
|
||||||
return mLinearBlockObj;
|
return linearBlock;
|
||||||
} else {
|
} else {
|
||||||
native_handle_close(const_cast<native_handle_t*>(
|
native_handle_close(const_cast<native_handle_t*>(
|
||||||
reinterpret_cast<const native_handle_t*>(mIonHandle)));
|
reinterpret_cast<const native_handle_t*>(mIonHandle)));
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ namespace android {
|
|||||||
|
|
||||||
struct LnbCallback : public ILnbCallback {
|
struct LnbCallback : public ILnbCallback {
|
||||||
LnbCallback(jweak tunerObj, LnbId id);
|
LnbCallback(jweak tunerObj, LnbId id);
|
||||||
|
~LnbCallback();
|
||||||
virtual Return<void> onEvent(LnbEventType lnbEventType);
|
virtual Return<void> onEvent(LnbEventType lnbEventType);
|
||||||
virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
|
virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
|
||||||
jweak mLnb;
|
jweak mLnb;
|
||||||
|
|||||||
Reference in New Issue
Block a user