Loading include/gui/BufferQueueConsumer.h +3 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,9 @@ public: // Retrieve the sideband buffer stream, if any. virtual sp<NativeHandle> getSidebandStream() const; // See IGraphicBufferConsumer::setShadowQueueSize virtual void setShadowQueueSize(size_t size); // dump our state in a String virtual void dump(String8& result, const char* prefix) const; Loading include/gui/BufferQueueCore.h +7 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,13 @@ private: // mBufferAge tracks the age of the contents of the most recently dequeued // buffer as the number of frames that have elapsed since it was last queued uint64_t mBufferAge; // mConsumerHasShadowQueue determines if acquireBuffer should be more // cautious about dropping buffers so that it always returns a buffer that // is represented in the consumer's shadow queue. bool mConsumerHasShadowQueue; size_t mConsumerShadowQueueSize; }; // class BufferQueueCore } // namespace android Loading include/gui/IGraphicBufferConsumer.h +5 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,11 @@ public: // Retrieve the sideband buffer stream, if any. virtual sp<NativeHandle> getSidebandStream() const = 0; // setShadowQueueSize notifies the BufferQueue that the consumer is // shadowing its queue and allows it to limit the number of buffers it is // permitted to drop during acquire so as to not get out of sync. virtual void setShadowQueueSize(size_t size) = 0; // dump state into a string virtual void dump(String8& result, const char* prefix) const = 0; Loading libs/gui/BufferQueueConsumer.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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 Loading Loading @@ -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); } Loading libs/gui/BufferQueueCore.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,9 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) : mIsAllocating(false), mIsAllocatingCondition(), mAllowAllocation(true), mBufferAge(0) mBufferAge(0), mConsumerHasShadowQueue(false), mConsumerShadowQueueSize(0) { if (allocator == NULL) { sp<ISurfaceComposer> composer(ComposerService::getComposerService()); Loading Loading
include/gui/BufferQueueConsumer.h +3 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,9 @@ public: // Retrieve the sideband buffer stream, if any. virtual sp<NativeHandle> getSidebandStream() const; // See IGraphicBufferConsumer::setShadowQueueSize virtual void setShadowQueueSize(size_t size); // dump our state in a String virtual void dump(String8& result, const char* prefix) const; Loading
include/gui/BufferQueueCore.h +7 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,13 @@ private: // mBufferAge tracks the age of the contents of the most recently dequeued // buffer as the number of frames that have elapsed since it was last queued uint64_t mBufferAge; // mConsumerHasShadowQueue determines if acquireBuffer should be more // cautious about dropping buffers so that it always returns a buffer that // is represented in the consumer's shadow queue. bool mConsumerHasShadowQueue; size_t mConsumerShadowQueueSize; }; // class BufferQueueCore } // namespace android Loading
include/gui/IGraphicBufferConsumer.h +5 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,11 @@ public: // Retrieve the sideband buffer stream, if any. virtual sp<NativeHandle> getSidebandStream() const = 0; // setShadowQueueSize notifies the BufferQueue that the consumer is // shadowing its queue and allows it to limit the number of buffers it is // permitted to drop during acquire so as to not get out of sync. virtual void setShadowQueueSize(size_t size) = 0; // dump state into a string virtual void dump(String8& result, const char* prefix) const = 0; Loading
libs/gui/BufferQueueConsumer.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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 Loading Loading @@ -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); } Loading
libs/gui/BufferQueueCore.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,9 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) : mIsAllocating(false), mIsAllocatingCondition(), mAllowAllocation(true), mBufferAge(0) mBufferAge(0), mConsumerHasShadowQueue(false), mConsumerShadowQueueSize(0) { if (allocator == NULL) { sp<ISurfaceComposer> composer(ComposerService::getComposerService()); Loading