diff options
| author | 2009-09-14 19:01:40 -0400 | |
|---|---|---|
| committer | 2009-09-14 19:01:40 -0400 | |
| commit | a1212578bfd11bd391c686c82c18b21b4a3a69b4 (patch) | |
| tree | 5cda57181fe2e319e394476f9d050e2c4841efa4 /libs/ui/SharedBufferStack.cpp | |
| parent | 0d5581133285cef4d7582b531e0bf09cee86aa90 (diff) | |
| parent | bd8527110caa5427ade0edd7ce0d00e63f15ccbc (diff) | |
Merge change 24947 into eclair
* changes:
make sure to update the tail pointer when undoing a dequeue
Diffstat (limited to 'libs/ui/SharedBufferStack.cpp')
| -rw-r--r-- | libs/ui/SharedBufferStack.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/ui/SharedBufferStack.cpp b/libs/ui/SharedBufferStack.cpp index 436d79320e9c..7789a3f8646f 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; } |