summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2012-08-26 13:09:39 -0700
committerSteve Kondik <shade@chemlab.org>2012-08-26 17:02:49 -0700
commit7523410a5d3721e84fe96464ff2cf61482137c58 (patch)
treec17de2079fbd801d95f9cd01786b0c2f5ad87332
parent3c77f875627a504ec8e52a341ce654a4e16a3838 (diff)
downloadandroid_frameworks_native-7523410a5d3721e84fe96464ff2cf61482137c58.tar.gz
android_frameworks_native-7523410a5d3721e84fe96464ff2cf61482137c58.tar.bz2
android_frameworks_native-7523410a5d3721e84fe96464ff2cf61482137c58.zip
surfacetexture: Add API to set the min undequeued buffer count
* Needed if we want to globally raise the value to reduce jank. Too many buffers causes issues for camera drivers. * Change the value back to 3 globally for QCOM targets. Change-Id: Ifc553fc0ea622974f773550799970b37e80a7c96
-rw-r--r--include/gui/BufferQueue.h6
-rw-r--r--include/gui/ISurfaceTexture.h2
-rw-r--r--include/gui/SurfaceTextureClient.h2
-rw-r--r--libs/gui/BufferQueue.cpp11
-rw-r--r--libs/gui/ISurfaceTexture.cpp20
-rw-r--r--libs/gui/SurfaceTextureClient.cpp21
-rw-r--r--services/surfaceflinger/SurfaceTextureLayer.cpp4
7 files changed, 61 insertions, 5 deletions
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index ce78e0bc5..47a46ff11 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -34,7 +34,11 @@ namespace android {
class BufferQueue : public BnSurfaceTexture {
public:
+#ifdef QCOM_HARDWARE
+ enum { MIN_UNDEQUEUED_BUFFERS = 3 };
+#else
enum { MIN_UNDEQUEUED_BUFFERS = 2 };
+#endif
enum { NUM_BUFFER_SLOTS = 32 };
enum { NO_CONNECTED_API = 0 };
enum { INVALID_BUFFER_SLOT = -1 };
@@ -143,6 +147,8 @@ public:
// for interlaced use cases where the user can pass extra information about
// the type of the frame whether it is interlaced or progressive frame.
virtual status_t setBuffersSize(int size);
+
+ virtual status_t setMinUndequeuedBufferCount(int count);
#endif
// connect attempts to connect a producer client API to the BufferQueue.
diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h
index 97de091f1..f39a5a0fc 100644
--- a/include/gui/ISurfaceTexture.h
+++ b/include/gui/ISurfaceTexture.h
@@ -154,6 +154,8 @@ protected:
// for interlaced use cases where the user can pass extra information about
// the type of the frame whether it is interlaced or progressive frame.
virtual status_t setBuffersSize(int size) = 0;
+
+ virtual status_t setMinUndequeuedBufferCount(int count) = 0;
#endif
// connect attempts to connect a client API to the SurfaceTexture. This
diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h
index b1695e23e..18c44d8cd 100644
--- a/include/gui/SurfaceTextureClient.h
+++ b/include/gui/SurfaceTextureClient.h
@@ -84,6 +84,7 @@ private:
int dispatchSetUsage(va_list args);
#ifdef QCOM_HARDWARE
int dispatchSetBuffersSize(va_list args);
+ int dispatchSetMinUndequeuedBufferCount(va_list args);
#endif
int dispatchLock(va_list args);
int dispatchUnlockAndPost(va_list args);
@@ -98,6 +99,7 @@ protected:
virtual int setSwapInterval(int interval);
#ifdef QCOM_HARDWARE
virtual int setBuffersSize(int size);
+ virtual int setMinUndequeuedBufferCount(int count);
#endif
virtual int connect(int api);
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index b47495fc5..d30306533 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -105,6 +105,8 @@ BufferQueue::BufferQueue( bool allowSynchronousMode, int bufferCount ) :
mConsumerName = String8::format("unnamed-%d-%d", getpid(), createProcessUniqueId());
ST_LOGV("BufferQueue");
+
+ ALOGI("BufferQueue: minUndequeued=%d", mMinUndequeuedBuffers);
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
mGraphicBufferAlloc = composer->createGraphicBufferAlloc();
if (mGraphicBufferAlloc == 0) {
@@ -180,7 +182,7 @@ status_t BufferQueue::setTransformHint(uint32_t hint) {
}
status_t BufferQueue::setBufferCount(int bufferCount) {
- ST_LOGV("setBufferCount: count=%d", bufferCount);
+ ALOGI("setBufferCount: count=%d", bufferCount);
sp<ConsumerListener> listener;
{
@@ -243,6 +245,13 @@ status_t BufferQueue::setBuffersSize(int size) {
mGraphicBufferAlloc->setGraphicBufferSize(size);
return NO_ERROR;
}
+
+status_t BufferQueue::setMinUndequeuedBufferCount(int count) {
+ ALOGI("setMinUndequeuedBufferCount: count=%d", count);
+ Mutex::Autolock lock(mMutex);
+ mMinUndequeuedBuffers = count;
+ return NO_ERROR;
+}
#endif
int BufferQueue::query(int what, int* outValue)
diff --git a/libs/gui/ISurfaceTexture.cpp b/libs/gui/ISurfaceTexture.cpp
index 623453556..dc00bd69e 100644
--- a/libs/gui/ISurfaceTexture.cpp
+++ b/libs/gui/ISurfaceTexture.cpp
@@ -40,6 +40,7 @@ enum {
SET_SYNCHRONOUS_MODE,
#ifdef QCOM_HARDWARE
SET_BUFFERS_SIZE,
+ SET_MIN_UNDEQUEUED_BUFFER_COUNT,
#endif
CONNECT,
DISCONNECT,
@@ -160,6 +161,18 @@ public:
result = reply.readInt32();
return result;
}
+
+ virtual status_t setMinUndequeuedBufferCount(int count) {
+ Parcel data, reply;
+ data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
+ data.writeInt32(count);
+ status_t result = remote()->transact(SET_MIN_UNDEQUEUED_BUFFER_COUNT, data, &reply);
+ if (result != NO_ERROR) {
+ return result;
+ }
+ result = reply.readInt32();
+ return result;
+ }
#endif
virtual status_t connect(int api, QueueBufferOutput* output) {
@@ -270,6 +283,13 @@ status_t BnSurfaceTexture::onTransact(
reply->writeInt32(res);
return NO_ERROR;
} break;
+ case SET_MIN_UNDEQUEUED_BUFFER_COUNT: {
+ CHECK_INTERFACE(ISurfaceTexture, data, reply);
+ int size = data.readInt32();
+ status_t res = setMinUndequeuedBufferCount(size);
+ reply->writeInt32(res);
+ return NO_ERROR;
+ } break;
#endif
case CONNECT: {
CHECK_INTERFACE(ISurfaceTexture, data, reply);
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index 973a03e31..a425f6936 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -353,6 +353,9 @@ int SurfaceTextureClient::perform(int operation, va_list args)
case NATIVE_WINDOW_SET_BUFFERS_SIZE:
res = dispatchSetBuffersSize(args);
break;
+ case NATIVE_WINDOW_SET_MIN_UNDEQUEUED_BUFFER_COUNT:
+ res = dispatchSetMinUndequeuedBufferCount(args);
+ break;
#endif
case NATIVE_WINDOW_LOCK:
res = dispatchLock(args);
@@ -434,6 +437,11 @@ int SurfaceTextureClient::dispatchSetBuffersSize(va_list args) {
int size = va_arg(args, int);
return setBuffersSize(size);
}
+
+int SurfaceTextureClient::dispatchSetMinUndequeuedBufferCount(va_list args) {
+ int count = va_arg(args, int);
+ return setMinUndequeuedBufferCount(count);
+}
#endif
int SurfaceTextureClient::dispatchSetScalingMode(va_list args) {
@@ -624,6 +632,19 @@ int SurfaceTextureClient::setBuffersSize(int size)
status_t err = mSurfaceTexture->setBuffersSize(size);
return NO_ERROR;
}
+
+int SurfaceTextureClient::setMinUndequeuedBufferCount(int count)
+{
+ ATRACE_CALL();
+ ALOGV("SurfaceTextureClient::setMinUndequeuedBufferCount");
+
+ if (count<0)
+ return BAD_VALUE;
+
+ Mutex::Autolock lock(mMutex);
+ status_t err = mSurfaceTexture->setMinUndequeuedBufferCount(count);
+ return NO_ERROR;
+}
#endif
int SurfaceTextureClient::setScalingMode(int mode)
diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp
index 73d1b56ee..9c1b506ec 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.cpp
+++ b/services/surfaceflinger/SurfaceTextureLayer.cpp
@@ -28,11 +28,7 @@ namespace android {
SurfaceTextureLayer::SurfaceTextureLayer()
-#ifdef QCOM_HARDWARE
- : BufferQueue(true, 3)
-#else
: BufferQueue(true)
-#endif
{
}