BQ: Flexible resizing
- Allow the producer to call setMaxDequeuedBufferCount and the
consumer to call setMaxAcquiredBufferCount when buffers are
currently dequeued/acquired as long as the new value is not less
than the number of dequeued/acquired buffers.
Bug 22768206
Change-Id: I599a4027a6ae9cb0a1c0d5ec60cb5e65b86a345b
diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h
index ebce7fb..e983c16 100644
--- a/include/gui/IGraphicBufferConsumer.h
+++ b/include/gui/IGraphicBufferConsumer.h
@@ -206,17 +206,26 @@
virtual status_t setMaxBufferCount(int bufferCount) = 0;
// setMaxAcquiredBufferCount sets the maximum number of buffers that can
- // be acquired by the consumer at one time (default 1). This call will
- // fail if a producer is connected to the BufferQueue.
+ // be acquired by the consumer at one time (default 1). If this method
+ // succeeds, any new buffer slots will be both unallocated and owned by the
+ // BufferQueue object (i.e. they are not owned by the producer or consumer).
+ // Calling this may also cause some buffer slots to be emptied.
+ //
+ // This function should not be called with a value of maxAcquiredBuffers
+ // that is less than the number of currently acquired buffer slots. Doing so
+ // will result in a BAD_VALUE error.
//
// maxAcquiredBuffers must be (inclusive) between 1 and
// MAX_MAX_ACQUIRED_BUFFERS. It also cannot cause the maxBufferCount value
// to be exceeded.
//
// Return of a value other than NO_ERROR means an error has occurred:
+ // * NO_INIT - the buffer queue has been abandoned
// * BAD_VALUE - one of the below conditions occurred:
// * maxAcquiredBuffers was out of range (see above).
// * failure to adjust the number of available slots.
+ // * client would have more than the requested number of
+ // acquired buffers after this call
// * INVALID_OPERATION - attempting to call this after a producer connected.
virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) = 0;
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index 1f4c8ac..265728f 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -82,15 +82,16 @@
virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) = 0;
// setMaxDequeuedBufferCount sets the maximum number of buffers that can be
- // dequeued by the producer at one time. If this method succeeds, buffer
- // slots will be both unallocated and owned by the BufferQueue object (i.e.
- // they are not owned by the producer or consumer). Calling this will also
- // cause all buffer slots to be emptied. If the caller is caching the
+ // dequeued by the producer at one time. If this method succeeds, any new
+ // buffer slots will be both unallocated and owned by the BufferQueue object
+ // (i.e. they are not owned by the producer or consumer). Calling this may
+ // also cause some buffer slots to be emptied. If the caller is caching the
// contents of the buffer slots, it should empty that cache after calling
// this method.
//
- // This function should not be called when there are any currently dequeued
- // buffer slots. Doing so will result in a BAD_VALUE error.
+ // This function should not be called with a value of maxDequeuedBuffers
+ // that is less than the number of currently dequeued buffer slots. Doing so
+ // will result in a BAD_VALUE error.
//
// The buffer count should be at least 1 (inclusive), but at most
// (NUM_BUFFER_SLOTS - the minimum undequeued buffer count) (exclusive). The
@@ -100,9 +101,10 @@
// Return of a value other than NO_ERROR means an error has occurred:
// * NO_INIT - the buffer queue has been abandoned.
// * BAD_VALUE - one of the below conditions occurred:
- // * bufferCount was out of range (see above)
- // * client has too many buffers dequeued
- // * this call would cause the maxBufferCount value to be exceeded
+ // * bufferCount was out of range (see above).
+ // * client would have more than the requested number of dequeued
+ // buffers after this call.
+ // * this call would cause the maxBufferCount value to be exceeded.
// * failure to adjust the number of available slots.
virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) = 0;