From 22f842ba04c32cef2faf855dc304eb0ab131b9ec Mon Sep 17 00:00:00 2001 From: Shuzhen Wang Date: Wed, 18 Jan 2017 23:02:36 -0800 Subject: BufferQueue: Add bufferReplaced flag in QueueBufferOutput For async buffer queue, when queueBuffer overwrites a previously queued buffer, because consumer won't be able to acquire the overwritten buffer, onBufferReleased isn't triggered either. This makes it difficult to track which buffer in the buffer queue becomes free other than calling dequeueBuffer(). Adding a flag in QueueBufferOutput addresses this issue. Test: TestBufferReplacedInQueueBuffer in BufferQueue_tests Bug: 34481539 Change-Id: Ic7f4be2d3f9691dd6b007a450240614c0c420f0d --- libs/gui/BufferQueueProducer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libs/gui/BufferQueueProducer.cpp') diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index 39b9a0b480..3f69b1f602 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -879,6 +879,7 @@ status_t BufferQueueProducer::queueBuffer(int slot, mCore->mSharedBufferCache.dataspace = dataSpace; } + output->bufferReplaced = false; if (mCore->mQueue.empty()) { // When the queue is empty, we can ignore mDequeueBufferCannotBlock // and simply queue this buffer @@ -905,6 +906,7 @@ status_t BufferQueueProducer::queueBuffer(int slot, if (!mSlots[last.mSlot].mBufferState.isShared()) { mCore->mActiveBuffers.erase(last.mSlot); mCore->mFreeBuffers.push_back(last.mSlot); + output->bufferReplaced = true; } } @@ -1158,6 +1160,7 @@ status_t BufferQueueProducer::connect(const sp& listener, output->numPendingBuffers = static_cast(mCore->mQueue.size()); output->nextFrameNumber = mCore->mFrameCounter + 1; + output->bufferReplaced = false; if (listener != NULL) { // Set up a death notification so that we can disconnect -- cgit v1.2.3-59-g8ed1b