From 8db92553e9e6263cd41eaf1a1ebc9e3f88f92b5f Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Thu, 29 Aug 2013 16:03:50 -0700 Subject: [PATCH] Force async behavior for the virtual display output BufferQueue Bug: 10551087 Change-Id: I40bbb2b87d64420939a0ea309254f281437dab56 --- libs/gui/BufferQueue.cpp | 6 ++++-- .../DisplayHardware/VirtualDisplaySurface.cpp | 17 ++++++++++++----- .../DisplayHardware/VirtualDisplaySurface.h | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 65007fa24..57a41f25c 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -637,7 +637,8 @@ void BufferQueue::cancelBuffer(int buf, const sp& fence) { status_t BufferQueue::connect(int api, bool producerControlledByApp, QueueBufferOutput* output) { ATRACE_CALL(); - ST_LOGV("connect: api=%d", api); + ST_LOGV("connect: api=%d producerControlledByApp=%s", api, + producerControlledByApp ? "true" : "false"); Mutex::Autolock lock(mMutex); if (mAbandoned) { @@ -1001,7 +1002,8 @@ status_t BufferQueue::releaseBuffer( status_t BufferQueue::consumerConnect(const sp& consumerListener, bool controlledByApp) { - ST_LOGV("consumerConnect"); + ST_LOGV("consumerConnect controlledByApp=%s", + controlledByApp ? "true" : "false"); Mutex::Autolock lock(mMutex); if (mAbandoned) { diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp index 01ca38ae3..43d27bb24 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp @@ -175,9 +175,12 @@ void VirtualDisplaySurface::onFrameCommitted() { sp outFence = mHwc.getLastRetireFence(mDisplayId); VDS_LOGV("onFrameCommitted: queue sink sslot=%d", sslot); status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot, - QueueBufferInput(systemTime(), false, + QueueBufferInput( + systemTime(), false /* isAutoTimestamp */, Rect(mSinkBufferWidth, mSinkBufferHeight), - NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, outFence), + NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */, + true /* async*/, + outFence), &qbo); if (result == NO_ERROR) { updateQueueBufferOutput(qbo); @@ -205,7 +208,10 @@ status_t VirtualDisplaySurface::setBufferCount(int bufferCount) { } status_t VirtualDisplaySurface::dequeueBuffer(Source source, - uint32_t format, int* sslot, sp* fence, bool async) { + uint32_t format, int* sslot, sp* fence) { + // Don't let a slow consumer block us + bool async = (source == SOURCE_SINK); + status_t result = mSource[source]->dequeueBuffer(sslot, fence, async, mSinkBufferWidth, mSinkBufferHeight, format, mProducerUsage); if (result < 0) @@ -244,6 +250,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp* fence, bool "Unexpected dequeueBuffer() in %s state", dbgStateStr()); mDbgState = DBG_STATE_GLES; + VDS_LOGW_IF(!async, "EGL called dequeueBuffer with !async despite eglSwapInterval(0)"); VDS_LOGV("dequeueBuffer %dx%d fmt=%d usage=%#x", w, h, format, usage); status_t result = NO_ERROR; @@ -275,7 +282,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp* fence, bool *fence = mOutputFence; } else { int sslot; - result = dequeueBuffer(source, format, &sslot, fence, async); + result = dequeueBuffer(source, format, &sslot, fence); if (result >= 0) { *pslot = mapSource2ProducerSlot(source, sslot); } @@ -391,7 +398,7 @@ status_t VirtualDisplaySurface::refreshOutputBuffer() { } int sslot; - status_t result = dequeueBuffer(SOURCE_SINK, 0, &sslot, &mOutputFence, false); + status_t result = dequeueBuffer(SOURCE_SINK, 0, &sslot, &mOutputFence); if (result < 0) return result; mOutputProducerSlot = mapSource2ProducerSlot(SOURCE_SINK, sslot); diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h index 4ab80e4f6..536007ec6 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h @@ -110,7 +110,7 @@ private: // static Source fbSourceForCompositionType(CompositionType type); status_t dequeueBuffer(Source source, uint32_t format, - int* sslot, sp* fence, bool async); + int* sslot, sp* fence); void updateQueueBufferOutput(const QueueBufferOutput& qbo); void resetPerFrameState(); status_t refreshOutputBuffer();