From 634f5ee6a713b3cf4086a2af8e9b56e76cba245f Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Fri, 3 Apr 2015 14:22:05 -0700 Subject: [PATCH] libgui: Plumb detachBuffer through ConsumerBase Exposes IGraphicBufferConsumer::detachBuffer as a ConsumerBase method. attachBuffer is not currently exposed, because all current clients will be recycling buffers through the allocator. Bug: 19628705 Change-Id: I3e519767fa43d5d880c1d5695e31b60f6ad588af --- include/gui/ConsumerBase.h | 3 +++ libs/gui/ConsumerBase.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h index ef0feab72..d56fa89b5 100644 --- a/include/gui/ConsumerBase.h +++ b/include/gui/ConsumerBase.h @@ -76,6 +76,9 @@ public: // when a new frame becomes available. void setFrameAvailableListener(const wp& listener); + // See IGraphicBufferConsumer::detachBuffer + status_t detachBuffer(int slot); + private: ConsumerBase(const ConsumerBase&); void operator=(const ConsumerBase&); diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp index b874e3a32..e576018bf 100644 --- a/libs/gui/ConsumerBase.cpp +++ b/libs/gui/ConsumerBase.cpp @@ -163,6 +163,21 @@ void ConsumerBase::setFrameAvailableListener( mFrameAvailableListener = listener; } +status_t ConsumerBase::detachBuffer(int slot) { + CB_LOGV("detachBuffer"); + Mutex::Autolock lock(mMutex); + + status_t result = mConsumer->detachBuffer(slot); + if (result != NO_ERROR) { + CB_LOGE("Failed to detach buffer: %d", result); + return result; + } + + freeBufferLocked(slot); + + return result; +} + void ConsumerBase::dump(String8& result) const { dump(result, ""); }