void BufferQueueCore::freeAllBuffersLocked() {
    for (int s : mFreeSlots) {
        clearBufferSlotLocked(s);
    }

    for (int s : mFreeBuffers) {
        mFreeSlots.insert(s);
        clearBufferSlotLocked(s);
    }
    mFreeBuffers.clear();

    for (int s : mActiveBuffers) {
        mFreeSlots.insert(s);
        clearBufferSlotLocked(s);
    }
    mActiveBuffers.clear();

    for (auto& b : mQueue) {
        b.mIsStale = true;

        // We set this to false to force the BufferQueue to resend the buffer
        // handle upon acquire, since if we're here due to a producer
        // disconnect, the consumer will have been told to purge its cache of
        // slot-to-buffer-handle mappings and will not be able to otherwise
        // obtain a valid buffer handle.
        b.mAcquireCalled = false;
    }
}

遍历 mFreeSlotsmFreeBuffers 和 mActiveBuffers,调用 BufferQueueCore::clearBufferSlotLocked() 释放 BufferSlot,并把所有 slot 加入到 mFreeSlots

遍历 mQueue,设置 mIsState 为 true,意思就是坏了不能用。同时设置 mAcquiredCalled 为 false,因为已经释放 buffer 了,下次 BufferQueueConsumer::acquireBuffer() 必须重新发送 GraphicBuffer。