Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b7054b9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix issue which Ion handle are free twice." am: d70c636a am: def12823

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib0e63d4092fc030f316b5c11261b3a37adb9b5c0
parents fe071a9d def12823
Loading
Loading
Loading
Loading
+38 −27
Original line number Diff line number Diff line
@@ -337,7 +337,10 @@ jobject MediaEvent::getLinearBlock() {
    }
    mIonHandle = new C2HandleIon(dup(mAvHandle->data[0]), mDataLength);
    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();
        std::unique_ptr<JMediaCodecLinearBlock> context{new JMediaCodecLinearBlock};
        context->mBlock = block;
@@ -364,6 +367,14 @@ jobject MediaEvent::getLinearBlock() {
        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;
    }
}

uint64_t MediaEvent::getAudioHandle() {