Loading include/gui/Surface.h +9 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,13 @@ public: // See IGraphicBufferProducer::setDequeueTimeout status_t setDequeueTimeout(nsecs_t timeout); /* * Wait for frame number to increase past lastFrame for at most * timeoutNs. Useful for one thread to wait for another unknown * thread to queue a buffer. */ bool waitForNextFrame(uint64_t lastFrame, nsecs_t timeout); protected: virtual ~Surface(); Loading Loading @@ -348,6 +355,8 @@ private: // This is true if the shared buffer has already been queued/canceled. It's // used to prevent a mismatch between the number of queue/dequeue calls. bool mSharedBufferHasBeenQueued; Condition mQueueBufferCondition; }; namespace view { Loading libs/gui/Surface.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -480,6 +480,8 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { mSharedBufferHasBeenQueued = true; } mQueueBufferCondition.broadcast(); return err; } Loading Loading @@ -1259,6 +1261,15 @@ status_t Surface::unlockAndPost() return err; } bool Surface::waitForNextFrame(uint64_t lastFrame, nsecs_t timeout) { Mutex::Autolock lock(mMutex); uint64_t currentFrame = mGraphicBufferProducer->getNextFrameNumber(); if (currentFrame > lastFrame) { return true; } return mQueueBufferCondition.waitRelative(mMutex, timeout) == OK; } namespace view { status_t Surface::writeToParcel(Parcel* parcel) const { Loading Loading
include/gui/Surface.h +9 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,13 @@ public: // See IGraphicBufferProducer::setDequeueTimeout status_t setDequeueTimeout(nsecs_t timeout); /* * Wait for frame number to increase past lastFrame for at most * timeoutNs. Useful for one thread to wait for another unknown * thread to queue a buffer. */ bool waitForNextFrame(uint64_t lastFrame, nsecs_t timeout); protected: virtual ~Surface(); Loading Loading @@ -348,6 +355,8 @@ private: // This is true if the shared buffer has already been queued/canceled. It's // used to prevent a mismatch between the number of queue/dequeue calls. bool mSharedBufferHasBeenQueued; Condition mQueueBufferCondition; }; namespace view { Loading
libs/gui/Surface.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -480,6 +480,8 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { mSharedBufferHasBeenQueued = true; } mQueueBufferCondition.broadcast(); return err; } Loading Loading @@ -1259,6 +1261,15 @@ status_t Surface::unlockAndPost() return err; } bool Surface::waitForNextFrame(uint64_t lastFrame, nsecs_t timeout) { Mutex::Autolock lock(mMutex); uint64_t currentFrame = mGraphicBufferProducer->getNextFrameNumber(); if (currentFrame > lastFrame) { return true; } return mQueueBufferCondition.waitRelative(mMutex, timeout) == OK; } namespace view { status_t Surface::writeToParcel(Parcel* parcel) const { Loading