summaryrefslogtreecommitdiff
path: root/libs/ui/SharedBufferStack.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2009-09-14 15:48:42 -0700
committer Mathias Agopian <mathias@google.com> 2009-09-14 15:48:42 -0700
commitc7d56010815b0e7104dfc1d4bba6d16cdcbffec4 (patch)
treeb9b3a22c43414ae2dbd978252d4f8fda5b8b055f /libs/ui/SharedBufferStack.cpp
parent46cd3afb0228dd18c5d67d2ef7e3620fcc4cc239 (diff)
make sure to update the tail pointer when undoing a dequeue
Diffstat (limited to 'libs/ui/SharedBufferStack.cpp')
-rw-r--r--libs/ui/SharedBufferStack.cpp20
1 files changed, 15 insertions, 5 deletions
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;
}