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

Commit d8a822db authored by Sungtak Lee's avatar Sungtak Lee
Browse files

MediaCodec: handle consumer side buffer attach to Surface

Currently MediaCodec handles buffer being released from Surface. Handle
buffer being attached to Surface also.

Bug: 353202582
Flag: EXEMPT bugfix
Change-Id: I5300086f7ae36d3b5e358e62e596001ecd32f572
parent dbf724aa
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2556,6 +2556,19 @@ void Codec2Client::Component::onBufferReleasedFromOutputSurface(
    mOutputBufferQueue->onBufferReleased(generation);
}

void Codec2Client::Component::onBufferAttachedToOutputSurface(
        uint32_t generation) {
    if (mAidlBase) {
        std::shared_ptr<AidlGraphicBufferAllocator> gba =
                mGraphicBufferAllocators->current();
        if (gba) {
            gba->onBufferAttached(generation);
        }
        return;
    }
    mOutputBufferQueue->onBufferAttached(generation);
}

void Codec2Client::Component::holdIgbaBlocks(
        const std::list<std::unique_ptr<C2Work>>& workList) {
    if (!mAidlBase) {
+4 −0
Original line number Diff line number Diff line
@@ -481,6 +481,10 @@ struct Codec2Client::Component : public Codec2Client::Configurable {
    void onBufferReleasedFromOutputSurface(
            uint32_t generation);

    // Notify a buffer is attached to output surface.
    void onBufferAttachedToOutputSurface(
            uint32_t generation);

    // When the client received \p workList and the blocks inside
    // \p workList are IGBA based graphic blocks, specify the owner
    // as the current IGBA for the future operations.
+3 −0
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ struct OutputBufferQueue {
    // update the number of dequeueable/allocatable buffers.
    void onBufferReleased(uint32_t generation);

    // Nofify a buffer is attached to the output surface.
    void onBufferAttached(uint32_t generation);

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

+5 −0
Original line number Diff line number Diff line
@@ -542,6 +542,11 @@ void OutputBufferQueue::onBufferReleased(uint32_t generation) {
    }
}

void OutputBufferQueue::onBufferAttached(uint32_t generation) {
    // TODO
    (void) generation;
}

void OutputBufferQueue::pollForRenderedFrames(FrameEventHistoryDelta* delta) {
    if (mIgbp) {
        mIgbp->getFrameTimestamps(delta);
+11 −0
Original line number Diff line number Diff line
@@ -1469,6 +1469,17 @@ void CCodecBufferChannel::onBufferReleasedFromOutputSurface(uint32_t generation)
    }
}

void CCodecBufferChannel::onBufferAttachedToOutputSurface(uint32_t 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->onBufferAttachedToOutputSurface(generation);
    }
}

status_t CCodecBufferChannel::discardBuffer(const sp<MediaCodecBuffer> &buffer) {
    ALOGV("[%s] discardBuffer: %p", mName, buffer.get());
    bool released = false;
Loading