Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a74cbc06 authored by Jesse Hall's avatar Jesse Hall
Browse files

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
parent d8e812ce
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -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;
}