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

Commit 93dd0518 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

BufferQueueProducer: Signal consumer when a buffer is detached

When a buffer is detached, it should be cleared from the consumer-side
cache as well.

Not doing so can leak buffers no longer owned by the queue for extended
lengths of time, depending on the exact usage patterns of the producer
and consumer.

Bug: 28695173
Change-Id: I2c618be51f2c827d92d0e19b92a2d5befda87c38
parent 572e23d7
Loading
Loading
Loading
Loading
+40 −31
Original line number Original line Diff line number Diff line
@@ -553,6 +553,9 @@ status_t BufferQueueProducer::detachBuffer(int slot) {
    ATRACE_CALL();
    ATRACE_CALL();
    ATRACE_BUFFER_INDEX(slot);
    ATRACE_BUFFER_INDEX(slot);
    BQ_LOGV("detachBuffer: slot %d", slot);
    BQ_LOGV("detachBuffer: slot %d", slot);

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


        if (mCore->mIsAbandoned) {
        if (mCore->mIsAbandoned) {
@@ -590,6 +593,12 @@ status_t BufferQueueProducer::detachBuffer(int slot) {
        mCore->clearBufferSlotLocked(slot);
        mCore->clearBufferSlotLocked(slot);
        mCore->mDequeueCondition.broadcast();
        mCore->mDequeueCondition.broadcast();
        VALIDATE_CONSISTENCY();
        VALIDATE_CONSISTENCY();
        listener = mCore->mConsumerListener;
    }

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


    return NO_ERROR;
    return NO_ERROR;
}
}