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

Commit 03904c44 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: StreamSplitter: Return overwritten buffer to input"

parents be0ee69a a141c5f3
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -322,6 +322,13 @@ void Camera3StreamSplitter::onFrameAvailable(const BufferItem& /* item */) {
                        "queueing buffer to output failed (%d)", status);
            }

            // If the queued buffer replaces a pending buffer in the async
            // queue, no onBufferReleased is called by the buffer queue.
            // Proactively trigger the callback to avoid buffer loss.
            if (queueOutput.bufferReplaced) {
                onBufferReleasedByOutputLocked(mOutputs[id]);
            }

            ALOGV("queued buffer %#" PRIx64 " to output %p",
                    bufferItem.mGraphicBuffer->getId(), mOutputs[id].get());
        }
@@ -335,6 +342,12 @@ void Camera3StreamSplitter::onBufferReleasedByOutput(
    ATRACE_CALL();
    Mutex::Autolock lock(mMutex);

    onBufferReleasedByOutputLocked(from);
}

void Camera3StreamSplitter::onBufferReleasedByOutputLocked(
        const sp<IGraphicBufferProducer>& from) {

    sp<GraphicBuffer> buffer;
    sp<Fence> fence;
    status_t status = from->detachNextBuffer(&buffer, &fence);
+5 −0
Original line number Diff line number Diff line
@@ -103,6 +103,11 @@ private:
    // onFrameAvailable call to proceed.
    void onBufferReleasedByOutput(const sp<IGraphicBufferProducer>& from);

    // This is the implementation of onBufferReleasedByOutput without the mutex locked.
    // It could either be called from onBufferReleasedByOutput or from
    // onFrameAvailable when a buffer in the async buffer queue is overwritten.
    void onBufferReleasedByOutputLocked(const sp<IGraphicBufferProducer>& from);

    // When this is called, the splitter disconnects from (i.e., abandons) its
    // input queue and signals any waiting onFrameAvailable calls to wake up.
    // It still processes callbacks from other outputs, but only detaches their