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

Commit def12823 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

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If9aae1d357e0edc2c79270cc075a7bdbfbb0c104
parents e8aad7ca d70c636a
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() {