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

Commit 8f172778 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Reapply "Codec2Client: use IProducerListener for Codec2 hidl1.2"" into main

parents 444cbbba 6700cc9f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2372,7 +2372,7 @@ void Codec2Client::Component::stopUsingOutputSurface(

void Codec2Client::Component::onBufferReleasedFromOutputSurface(
        uint32_t generation) {
    (void) generation;
    mOutputBufferQueue->onBufferReleased(generation);
}

c2_status_t Codec2Client::Component::connectToInputSurface(
+4 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ struct OutputBufferQueue {
            const BnGraphicBufferProducer::QueueBufferInput& input,
            BnGraphicBufferProducer::QueueBufferOutput* output);

    // Nofify a buffer is released from the output surface. If HAL ver is 1.2
    // update the number of dequeueable/allocatable buffers.
    void onBufferReleased(uint32_t generation);

    // Retrieve frame event history from the output surface.
    void pollForRenderedFrames(FrameEventHistoryDelta* delta);

+34 −6
Original line number Diff line number Diff line
@@ -441,10 +441,12 @@ status_t OutputBufferQueue::outputBuffer(
            status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
                                         input, output);
            if (status == OK) {
                if (output->bufferReplaced) {
                    syncVar->lock();
                    syncVar->notifyQueuedLocked();
                    syncVar->unlock();
                }
            }
        } else {
            status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
                                         input, output);
@@ -496,10 +498,12 @@ status_t OutputBufferQueue::outputBuffer(
        status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
                                                  input, output);
        if (status == OK) {
            if (output->bufferReplaced) {
                syncVar->lock();
                syncVar->notifyQueuedLocked();
                syncVar->unlock();
            }
        }
    } else {
        status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
                                                  input, output);
@@ -514,6 +518,30 @@ status_t OutputBufferQueue::outputBuffer(
    return OK;
}

void OutputBufferQueue::onBufferReleased(uint32_t generation) {
    std::shared_ptr<C2SurfaceSyncMemory> syncMem;
    sp<IGraphicBufferProducer> outputIgbp;
    uint32_t outputGeneration = 0;
    {
        std::unique_lock<std::mutex> l(mMutex);
        if (mStopped) {
            return;
        }
        outputIgbp = mIgbp;
        outputGeneration = mGeneration;
        syncMem = mSyncMem;
    }

    if (outputIgbp && generation == outputGeneration) {
        auto syncVar = syncMem ? syncMem->mem() : nullptr;
        if (syncVar) {
            syncVar->lock();
            syncVar->notifyQueuedLocked();
            syncVar->unlock();
        }
    }
}

void OutputBufferQueue::pollForRenderedFrames(FrameEventHistoryDelta* delta) {
    if (mIgbp) {
        mIgbp->getFrameTimestamps(delta);
+8 −1
Original line number Diff line number Diff line
@@ -1131,7 +1131,14 @@ void CCodecBufferChannel::pollForRenderedBuffers() {
}

void CCodecBufferChannel::onBufferReleasedFromOutputSurface(uint32_t generation) {
    mComponent->onBufferReleasedFromOutputSurface(generation);
    // Note: Since this is called asynchronously from IProducerListener not
    // knowing the internal state of CCodec/CCodecBufferChannel,
    // prevent mComponent from being destroyed by holding the shared reference
    // during this interface being executed.
    std::shared_ptr<Codec2Client::Component> comp = mComponent;
    if (comp) {
        comp->onBufferReleasedFromOutputSurface(generation);
    }
}

status_t CCodecBufferChannel::discardBuffer(const sp<MediaCodecBuffer> &buffer) {