diff options
author | Mathias Agopian <mathias@google.com> | 2013-03-11 17:59:59 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2013-03-11 17:59:59 -0700 |
commit | d2d5a64aa21cfc548c8c8333d1b36979e5e5a640 (patch) | |
tree | fd20adbc883d1c9eef9c8024497ab2959d943368 | |
parent | dbca4a0ee5dac0b2f8d0ed4b1667adbf11363e35 (diff) | |
download | frameworks_native-d2d5a64aa21cfc548c8c8333d1b36979e5e5a640.zip frameworks_native-d2d5a64aa21cfc548c8c8333d1b36979e5e5a640.tar.gz frameworks_native-d2d5a64aa21cfc548c8c8333d1b36979e5e5a640.tar.bz2 |
workaround a deadlock when taking screenshots into a surface
When disconnecting from BufferQueue, we now drain the queue
except the head (which means in the screenshot case we won't
have to block, but we might not have a buffer to show, this
will appear as an error in the log).
Bug: 8362363
Change-Id: If80989aac3c917beea2ebddf3cbb502849d394da
-rw-r--r-- | libs/gui/BufferQueue.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index d93c067..41ee1be 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -995,7 +995,7 @@ void BufferQueue::freeAllBuffersExceptHeadLocked() { } status_t BufferQueue::drainQueueLocked() { - while (mSynchronousMode && !mQueue.isEmpty()) { + while (mSynchronousMode && mQueue.size() > 1) { mDequeueCondition.wait(mMutex); if (mAbandoned) { ST_LOGE("drainQueueLocked: BufferQueue has been abandoned!"); @@ -1012,7 +1012,7 @@ status_t BufferQueue::drainQueueLocked() { status_t BufferQueue::drainQueueAndFreeBuffersLocked() { status_t err = drainQueueLocked(); if (err == NO_ERROR) { - if (mSynchronousMode) { + if (mQueue.empty()) { freeAllBuffersLocked(); } else { freeAllBuffersExceptHeadLocked(); |