Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 7523410a5d3721e84fe96464ff2cf61482137c58 1 parent 3c77f87
@cyanogen cyanogen authored
View
6 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 @@ class BufferQueue : public BnSurfaceTexture {
// 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.
View
2  include/gui/ISurfaceTexture.h
@@ -154,6 +154,8 @@ class ISurfaceTexture : public IInterface
// 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
View
2  include/gui/SurfaceTextureClient.h
@@ -84,6 +84,7 @@ class SurfaceTextureClient
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 @@ class SurfaceTextureClient
virtual int setSwapInterval(int interval);
#ifdef QCOM_HARDWARE
virtual int setBuffersSize(int size);
+ virtual int setMinUndequeuedBufferCount(int count);
#endif
virtual int connect(int api);
View
11 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)
View
20 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 @@ class BpSurfaceTexture : public BpInterface<ISurfaceTexture>
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);
View
21 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)
View
4 services/surfaceflinger/SurfaceTextureLayer.cpp
@@ -28,11 +28,7 @@ namespace android {
SurfaceTextureLayer::SurfaceTextureLayer()
-#ifdef QCOM_HARDWARE
- : BufferQueue(true, 3)
-#else
: BufferQueue(true)
-#endif
{
}
Please sign in to comment.
Something went wrong with that request. Please try again.