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: Iaf9371b829f772f559daae42e06d4dbd9505d6a0
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index 25a4c22..7d64105 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;
 }
 
@@ -306,6 +306,7 @@
             if (numberOfBuffersNeedsToChange) {
                 // here we're guaranteed that mQueue is empty
                 freeAllBuffersLocked();
+                // XXX: signal?
                 mBufferCount = mServerBufferCount;
                 if (mBufferCount < minBufferCountNeeded)
                     mBufferCount = minBufferCountNeeded;
@@ -496,7 +497,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;
 }
@@ -564,7 +565,7 @@
         mSlots[buf].mFrameNumber = mFrameCounter;
 
         mBufferHasBeenQueued = true;
-        mDequeueCondition.signal();
+        mDequeueCondition.broadcast();
 
         *outWidth = mDefaultWidth;
         *outHeight = mDefaultHeight;
@@ -601,7 +602,7 @@
     }
     mSlots[buf].mBufferState = BufferSlot::FREE;
     mSlots[buf].mFrameNumber = 0;
-    mDequeueCondition.signal();
+    mDequeueCondition.broadcast();
 }
 
 status_t BufferQueue::setCrop(const Rect& crop) {
@@ -709,7 +710,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);
@@ -846,6 +847,7 @@
 
         mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
         mQueue.erase(front);
+        mDequeueCondition.broadcast();
 
         ATRACE_INT(mConsumerName.string(), mQueue.size());
     }
@@ -877,7 +879,8 @@
             || mSlots[buf].mBufferState == BufferSlot::ACQUIRED) {
         mSlots[buf].mBufferState = BufferSlot::FREE;
     }
-    mDequeueCondition.signal();
+
+    mDequeueCondition.broadcast();
 
     return OK;
 }
@@ -888,7 +891,7 @@
     // is considered abandoned
     mAbandoned = true;
     freeAllBuffersLocked();
-    mDequeueCondition.signal();
+    mDequeueCondition.broadcast();
     return OK;
 }