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
// 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
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 {