BufferQueue improvements and APIs changes
this is the first step of a series of improvements to
BufferQueue. A few things happen in this change:
- setSynchronousMode() goes away as well as the SynchronousModeAllowed flag
- BufferQueue now defaults to (what used to be) synchronous mode
- a new "controlled by app" flag is passed when creating consumers and producers
those flags are used to put the BufferQueue in a mode where it
will never block if both flags are set. This is achieved by:
- returning an error from dequeueBuffer() if it would block
- making sure a buffer is always available by replacing
the previous buffer with the new one in queueBuffer()
(note: this is similar to what asynchrnous mode used to be)
Note: in this change EGL's swap-interval 0 is broken; this will be
fixed in another change.
Change-Id: I691f9507d6e2e158287e3039f2a79a4d4434211d
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp
index 63d7628..9f65fc3 100644
--- a/libs/gui/IGraphicBufferProducer.cpp
+++ b/libs/gui/IGraphicBufferProducer.cpp
@@ -37,7 +37,6 @@
QUEUE_BUFFER,
CANCEL_BUFFER,
QUERY,
- SET_SYNCHRONOUS_MODE,
CONNECT,
DISCONNECT,
};
@@ -142,22 +141,11 @@
return result;
}
- virtual status_t setSynchronousMode(bool enabled) {
- Parcel data, reply;
- data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
- data.writeInt32(enabled);
- status_t result = remote()->transact(SET_SYNCHRONOUS_MODE, data, &reply);
- if (result != NO_ERROR) {
- return result;
- }
- result = reply.readInt32();
- return result;
- }
-
- virtual status_t connect(int api, QueueBufferOutput* output) {
+ virtual status_t connect(int api, bool producerControlledByApp, QueueBufferOutput* output) {
Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
data.writeInt32(api);
+ data.writeInt32(producerControlledByApp);
status_t result = remote()->transact(CONNECT, data, &reply);
if (result != NO_ERROR) {
return result;
@@ -252,20 +240,14 @@
reply->writeInt32(res);
return NO_ERROR;
} break;
- case SET_SYNCHRONOUS_MODE: {
- CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
- bool enabled = data.readInt32();
- status_t res = setSynchronousMode(enabled);
- reply->writeInt32(res);
- return NO_ERROR;
- } break;
case CONNECT: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
int api = data.readInt32();
+ bool producerControlledByApp = data.readInt32();
QueueBufferOutput* const output =
reinterpret_cast<QueueBufferOutput *>(
reply->writeInplace(sizeof(QueueBufferOutput)));
- status_t res = connect(api, output);
+ status_t res = connect(api, producerControlledByApp, output);
reply->writeInt32(res);
return NO_ERROR;
} break;