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

Commit 2672decb authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

BufferQueueProducer: Call onBuffersReleased() in detachNextBuffer

Like detachBuffer(), detachNextBuffer() needs to inform the consumer,
who generally has a cache of buffer items, that a buffer is no longer
owned by the buffer queue.

Otherwise the consumer layer can leak the buffer reference until
consumer teardown/disconnect.

Test: Camera CTS is fine, using a camera app shows correct memory
  behavior
Bug: 62591036

Change-Id: I14c200d13e60dbbe21261343941f84fb786db117
parent 2563c0f3
Loading
Loading
Loading
Loading
+34 −26
Original line number Diff line number Diff line
@@ -632,6 +632,8 @@ status_t BufferQueueProducer::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
        return BAD_VALUE;
    }

    sp<IConsumerListener> listener;
    {
        Mutex::Autolock lock(mCore->mMutex);

        if (mCore->mIsAbandoned) {
@@ -666,6 +668,12 @@ status_t BufferQueueProducer::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
        *outFence = mSlots[found].mFence;
        mCore->clearBufferSlotLocked(found);
        VALIDATE_CONSISTENCY();
        listener = mCore->mConsumerListener;
    }

    if (listener != NULL) {
        listener->onBuffersReleased();
    }

    return NO_ERROR;
}