Move remaining bits of lockBuffer to dequeueBuffer

FramebufferNativeWindow::dequeueBuffer now waits for the next buffer
to be non-front in addition to being free.

Change-Id: I991f154958cc6b488b1241aba83d1f95a0513b3c
This commit is contained in:
Jesse Hall 2012-06-21 11:35:23 -07:00
parent d8e812ce6f
commit a74cbc0649

View File

@ -237,10 +237,12 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
if (self->mBufferHead >= self->mNumBuffers)
self->mBufferHead = 0;
// wait for a free buffer
while (!self->mNumFreeBuffers) {
// wait for a free non-front buffer
while (self->mNumFreeBuffers < 2) {
self->mCondition.wait(self->mutex);
}
ALOG_ASSERT(self->buffers[index] != self->front);
// get this buffer
self->mNumFreeBuffers--;
self->mCurrentBufferIndex = index;
@ -254,17 +256,6 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* window,
ANativeWindowBuffer* buffer)
{
// XXX: Can this code all get ripped out? Should it move to dequeueBuffer?
FramebufferNativeWindow* self = getSelf(window);
Mutex::Autolock _l(self->mutex);
const int index = self->mCurrentBufferIndex;
// wait that the buffer we're locking is not front anymore
while (self->front == buffer) {
self->mCondition.wait(self->mutex);
}
return NO_ERROR;
}