From 74ff8c23f44f1546d0c7004302f4c7ba726ff4c0 Mon Sep 17 00:00:00 2001 From: Dave Burke Date: Mon, 12 Mar 2012 21:49:41 -0700 Subject: [PATCH] attempt to fix a deadlock in SurfaceTextureClient::disconnect - condition wasn't signaled if an error happened between acquire and release - also replace signal with broadcasts Bug: 6109450 Change-Id: I8ac03c7eca35c9cc04a00ef7fad36bb9cb3fcef6 --- libs/gui/BufferQueue.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 513a00e9e..54ee6ce98 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -111,7 +111,7 @@ status_t BufferQueue::setBufferCountServerLocked(int bufferCount) { // easy, we just have more buffers mBufferCount = bufferCount; mServerBufferCount = bufferCount; - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); } else { // we're here because we're either // - reducing the number of available buffers @@ -192,7 +192,7 @@ status_t BufferQueue::setBufferCount(int bufferCount) { mClientBufferCount = bufferCount; mBufferHasBeenQueued = false; mQueue.clear(); - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); return OK; } @@ -491,7 +491,7 @@ status_t BufferQueue::setSynchronousMode(bool enabled) { // - if the client set the number of buffers, we're guaranteed that // we have at least 3 (because we don't allow less) mSynchronousMode = enabled; - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); } return err; } @@ -559,7 +559,7 @@ status_t BufferQueue::queueBuffer(int buf, int64_t timestamp, mSlots[buf].mFrameNumber = mFrameCounter; mBufferHasBeenQueued = true; - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); *outWidth = mDefaultWidth; *outHeight = mDefaultHeight; @@ -596,7 +596,7 @@ void BufferQueue::cancelBuffer(int buf) { } mSlots[buf].mBufferState = BufferSlot::FREE; mSlots[buf].mFrameNumber = 0; - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); } status_t BufferQueue::setCrop(const Rect& crop) { @@ -704,7 +704,7 @@ status_t BufferQueue::disconnect(int api) { mNextCrop.makeInvalid(); mNextScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE; mNextTransform = 0; - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); } else { ST_LOGE("disconnect: connected to another api (cur=%d, req=%d)", mConnectedApi, api); @@ -841,6 +841,7 @@ status_t BufferQueue::acquire(BufferItem *buffer) { mSlots[buf].mBufferState = BufferSlot::ACQUIRED; mQueue.erase(front); + mDequeueCondition.broadcast(); ATRACE_INT(mConsumerName.string(), mQueue.size()); } @@ -872,7 +873,7 @@ status_t BufferQueue::releaseBuffer(int buf, EGLDisplay display, || mSlots[buf].mBufferState == BufferSlot::ACQUIRED) { mSlots[buf].mBufferState = BufferSlot::FREE; } - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); return OK; } @@ -883,7 +884,7 @@ status_t BufferQueue::consumerDisconnect() { // is considered abandoned mAbandoned = true; freeAllBuffersLocked(); - mDequeueCondition.signal(); + mDequeueCondition.broadcast(); return OK; }