rework dequeueBuffer()'s main loop.

this simplifies the code a bit and also makes sure
we reevaluate mAbandoned and mConnectedApi each time
we come back from waiting on mDequeueCondition

Change-Id: I1f8538b62ad321b51ed79d953b700036daba796d
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index f93930d..71d818c 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -211,6 +211,11 @@
     // freeAllBuffers frees the resources (both GraphicBuffer and EGLImage) for
     // all slots.
     void freeAllBuffersLocked();
+
+    // drainQueueLocked drains the buffer queue if we're in synchronous mode
+    // returns immediately otherwise.
+    void drainQueueLocked();
+
     static bool isExternalFormat(uint32_t format);
 
 private: