diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h index 52edf17fe..2c58ca5e2 100644 --- a/include/gui/BufferItemConsumer.h +++ b/include/gui/BufferItemConsumer.h @@ -44,6 +44,7 @@ class BufferItemConsumer: public ConsumerBase typedef BufferQueue::BufferItem BufferItem; + enum { MIN_UNDEQUEUED_BUFFERS = -1 }; enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT }; enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE }; @@ -54,7 +55,7 @@ class BufferItemConsumer: public ConsumerBase // controlledByApp tells whether this consumer is controlled by the // application. BufferItemConsumer(const sp& bq, uint32_t consumerUsage, - int bufferCount = BufferQueue::MIN_UNDEQUEUED_BUFFERS, + int bufferCount = MIN_UNDEQUEUED_BUFFERS, bool controlledByApp = false); virtual ~BufferItemConsumer(); diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 2457eba09..cab7e8684 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -41,7 +41,6 @@ class BufferQueue : public BnGraphicBufferProducer, public BnGraphicBufferConsumer, private IBinder::DeathRecipient { public: - enum { MIN_UNDEQUEUED_BUFFERS = 2 }; // BufferQueue will keep track of at most this value of buffers. // Attempts at runtime to increase the number of buffers past this will fail. enum { NUM_BUFFER_SLOTS = 32 }; diff --git a/libs/gui/BufferItemConsumer.cpp b/libs/gui/BufferItemConsumer.cpp index 350887a1f..74a65ed8d 100644 --- a/libs/gui/BufferItemConsumer.cpp +++ b/libs/gui/BufferItemConsumer.cpp @@ -33,6 +33,13 @@ BufferItemConsumer::BufferItemConsumer(const sp& bq, uint32_t consumerUsage, int bufferCount, bool controlledByApp) : ConsumerBase(bq, controlledByApp) { + if (bufferCount == MIN_UNDEQUEUED_BUFFERS) { + status_t res; + res = bq->query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &bufferCount); + LOG_ALWAYS_FATAL_IF(res != OK || bufferCount < 0, + "Failed to query min buffer count"); + } + mConsumer->setConsumerUsageBits(consumerUsage); mConsumer->setMaxAcquiredBufferCount(bufferCount); }