Loading include/private/ui/SharedBufferStack.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -229,6 +229,8 @@ private: friend struct DequeueCondition; friend struct DequeueCondition; friend struct LockCondition; friend struct LockCondition; int32_t computeTail() const; struct QueueUpdate : public UpdateBase { struct QueueUpdate : public UpdateBase { inline QueueUpdate(SharedBufferBase* sbb); inline QueueUpdate(SharedBufferBase* sbb); inline ssize_t operator()(); inline ssize_t operator()(); Loading libs/ui/SharedBufferStack.cpp +15 −5 Original line number Original line Diff line number Diff line Loading @@ -245,20 +245,27 @@ ssize_t SharedBufferServer::StatusUpdate::operator()() { SharedBufferClient::SharedBufferClient(SharedClient* sharedClient, SharedBufferClient::SharedBufferClient(SharedClient* sharedClient, int surface, int num) int surface, int num) : SharedBufferBase(sharedClient, surface, num), tail(0) : SharedBufferBase(sharedClient, surface, num), tail(0) { tail = computeTail(); } int32_t SharedBufferClient::computeTail() const { { SharedBufferStack& stack( *mSharedStack ); SharedBufferStack& stack( *mSharedStack ); int32_t avail; int32_t head; // we need to make sure we read available and head coherently, // we need to make sure we read available and head coherently, // w.r.t RetireUpdate. // w.r.t RetireUpdate. int32_t newTail; int32_t avail; int32_t head; do { do { avail = stack.available; avail = stack.available; head = stack.head; head = stack.head; } while (stack.available != avail); } while (stack.available != avail); tail = head - avail + 1; newTail = head - avail + 1; if (tail < 0) { if (newTail < 0) { tail += num; newTail += mNumBuffers; } } return newTail; } } ssize_t SharedBufferClient::dequeue() ssize_t SharedBufferClient::dequeue() Loading Loading @@ -296,6 +303,9 @@ status_t SharedBufferClient::undoDequeue(int buf) { { UndoDequeueUpdate update(this); UndoDequeueUpdate update(this); status_t err = updateCondition( update ); status_t err = updateCondition( update ); if (err == NO_ERROR) { tail = computeTail(); } return err; return err; } } Loading Loading
include/private/ui/SharedBufferStack.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -229,6 +229,8 @@ private: friend struct DequeueCondition; friend struct DequeueCondition; friend struct LockCondition; friend struct LockCondition; int32_t computeTail() const; struct QueueUpdate : public UpdateBase { struct QueueUpdate : public UpdateBase { inline QueueUpdate(SharedBufferBase* sbb); inline QueueUpdate(SharedBufferBase* sbb); inline ssize_t operator()(); inline ssize_t operator()(); Loading
libs/ui/SharedBufferStack.cpp +15 −5 Original line number Original line Diff line number Diff line Loading @@ -245,20 +245,27 @@ ssize_t SharedBufferServer::StatusUpdate::operator()() { SharedBufferClient::SharedBufferClient(SharedClient* sharedClient, SharedBufferClient::SharedBufferClient(SharedClient* sharedClient, int surface, int num) int surface, int num) : SharedBufferBase(sharedClient, surface, num), tail(0) : SharedBufferBase(sharedClient, surface, num), tail(0) { tail = computeTail(); } int32_t SharedBufferClient::computeTail() const { { SharedBufferStack& stack( *mSharedStack ); SharedBufferStack& stack( *mSharedStack ); int32_t avail; int32_t head; // we need to make sure we read available and head coherently, // we need to make sure we read available and head coherently, // w.r.t RetireUpdate. // w.r.t RetireUpdate. int32_t newTail; int32_t avail; int32_t head; do { do { avail = stack.available; avail = stack.available; head = stack.head; head = stack.head; } while (stack.available != avail); } while (stack.available != avail); tail = head - avail + 1; newTail = head - avail + 1; if (tail < 0) { if (newTail < 0) { tail += num; newTail += mNumBuffers; } } return newTail; } } ssize_t SharedBufferClient::dequeue() ssize_t SharedBufferClient::dequeue() Loading Loading @@ -296,6 +303,9 @@ status_t SharedBufferClient::undoDequeue(int buf) { { UndoDequeueUpdate update(this); UndoDequeueUpdate update(this); status_t err = updateCondition( update ); status_t err = updateCondition( update ); if (err == NO_ERROR) { tail = computeTail(); } return err; return err; } } Loading