diff options
| author | 2015-05-01 21:44:06 +0000 | |
|---|---|---|
| committer | 2015-05-01 21:44:07 +0000 | |
| commit | ba9e1f4241a81eb7c453028ee05da56e290d8ce6 (patch) | |
| tree | 36744e0d0815385aac92679b60efc02c9caf836e /libs/gui/BufferQueueConsumer.cpp | |
| parent | 61a3c8dec90acebef15ef56cae14efea69279f69 (diff) | |
| parent | ecc504043fddb7a75042ce402c67aedfac04d5e2 (diff) | |
Merge "SurfaceFlinger: Fix PTS on stale buffers" into mnc-dev
Diffstat (limited to 'libs/gui/BufferQueueConsumer.cpp')
| -rw-r--r-- | libs/gui/BufferQueueConsumer.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp index c7d5e00326..2deef0e777 100644 --- a/libs/gui/BufferQueueConsumer.cpp +++ b/libs/gui/BufferQueueConsumer.cpp @@ -89,7 +89,20 @@ status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer, // the timestamps are being auto-generated by Surface. If the app isn't // generating timestamps explicitly, it probably doesn't want frames to // be discarded based on them. + // + // If the consumer is shadowing our queue, we also make sure that we + // don't drop so many buffers that the consumer hasn't received the + // onFrameAvailable callback for the buffer it acquires. That is, we + // want the buffer we return to be in the consumer's shadow queue. + size_t droppableBuffers = mCore->mConsumerShadowQueueSize > 1 ? + mCore->mConsumerShadowQueueSize - 1 : 0; while (mCore->mQueue.size() > 1 && !mCore->mQueue[0].mIsAutoTimestamp) { + if (mCore->mConsumerHasShadowQueue && droppableBuffers == 0) { + BQ_LOGV("acquireBuffer: no droppable buffers in consumer's" + " shadow queue, continuing"); + break; + } + // If entry[1] is timely, drop entry[0] (and repeat). We apply an // additional criterion here: we only drop the earlier buffer if our // desiredPresent falls within +/- 1 second of the expected present. @@ -124,6 +137,7 @@ status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer, } mCore->mQueue.erase(front); front = mCore->mQueue.begin(); + --droppableBuffers; } // See if the front buffer is due @@ -537,6 +551,14 @@ sp<NativeHandle> BufferQueueConsumer::getSidebandStream() const { return mCore->mSidebandStream; } +void BufferQueueConsumer::setShadowQueueSize(size_t size) { + ATRACE_CALL(); + BQ_LOGV("setShadowQueueSize: %zu", size); + Mutex::Autolock lock(mCore->mMutex); + mCore->mConsumerHasShadowQueue = true; + mCore->mConsumerShadowQueueSize = size; +} + void BufferQueueConsumer::dump(String8& result, const char* prefix) const { mCore->dump(result, prefix); } |