BufferQueueCore::BufferQueueCore()
: ...
mDequeueBufferCannotBlock(false),
mMaxBufferCount(BufferQueueDefs::NUM_BUFFER_SLOTS),
mMaxAcquiredBufferCount(1),
mMaxDequeuedBufferCount(1),
mAsyncMode(false),
mUniqueId(getUniqueId()),
... {
int numStartingBuffers = getMaxBufferCountLocked();
for (int s = 0; s < numStartingBuffers; s++) {
mFreeSlots.insert(s);
}
for (int s = numStartingBuffers; s < BufferQueueDefs::NUM_BUFFER_SLOTS;
s++) {
mUnusedSlots.push_front(s);
}
}
- 初始化
mFreeSlots
和 mUnusedSlots
。
- 从 BufferQueueCore::getMaxBufferCountLocked() 实现可知,因为
mMaxAcquiredBufferCount
和 mMaxDequeuedBufferCount
都是 1,且 mDequeueBufferCannotBlock
和 mAsyncMode
都是 false
,所以 numStartingBuffers
是 2。
- 因此,
mFreeSlots
大小是 2,mUnusedSlots
大小是 62。