summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/SurfaceTextureLayer.cpp
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-07-30 15:06:10 -0700
committerJamie Gennis <jgennis@google.com>2011-07-30 16:47:44 -0700
commit950de415284bc7582905650c352df7edfb91f28b (patch)
treec4f763ab2071c12c96266e047933db765e3447f0 /services/surfaceflinger/SurfaceTextureLayer.cpp
parente8f1cbae4400e8b046b405f205dffe0417826fb3 (diff)
downloadframeworks_base-950de415284bc7582905650c352df7edfb91f28b.zip
frameworks_base-950de415284bc7582905650c352df7edfb91f28b.tar.gz
frameworks_base-950de415284bc7582905650c352df7edfb91f28b.tar.bz2
SurfaceFlinger: use async mode for video & cam
This change makes SurfaceFlinger's SurfaceTexture objects default to async mode whenever a camera or video decoder connects. This behavior can be disabled by #defining NEVER_DEFAULT_TO_ASYNC_MODE. Change-Id: I8965951d1775915da180e4af298dd7af3afafecc
Diffstat (limited to 'services/surfaceflinger/SurfaceTextureLayer.cpp')
-rw-r--r--services/surfaceflinger/SurfaceTextureLayer.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp
index 91e010f..5973e76 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.cpp
+++ b/services/surfaceflinger/SurfaceTextureLayer.cpp
@@ -86,6 +86,32 @@ status_t SurfaceTextureLayer::dequeueBuffer(int *buf,
return res;
}
+status_t SurfaceTextureLayer::connect(int api) {
+ status_t err = SurfaceTexture::connect(api);
+ 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.
+ deafult:
+ err = setSynchronousMode(true);
+ break;
+ }
+ if (err != NO_ERROR) {
+ disconnect(api);
+ }
+ }
+ return err;
+}
// ---------------------------------------------------------------------------
}; // namespace android