BufferQueueProducer: add detachNextBuffer
Adds a new method, IGBP::detachNextBuffer, that effectively does
dequeue + request + detach in a single call, but does not need to
know anything about the dequeued buffer, and will not block on
dequeue. This is mostly for the upcoming StreamSplitter to use in
its onBufferReleased callback.
Change-Id: Ie88a69de109003acebaa486a5b44c8a455726550
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index da876ec..311926d 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -199,6 +199,10 @@
// See IGraphicBufferProducer::detachBuffer
virtual status_t detachProducerBuffer(int slot);
+ // See IGraphicBufferProducer::detachNextBuffer
+ virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+ sp<Fence>* outFence);
+
// See IGraphicBufferProducer::attachBuffer
virtual status_t attachProducerBuffer(int* slot,
const sp<GraphicBuffer>& buffer);
diff --git a/include/gui/BufferQueueProducer.h b/include/gui/BufferQueueProducer.h
index 04692a5..9df3633 100644
--- a/include/gui/BufferQueueProducer.h
+++ b/include/gui/BufferQueueProducer.h
@@ -99,6 +99,10 @@
// See IGraphicBufferProducer::detachBuffer
virtual status_t detachBuffer(int slot);
+ // See IGraphicBufferProducer::detachNextBuffer
+ virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+ sp<Fence>* outFence);
+
// See IGraphicBufferProducer::attachBuffer
virtual status_t attachBuffer(int* outSlot, const sp<GraphicBuffer>& buffer);
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index 2b61ab3..d9e116b 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -185,6 +185,27 @@
// it refers to is not currently dequeued and requested.
virtual status_t detachBuffer(int slot) = 0;
+ // detachNextBuffer is equivalent to calling dequeueBuffer, requestBuffer,
+ // and detachBuffer in sequence, except for two things:
+ //
+ // 1) It is unnecessary to know the dimensions, format, or usage of the
+ // next buffer.
+ // 2) It will not block, since if it cannot find an appropriate buffer to
+ // return, it will return an error instead.
+ //
+ // Only slots that are free but still contain a GraphicBuffer will be
+ // considered, and the oldest of those will be returned. outBuffer is
+ // equivalent to outBuffer from the requestBuffer call, and outFence is
+ // equivalent to fence from the dequeueBuffer call.
+ //
+ // Return of a value other than NO_ERROR means an error has occurred:
+ // * NO_INIT - the buffer queue has been abandoned.
+ // * BAD_VALUE - either outBuffer or outFence were NULL.
+ // * NO_MEMORY - no slots were found that were both free and contained a
+ // GraphicBuffer.
+ virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+ sp<Fence>* outFence) = 0;
+
// attachBuffer attempts to transfer ownership of a buffer to the buffer
// queue. If this call succeeds, it will be as if this buffer was dequeued
// from the returned slot number. As such, this call will fail if attaching