diff options
-rw-r--r-- | include/private/surfaceflinger/SharedBufferStack.h | 6 | ||||
-rw-r--r-- | libs/surfaceflinger_client/SharedBufferStack.cpp | 24 |
2 files changed, 17 insertions, 13 deletions
diff --git a/include/private/surfaceflinger/SharedBufferStack.h b/include/private/surfaceflinger/SharedBufferStack.h index d016dfa..d689667 100644 --- a/include/private/surfaceflinger/SharedBufferStack.h +++ b/include/private/surfaceflinger/SharedBufferStack.h @@ -151,7 +151,6 @@ public: ~SharedBufferBase(); status_t getStatus() const; int32_t getIdentity() const; - size_t getFrontBuffer() const; String8 dump(char const* prefix) const; protected: @@ -226,6 +225,11 @@ private: inline ssize_t operator()(); }; + struct DequeueUpdate : public UpdateBase { + inline DequeueUpdate(SharedBufferBase* sbb); + inline ssize_t operator()(); + }; + struct UndoDequeueUpdate : public UpdateBase { inline UndoDequeueUpdate(SharedBufferBase* sbb); inline ssize_t operator()(); diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp index 4ad9f86..38b2fae 100644 --- a/libs/surfaceflinger_client/SharedBufferStack.cpp +++ b/libs/surfaceflinger_client/SharedBufferStack.cpp @@ -191,12 +191,6 @@ int32_t SharedBufferBase::getIdentity() const return stack.identity; } -size_t SharedBufferBase::getFrontBuffer() const -{ - SharedBufferStack& stack( *mSharedStack ); - return size_t( stack.head ); -} - String8 SharedBufferBase::dump(char const* prefix) const { const size_t SIZE = 1024; @@ -281,6 +275,16 @@ ssize_t SharedBufferClient::QueueUpdate::operator()() { return NO_ERROR; } +SharedBufferClient::DequeueUpdate::DequeueUpdate(SharedBufferBase* sbb) + : UpdateBase(sbb) { +} +ssize_t SharedBufferClient::DequeueUpdate::operator()() { + if (android_atomic_dec(&stack.available) == 0) { + LOGW("dequeue probably called from multiple threads!"); + } + return NO_ERROR; +} + SharedBufferClient::UndoDequeueUpdate::UndoDequeueUpdate(SharedBufferBase* sbb) : UpdateBase(sbb) { } @@ -388,12 +392,8 @@ ssize_t SharedBufferClient::dequeue() if (err != NO_ERROR) return ssize_t(err); - // NOTE: 'stack.available' is part of the conditions, however - // decrementing it, never changes any conditions, so we don't need - // to do this as part of an update. - if (android_atomic_dec(&stack.available) == 0) { - LOGW("dequeue probably called from multiple threads!"); - } + DequeueUpdate update(this); + updateCondition( update ); undoDequeueTail = tail; int dequeued = stack.index[tail]; |