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
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index 513a00e..54ee6ce 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -111,7 +111,7 @@
// 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 @@
mClientBufferCount = bufferCount;
mBufferHasBeenQueued = false;
mQueue.clear();
- mDequeueCondition.signal();
+ mDequeueCondition.broadcast();
return OK;
}
@@ -491,7 +491,7 @@
// - 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 @@
mSlots[buf].mFrameNumber = mFrameCounter;
mBufferHasBeenQueued = true;
- mDequeueCondition.signal();
+ mDequeueCondition.broadcast();
*outWidth = mDefaultWidth;
*outHeight = mDefaultHeight;
@@ -596,7 +596,7 @@
}
mSlots[buf].mBufferState = BufferSlot::FREE;
mSlots[buf].mFrameNumber = 0;
- mDequeueCondition.signal();
+ mDequeueCondition.broadcast();
}
status_t BufferQueue::setCrop(const Rect& crop) {
@@ -704,7 +704,7 @@
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 @@
mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
mQueue.erase(front);
+ mDequeueCondition.broadcast();
ATRACE_INT(mConsumerName.string(), mQueue.size());
}
@@ -872,7 +873,7 @@
|| mSlots[buf].mBufferState == BufferSlot::ACQUIRED) {
mSlots[buf].mBufferState = BufferSlot::FREE;
}
- mDequeueCondition.signal();
+ mDequeueCondition.broadcast();
return OK;
}
@@ -883,7 +884,7 @@
// is considered abandoned
mAbandoned = true;
freeAllBuffersLocked();
- mDequeueCondition.signal();
+ mDequeueCondition.broadcast();
return OK;
}