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/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp
index d0f0dae..b76dc0c 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.cpp
+++ b/services/surfaceflinger/SurfaceTextureLayer.cpp
@@ -28,7 +28,7 @@
SurfaceTextureLayer::SurfaceTextureLayer(const sp<SurfaceFlinger>& flinger)
- : BufferQueue(true), flinger(flinger) {
+ : BufferQueue(), flinger(flinger) {
}
SurfaceTextureLayer::~SurfaceTextureLayer() {
@@ -51,32 +51,5 @@
flinger->postMessageAsync( new MessageCleanUpList(flinger, this) );
}
-status_t SurfaceTextureLayer::connect(int api, QueueBufferOutput* output) {
- status_t err = BufferQueue::connect(api, output);
- if (err == NO_ERROR) {
- switch(api) {
- case NATIVE_WINDOW_API_MEDIA:
- case NATIVE_WINDOW_API_CAMERA:
- // Camera preview and videos are rate-limited on the producer
- // side. If enabled for this build, we use async mode to always
- // show the most recent frame at the cost of requiring an
- // additional buffer.
-#ifndef NEVER_DEFAULT_TO_ASYNC_MODE
- err = setSynchronousMode(false);
- break;
-#endif
- // fall through to set synchronous mode when not defaulting to
- // async mode.
- default:
- err = setSynchronousMode(true);
- break;
- }
- if (err != NO_ERROR) {
- disconnect(api);
- }
- }
- return err;
-}
-
// ---------------------------------------------------------------------------
}; // namespace android