diff options
| author | 2009-09-14 19:01:40 -0400 | |
|---|---|---|
| committer | 2009-09-14 19:01:40 -0400 | |
| commit | ab0fb1be8933b9c923c683d00d94bd2fa383fa85 (patch) | |
| tree | a9e2bd95a57a5851bcbfebb0146ce41b42ac705d | |
| parent | abff9f77d5319e770c895ee302b5de321b4ee4ed (diff) | |
| parent | c7d56010815b0e7104dfc1d4bba6d16cdcbffec4 (diff) | |
Merge change 24947 into eclair
* changes:
make sure to update the tail pointer when undoing a dequeue
| -rw-r--r-- | include/private/ui/SharedBufferStack.h | 2 | ||||
| -rw-r--r-- | libs/ui/SharedBufferStack.cpp | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/include/private/ui/SharedBufferStack.h b/include/private/ui/SharedBufferStack.h index 6181f55760..8b0f154f5c 100644 --- a/include/private/ui/SharedBufferStack.h +++ b/include/private/ui/SharedBufferStack.h @@ -228,6 +228,8 @@ private: friend struct Condition; friend struct DequeueCondition; friend struct LockCondition; + + int32_t computeTail() const; struct QueueUpdate : public UpdateBase { inline QueueUpdate(SharedBufferBase* sbb); diff --git a/libs/ui/SharedBufferStack.cpp b/libs/ui/SharedBufferStack.cpp index 436d79320e..7789a3f864 100644 --- a/libs/ui/SharedBufferStack.cpp +++ b/libs/ui/SharedBufferStack.cpp @@ -246,19 +246,26 @@ SharedBufferClient::SharedBufferClient(SharedClient* sharedClient, int surface, int num) : SharedBufferBase(sharedClient, surface, num), tail(0) { + tail = computeTail(); +} + +int32_t SharedBufferClient::computeTail() const +{ SharedBufferStack& stack( *mSharedStack ); - int32_t avail; - int32_t head; // we need to make sure we read available and head coherently, // w.r.t RetireUpdate. + int32_t newTail; + int32_t avail; + int32_t head; do { avail = stack.available; head = stack.head; } while (stack.available != avail); - tail = head - avail + 1; - if (tail < 0) { - tail += num; + newTail = head - avail + 1; + if (newTail < 0) { + newTail += mNumBuffers; } + return newTail; } ssize_t SharedBufferClient::dequeue() @@ -296,6 +303,9 @@ status_t SharedBufferClient::undoDequeue(int buf) { UndoDequeueUpdate update(this); status_t err = updateCondition( update ); + if (err == NO_ERROR) { + tail = computeTail(); + } return err; } |