发现835手机外接1080p@60摄像头时,帧率不稳定(burst)。现象是如果统计一千帧,帧率是60fps,但是如果打印两帧之间的间隔,发现有时候间隔是3毫秒,有时是9ms。这样导致UI处理不过来,而Android GraphicBuffer在queueBuffer时,最多只能缓存一帧,而丢弃前面的帧
status_t BufferQueueProducer::queueBuffer(int slot,
const QueueBufferInput &input, QueueBufferOutput *output) {
ATRACE_CALL();
ATRACE_BUFFER_INDEX(slot);
................................................
sp<IConsumerListener> frameAvailableListener;
sp<IConsumerListener> frameReplacedListener;
int callbackTicket = 0;
uint64_t currentFrameNumber = 0;
BufferItem item;
{ // Autolock scope
Mutex::Autolock lock(mCore->mMutex);
.........................................
output->bufferReplaced = false;
if (mCore->mQueue.empty()) {
// When the queue is empty, we can ignore mDequeueBufferCannotBlock
// and simply queue this buffer
mCore->mQueue.push_back(item);
frameAvailableListener = mCore->mConsumerListener;
} else {
// When the queue is not empty, we need to look at the last buffer
// in the queue to see if we need to replace it
const