BufferQueue: remove freeAllBuffersExceptHeadLocked()

Now that we are having separate buffer-instances for the buffer-
queue, we can free all buffers; we don't have to keep the head
alive.

Change-Id: I023e9161a2501d99333f8868ce438afa914ec50f
Signed-off-by: Lajos Molnar <lajos@google.com>
Related-to-bug: 7093648
This commit is contained in:
Lajos Molnar 2013-05-06 16:23:07 -07:00 committed by Android (Google) Code Review
parent c5d7b7d323
commit 9e3cb55b8f
2 changed files with 5 additions and 28 deletions

View File

@ -373,10 +373,6 @@ private:
// all slots.
void freeAllBuffersLocked();
// freeAllBuffersExceptHeadLocked frees the GraphicBuffer and sync
// resources for all slots except the head of mQueue.
void freeAllBuffersExceptHeadLocked();
// drainQueueLocked waits for the buffer queue to empty if we're in
// synchronous mode, or returns immediately otherwise. It returns NO_INIT
// if the BufferQueue is abandoned (consumer disconnected) or disconnected

View File

@ -178,12 +178,10 @@ status_t BufferQueue::setBufferCount(int bufferCount) {
}
// here we're guaranteed that the client doesn't have dequeued buffers
// and will release all of its buffer references.
//
// XXX: Should this use drainQueueAndFreeBuffersLocked instead?
// and will release all of its buffer references. We don't clear the
// queue, however, so currently queued buffers still get displayed.
freeAllBuffersLocked();
mOverrideMaxBufferCount = bufferCount;
mBufferHasBeenQueued = false;
mDequeueCondition.broadcast();
listener = mConsumerListener;
} // scope for lock
@ -801,9 +799,8 @@ void BufferQueue::freeBufferLocked(int slot) {
}
void BufferQueue::freeAllBuffersLocked() {
ALOGW_IF(!mQueue.isEmpty(),
"freeAllBuffersLocked called but mQueue is not empty");
mQueue.clear();
ALOGD_IF(!mQueue.isEmpty(),
"freeAllBuffersLocked called with non-empty mQueue");
mBufferHasBeenQueued = false;
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
freeBufferLocked(i);
@ -1026,18 +1023,6 @@ status_t BufferQueue::setMaxAcquiredBufferCount(int maxAcquiredBuffers) {
return NO_ERROR;
}
void BufferQueue::freeAllBuffersExceptHeadLocked() {
// only called if mQueue is not empty
Fifo::iterator front(mQueue.begin());
mBufferHasBeenQueued = false;
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
const BufferSlot &slot = mSlots[i];
if (slot.mGraphicBuffer == NULL ||
slot.mGraphicBuffer->handle != front->mGraphicBuffer->handle)
freeBufferLocked(i);
}
}
status_t BufferQueue::drainQueueLocked() {
while (mSynchronousMode && mQueue.size() > 1) {
mDequeueCondition.wait(mMutex);
@ -1056,11 +1041,7 @@ status_t BufferQueue::drainQueueLocked() {
status_t BufferQueue::drainQueueAndFreeBuffersLocked() {
status_t err = drainQueueLocked();
if (err == NO_ERROR) {
if (mQueue.empty()) {
freeAllBuffersLocked();
} else {
freeAllBuffersExceptHeadLocked();
}
freeAllBuffersLocked();
}
return err;
}