Fix issue which Ion handle are free twice.
bug: 162083545 Test: Manual Change-Id: I3a53fe949ecfdff4614a44cc1ddecdbeaa583dd8
This commit is contained in:
@@ -337,7 +337,10 @@ jobject MediaEvent::getLinearBlock() {
|
|||||||
}
|
}
|
||||||
mIonHandle = new C2HandleIon(dup(mAvHandle->data[0]), mDataLength);
|
mIonHandle = new C2HandleIon(dup(mAvHandle->data[0]), mDataLength);
|
||||||
std::shared_ptr<C2LinearBlock> block = _C2BlockFactory::CreateLinearBlock(mIonHandle);
|
std::shared_ptr<C2LinearBlock> block = _C2BlockFactory::CreateLinearBlock(mIonHandle);
|
||||||
|
if (block != nullptr) {
|
||||||
|
// CreateLinearBlock delete mIonHandle after it create block successfully.
|
||||||
|
// ToDo: coordinate who is response to delete mIonHandle
|
||||||
|
mIonHandle = NULL;
|
||||||
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||||
std::unique_ptr<JMediaCodecLinearBlock> context{new JMediaCodecLinearBlock};
|
std::unique_ptr<JMediaCodecLinearBlock> context{new JMediaCodecLinearBlock};
|
||||||
context->mBlock = block;
|
context->mBlock = block;
|
||||||
@@ -364,6 +367,14 @@ jobject MediaEvent::getLinearBlock() {
|
|||||||
mLinearBlockObj = env->NewWeakGlobalRef(linearBlock);
|
mLinearBlockObj = env->NewWeakGlobalRef(linearBlock);
|
||||||
mAvHandleRefCnt++;
|
mAvHandleRefCnt++;
|
||||||
return mLinearBlockObj;
|
return mLinearBlockObj;
|
||||||
|
} else {
|
||||||
|
native_handle_close(const_cast<native_handle_t*>(
|
||||||
|
reinterpret_cast<const native_handle_t*>(mIonHandle)));
|
||||||
|
native_handle_delete(const_cast<native_handle_t*>(
|
||||||
|
reinterpret_cast<const native_handle_t*>(mIonHandle)));
|
||||||
|
mIonHandle = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MediaEvent::getAudioHandle() {
|
uint64_t MediaEvent::getAudioHandle() {
|
||||||
|
|||||||
Reference in New Issue
Block a user