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

Commit 3d6b936f authored by Sungtak Lee's avatar Sungtak Lee Committed by Automerger Merge Worker
Browse files

CCodec: Delay stop using surface until the end of stop() am: d964e2eb am: e967a3e8

parents dce6b55a e967a3e8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1899,6 +1899,7 @@ void CCodec::stop() {
        comp = state->comp;
    }
    status_t err = comp->stop();
    mChannel->stopUseOutputSurface();
    if (err != C2_OK) {
        // TODO: convert err into status_t
        mCallback->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
@@ -1972,6 +1973,7 @@ void CCodec::initiateRelease(bool sendCallback /* = true */) {
    }

    mChannel->reset();
    mChannel->stopUseOutputSurface();
    // thiz holds strong ref to this while the thread is running.
    sp<CCodec> thiz(this);
    std::thread([thiz, sendCallback] { thiz->release(sendCallback); }).detach();
+11 −8
Original line number Diff line number Diff line
@@ -1578,6 +1578,17 @@ void CCodecBufferChannel::stop() {
    mFirstValidFrameIndex = mFrameIndex.load(std::memory_order_relaxed);
}

void CCodecBufferChannel::stopUseOutputSurface() {
    if (mOutputSurface.lock()->surface) {
        C2BlockPool::local_id_t outputPoolId;
        {
            Mutexed<BlockPools>::Locked pools(mBlockPools);
            outputPoolId = pools->outputPoolId;
        }
        if (mComponent) mComponent->stopUsingOutputSurface(outputPoolId);
    }
}

void CCodecBufferChannel::reset() {
    stop();
    if (mInputSurface != nullptr) {
@@ -1593,14 +1604,6 @@ void CCodecBufferChannel::reset() {
        Mutexed<Output>::Locked output(mOutput);
        output->buffers.reset();
    }
    if (mOutputSurface.lock()->surface) {
        C2BlockPool::local_id_t outputPoolId;
        {
            Mutexed<BlockPools>::Locked pools(mBlockPools);
            outputPoolId = pools->outputPoolId;
        }
        mComponent->stopUsingOutputSurface(outputPoolId);
    }
}

void CCodecBufferChannel::release() {
+6 −0
Original line number Diff line number Diff line
@@ -148,6 +148,12 @@ public:
    status_t requestInitialInputBuffers(
            std::map<size_t, sp<MediaCodecBuffer>> &&clientInputBuffers);

    /**
     * Stop using buffers of the current output surface for other Codec
     * instances to use the surface safely.
     */
    void stopUseOutputSurface();

    /**
     * Stop queueing buffers to the component. This object should never queue
     * buffers after this call, until start() is called.