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
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index 0874f03..2b61ab3 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -32,6 +32,7 @@
namespace android {
// ----------------------------------------------------------------------------
+class IProducerListener;
class NativeHandle;
class Surface;
@@ -344,9 +345,11 @@
// This method will fail if the connect was previously called on the
// IGraphicBufferProducer and no corresponding disconnect call was made.
//
- // The token needs to be any opaque binder object that lives in the
- // producer process -- it is solely used for obtaining a death notification
- // when the producer is killed.
+ // The listener is an optional binder callback object that can be used if
+ // the producer wants to be notified when the consumer releases a buffer
+ // back to the BufferQueue. It is also used to detect the death of the
+ // producer. If only the latter functionality is desired, there is a
+ // DummyProducerListener class in IProducerListener.h that can be used.
//
// The api should be one of the NATIVE_WINDOW_API_* values in <window.h>
//
@@ -370,7 +373,7 @@
//
// Additional negative errors may be returned by the internals, they
// should be treated as opaque fatal unrecoverable errors.
- virtual status_t connect(const sp<IBinder>& token,
+ virtual status_t connect(const sp<IProducerListener>& listener,
int api, bool producerControlledByApp, QueueBufferOutput* output) = 0;
// disconnect attempts to disconnect a client API from the