int BufferQueueCore::getMaxBufferCountLocked(bool asyncMode,
bool dequeueBufferCannotBlock, int maxBufferCount) const {
int maxCount = mMaxAcquiredBufferCount + mMaxDequeuedBufferCount +
((asyncMode || dequeueBufferCannotBlock) ? 1 : 0);
maxCount = std::min(maxBufferCount, maxCount);
return maxCount;
}
- 允许的最大 buffer 个数等于最大
ACQUIRED
个数与最大 DEQUEUED
个数之和,如果 asyncMode
或 dequeueBufferCannotBlock
是 true
,则再加 1。
- 从
maxBufferCount
和 maxCount
取最小值返回。
int BufferQueueCore::getMaxBufferCountLocked() const {
int maxBufferCount = mMaxAcquiredBufferCount + mMaxDequeuedBufferCount +
((mAsyncMode || mDequeueBufferCannotBlock) ? 1 : 0);
// limit maxBufferCount by mMaxBufferCount always
maxBufferCount = std::min(mMaxBufferCount, maxBufferCount);
return maxBufferCount;
}
maxBufferCount
的算法和第一个函数一致。在 BufferQueueCore() 中 mMaxAcquiredBufferCount
和 mMaxDequeuedBufferCount
的初始值都是 1。
- 从
mMaxBufferCount
和 maxBufferCount
取最小值返回。