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

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

ConsumerBase: discardFreeBuffers() also needs to dump its own cache

ConsumerBase has its own cached slots with graphic buffer references,
so it's not enough to just ask the buffer queue consumer to free
buffers.

Add code equivalent to what happens in the onBuffersReleased callback.

Test:
Bug: 62593139
Change-Id: Ibc1444b868c6150aa2da1c209e06bdba42f1595d
parent 2672decb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -267,6 +267,8 @@ public:
    // discardFreeBuffers releases all currently-free buffers held by the BufferQueue, in order to
    // reduce the memory consumption of the BufferQueue to the minimum possible without
    // discarding data.
    // The consumer invoking this method is responsible for calling getReleasedBuffers() after this
    // call to free up any of its locally cached buffers.
    virtual status_t discardFreeBuffers() = 0;

    // dump state into a string
+12 −1
Original line number Diff line number Diff line
@@ -253,7 +253,18 @@ status_t ConsumerBase::discardFreeBuffers() {
        CB_LOGE("discardFreeBuffers: ConsumerBase is abandoned!");
        return NO_INIT;
    }
    return mConsumer->discardFreeBuffers();
    status_t err = mConsumer->discardFreeBuffers();
    if (err != OK) {
        return err;
    }
    uint64_t mask;
    mConsumer->getReleasedBuffers(&mask);
    for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
        if (mask & (1ULL << i)) {
            freeBufferLocked(i);
        }
    }
    return OK;
}

void ConsumerBase::dumpState(String8& result) const {