diff options
author | 2014-03-21 13:05:51 -0700 | |
---|---|---|
committer | 2014-03-31 14:10:07 -0700 | |
commit | f0eaf25e9247edf4d124bedaeb863f7abdf35a3e (patch) | |
tree | 15baebb3fa387a1bba3625b3067aa28221cbc8ae /libs/gui/BufferQueueProducer.cpp | |
parent | 96668903e4d11893ea1f68525713542b0adb5404 (diff) |
BufferQueue: Add producer buffer-released callback
Add a callback to the producer side, onBufferReleased, which will be
called every time the consumer releases a buffer back to the
BufferQueue. This will enable a buffer stream splitter to work
autonomously without having to block on dequeueBuffer.
The binder object used for the callback replaces the generic IBinder
token that was passed into IGraphicBufferProducer::connect to detect
the death of the producer. If a producer does not wish to listen for
buffer release events, it can pass in an instance of the
DummyProducerListener class defined in IProducerListener.h, if it even
cares about death events (BufferQueue doesn't enforce the token being
non-NULL, though perhaps we should).
Change-Id: I23935760673524abeafea2b58dccc3583b368710
Diffstat (limited to 'libs/gui/BufferQueueProducer.cpp')
-rw-r--r-- | libs/gui/BufferQueueProducer.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index 9dd90bab58..82d931ec7f 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -25,6 +25,7 @@ #include <gui/BufferQueueProducer.h> #include <gui/IConsumerListener.h> #include <gui/IGraphicBufferAlloc.h> +#include <gui/IProducerListener.h> #include <utils/Log.h> #include <utils/Trace.h> @@ -654,7 +655,7 @@ int BufferQueueProducer::query(int what, int *outValue) { return NO_ERROR; } -status_t BufferQueueProducer::connect(const sp<android::IBinder> &token, +status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener, int api, bool producerControlledByApp, QueueBufferOutput *output) { ATRACE_CALL(); Mutex::Autolock lock(mCore->mMutex); @@ -711,16 +712,16 @@ status_t BufferQueueProducer::connect(const sp<android::IBinder> &token, // Set up a death notification so that we can disconnect // automatically if the remote producer dies - if (token != NULL && token->remoteBinder() != NULL) { - status = token->linkToDeath( + if (listener != NULL && + listener->asBinder()->remoteBinder() != NULL) { + status = listener->asBinder()->linkToDeath( static_cast<IBinder::DeathRecipient*>(this)); - if (status == NO_ERROR) { - mCore->mConnectedProducerToken = token; - } else { + if (status != NO_ERROR) { BQ_LOGE("connect(P): linkToDeath failed: %s (%d)", strerror(-status), status); } } + mCore->mConnectedProducerListener = listener; break; default: BQ_LOGE("connect(P): unknown API %d", api); @@ -759,14 +760,15 @@ status_t BufferQueueProducer::disconnect(int api) { mCore->freeAllBuffersLocked(); // Remove our death notification callback if we have one - sp<IBinder> token = mCore->mConnectedProducerToken; - if (token != NULL) { + if (mCore->mConnectedProducerListener != NULL) { + sp<IBinder> token = + mCore->mConnectedProducerListener->asBinder(); // This can fail if we're here because of the death // notification, but we just ignore it token->unlinkToDeath( static_cast<IBinder::DeathRecipient*>(this)); } - mCore->mConnectedProducerToken = NULL; + mCore->mConnectedProducerListener = NULL; mCore->mConnectedApi = BufferQueueCore::NO_CONNECTED_API; mCore->mSidebandStream.clear(); mCore->mDequeueCondition.broadcast(); |