BufferQueues: Always respect setMaxDequeuedBufferCount
For some reason, this wouldn't be respected if no buffers had been
queued. This could lead to surprising behavior of a (with unlimited
buffers, essentially unbounded) buffers being dequeued for new BQs.
This is flag gated to capture potential issues, since I'm worried about
chesterton's fence.
Bug: 399328309
Flag: com.android.graphics.libgui.flags.bq_always_use_max_dequeued_buffer_count
Test: new tests
Change-Id: I756eb4f621f6eec1a5bb43a490305018ec69c477
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index 5961b41..bcf61e4 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -364,8 +364,10 @@
// Producers are not allowed to dequeue more than
// mMaxDequeuedBufferCount buffers.
// This check is only done if a buffer has already been queued
- if (mCore->mBufferHasBeenQueued &&
- dequeuedCount >= mCore->mMaxDequeuedBufferCount) {
+ using namespace com::android::graphics::libgui::flags;
+ bool flagGatedBufferHasBeenQueued =
+ bq_always_use_max_dequeued_buffer_count() || mCore->mBufferHasBeenQueued;
+ if (flagGatedBufferHasBeenQueued && dequeuedCount >= mCore->mMaxDequeuedBufferCount) {
// Supress error logs when timeout is non-negative.
if (mDequeueTimeout < 0) {
BQ_LOGE("%s: attempting to exceed the max dequeued buffer "