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

Commit 24d2fa62 authored by Henry Fang's avatar Henry Fang Committed by Android (Google) Code Review
Browse files

Merge "Fix issue which Ion handle are free twice."

parents e0007d96 cc7d12ea
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() {