Fix a small bug where we could compute SharedBufferStack's tail incorrectly.
Also add "tail" to the debug dump().
Change-Id: I04b1ea375dfc9ddcc22f0c6b6cd01300e507572e
diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp
index ceb5e59..65ce1c1 100644
--- a/libs/surfaceflinger_client/SharedBufferStack.cpp
+++ b/libs/surfaceflinger_client/SharedBufferStack.cpp
@@ -132,10 +132,11 @@
char buffer[SIZE];
String8 result;
SharedBufferStack& stack( *mSharedStack );
+ int tail = (mNumBuffers + stack.head - stack.available + 1) % mNumBuffers;
snprintf(buffer, SIZE,
- "%s[ head=%2d, available=%2d, queued=%2d ] "
+ "%s[ head=%2d, available=%2d, queued=%2d, tail=%2d ] "
"reallocMask=%08x, inUse=%2d, identity=%d, status=%d\n",
- prefix, stack.head, stack.available, stack.queued,
+ prefix, stack.head, stack.available, stack.queued, tail,
stack.reallocMask, stack.inUse, stack.identity, stack.status);
result.append(buffer);
return result;
@@ -269,6 +270,8 @@
newTail = head - avail + 1;
if (newTail < 0) {
newTail += mNumBuffers;
+ } else if (newTail >= mNumBuffers) {
+ newTail -= mNumBuffers;
}
return newTail;
}