summaryrefslogtreecommitdiffstats
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
commitcb6c755234a17ab14e6c5d0a857aab96fb02dc02 (patch)
tree32b4ea9d0ac6e5eb6fc4a7650618dd6410c6423b
parent8d944d254bd8054e9926ac651a7867083d36752d (diff)
downloadframeworks_native-cb6c755234a17ab14e6c5d0a857aab96fb02dc02.zip
frameworks_native-cb6c755234a17ab14e6c5d0a857aab96fb02dc02.tar.gz
frameworks_native-cb6c755234a17ab14e6c5d0a857aab96fb02dc02.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
-rw-r--r--services/surfaceflinger/Android.mk2
-rw-r--r--services/surfaceflinger/SurfaceTextureLayer.cpp26
-rw-r--r--services/surfaceflinger/SurfaceTextureLayer.h2
3 files changed, 29 insertions, 1 deletions
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index f67c82e..b178e49 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -22,7 +22,7 @@ ifeq ($(TARGET_BOARD_PLATFORM), omap3)
LOCAL_CFLAGS += -DNO_RGBX_8888
endif
ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
- LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
+ LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY -DNEVER_DEFAULT_TO_ASYNC_MODE
endif
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
diff --git a/services/surfaceflinger/SurfaceTextureLayer.h b/services/surfaceflinger/SurfaceTextureLayer.h
index 29a9cbe..5d328b7 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.h
+++ b/services/surfaceflinger/SurfaceTextureLayer.h
@@ -50,6 +50,8 @@ protected:
virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h,
uint32_t format, uint32_t usage);
+
+ virtual status_t connect(int api);
};
// ---------------------------------------------------------------------------