Merge "Fix issue which Ion handle are free twice." am: d70c636ad4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1536907 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: If9aae1d357e0edc2c79270cc075a7bdbfbb0c104
This commit is contained in:
@@ -337,33 +337,44 @@ 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) {
|
||||||
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
// CreateLinearBlock delete mIonHandle after it create block successfully.
|
||||||
std::unique_ptr<JMediaCodecLinearBlock> context{new JMediaCodecLinearBlock};
|
// ToDo: coordinate who is response to delete mIonHandle
|
||||||
context->mBlock = block;
|
mIonHandle = NULL;
|
||||||
std::shared_ptr<C2Buffer> pC2Buffer = context->toC2Buffer(0, mDataLength);
|
JNIEnv *env = AndroidRuntime::getJNIEnv();
|
||||||
context->mBuffer = pC2Buffer;
|
std::unique_ptr<JMediaCodecLinearBlock> context{new JMediaCodecLinearBlock};
|
||||||
mC2Buffer = pC2Buffer;
|
context->mBlock = block;
|
||||||
if (mAvHandle->numInts > 0) {
|
std::shared_ptr<C2Buffer> pC2Buffer = context->toC2Buffer(0, mDataLength);
|
||||||
// use first int in the native_handle as the index
|
context->mBuffer = pC2Buffer;
|
||||||
int index = mAvHandle->data[mAvHandle->numFds];
|
mC2Buffer = pC2Buffer;
|
||||||
std::shared_ptr<C2Param> c2param = std::make_shared<C2DataIdInfo>(index, mDataId);
|
if (mAvHandle->numInts > 0) {
|
||||||
std::shared_ptr<C2Info> info(std::static_pointer_cast<C2Info>(c2param));
|
// use first int in the native_handle as the index
|
||||||
pC2Buffer->setInfo(info);
|
int index = mAvHandle->data[mAvHandle->numFds];
|
||||||
|
std::shared_ptr<C2Param> c2param = std::make_shared<C2DataIdInfo>(index, mDataId);
|
||||||
|
std::shared_ptr<C2Info> info(std::static_pointer_cast<C2Info>(c2param));
|
||||||
|
pC2Buffer->setInfo(info);
|
||||||
|
}
|
||||||
|
pC2Buffer->registerOnDestroyNotify(&DestroyCallback, this);
|
||||||
|
jobject linearBlock =
|
||||||
|
env->NewObject(
|
||||||
|
env->FindClass("android/media/MediaCodec$LinearBlock"),
|
||||||
|
gFields.linearBlockInitID);
|
||||||
|
env->CallVoidMethod(
|
||||||
|
linearBlock,
|
||||||
|
gFields.linearBlockSetInternalStateID,
|
||||||
|
(jlong)context.release(),
|
||||||
|
true);
|
||||||
|
mLinearBlockObj = env->NewWeakGlobalRef(linearBlock);
|
||||||
|
mAvHandleRefCnt++;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
pC2Buffer->registerOnDestroyNotify(&DestroyCallback, this);
|
|
||||||
jobject linearBlock =
|
|
||||||
env->NewObject(
|
|
||||||
env->FindClass("android/media/MediaCodec$LinearBlock"),
|
|
||||||
gFields.linearBlockInitID);
|
|
||||||
env->CallVoidMethod(
|
|
||||||
linearBlock,
|
|
||||||
gFields.linearBlockSetInternalStateID,
|
|
||||||
(jlong)context.release(),
|
|
||||||
true);
|
|
||||||
mLinearBlockObj = env->NewWeakGlobalRef(linearBlock);
|
|
||||||
mAvHandleRefCnt++;
|
|
||||||
return mLinearBlockObj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MediaEvent::getAudioHandle() {
|
uint64_t MediaEvent::getAudioHandle() {
|
||||||
|
|||||||
Reference in New Issue
Block a user