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:
parent
c5d7b7d323
commit
9e3cb55b8f
@ -373,10 +373,6 @@ private:
|
|||||||
// all slots.
|
// all slots.
|
||||||
void freeAllBuffersLocked();
|
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
|
// drainQueueLocked waits for the buffer queue to empty if we're in
|
||||||
// synchronous mode, or returns immediately otherwise. It returns NO_INIT
|
// synchronous mode, or returns immediately otherwise. It returns NO_INIT
|
||||||
// if the BufferQueue is abandoned (consumer disconnected) or disconnected
|
// if the BufferQueue is abandoned (consumer disconnected) or disconnected
|
||||||
|
@ -178,12 +178,10 @@ status_t BufferQueue::setBufferCount(int bufferCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// here we're guaranteed that the client doesn't have dequeued buffers
|
// here we're guaranteed that the client doesn't have dequeued buffers
|
||||||
// and will release all of its buffer references.
|
// and will release all of its buffer references. We don't clear the
|
||||||
//
|
// queue, however, so currently queued buffers still get displayed.
|
||||||
// XXX: Should this use drainQueueAndFreeBuffersLocked instead?
|
|
||||||
freeAllBuffersLocked();
|
freeAllBuffersLocked();
|
||||||
mOverrideMaxBufferCount = bufferCount;
|
mOverrideMaxBufferCount = bufferCount;
|
||||||
mBufferHasBeenQueued = false;
|
|
||||||
mDequeueCondition.broadcast();
|
mDequeueCondition.broadcast();
|
||||||
listener = mConsumerListener;
|
listener = mConsumerListener;
|
||||||
} // scope for lock
|
} // scope for lock
|
||||||
@ -801,9 +799,8 @@ void BufferQueue::freeBufferLocked(int slot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BufferQueue::freeAllBuffersLocked() {
|
void BufferQueue::freeAllBuffersLocked() {
|
||||||
ALOGW_IF(!mQueue.isEmpty(),
|
ALOGD_IF(!mQueue.isEmpty(),
|
||||||
"freeAllBuffersLocked called but mQueue is not empty");
|
"freeAllBuffersLocked called with non-empty mQueue");
|
||||||
mQueue.clear();
|
|
||||||
mBufferHasBeenQueued = false;
|
mBufferHasBeenQueued = false;
|
||||||
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
|
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
|
||||||
freeBufferLocked(i);
|
freeBufferLocked(i);
|
||||||
@ -1026,18 +1023,6 @@ status_t BufferQueue::setMaxAcquiredBufferCount(int maxAcquiredBuffers) {
|
|||||||
return NO_ERROR;
|
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() {
|
status_t BufferQueue::drainQueueLocked() {
|
||||||
while (mSynchronousMode && mQueue.size() > 1) {
|
while (mSynchronousMode && mQueue.size() > 1) {
|
||||||
mDequeueCondition.wait(mMutex);
|
mDequeueCondition.wait(mMutex);
|
||||||
@ -1056,11 +1041,7 @@ status_t BufferQueue::drainQueueLocked() {
|
|||||||
status_t BufferQueue::drainQueueAndFreeBuffersLocked() {
|
status_t BufferQueue::drainQueueAndFreeBuffersLocked() {
|
||||||
status_t err = drainQueueLocked();
|
status_t err = drainQueueLocked();
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
if (mQueue.empty()) {
|
freeAllBuffersLocked();
|
||||||
freeAllBuffersLocked();
|
|
||||||
} else {
|
|
||||||
freeAllBuffersExceptHeadLocked();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user