diff options
author | Jamie Gennis <jgennis@google.com> | 2012-12-07 00:41:56 -0800 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2012-12-07 10:33:07 -0800 |
commit | 72c3f7d88160b7c279f90f0efe3c1cb12cd140ae (patch) | |
tree | 188fb5daa2eda66cbf271b1518836d998af4f818 | |
parent | 2e59d2c3fdc0bcfedbe9c5d04d7acadc3eff8887 (diff) | |
download | frameworks_native-72c3f7d88160b7c279f90f0efe3c1cb12cd140ae.zip frameworks_native-72c3f7d88160b7c279f90f0efe3c1cb12cd140ae.tar.gz frameworks_native-72c3f7d88160b7c279f90f0efe3c1cb12cd140ae.tar.bz2 |
Revert "ConsumerBase: free buffers outside the lock"
This reverts commit b21a4e3b5f7f07ed160ca6e1809313e2a8e2a6a4.
-rw-r--r-- | libs/gui/ConsumerBase.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp index cfc0293..624d7e0 100644 --- a/libs/gui/ConsumerBase.cpp +++ b/libs/gui/ConsumerBase.cpp @@ -109,35 +109,21 @@ void ConsumerBase::onFrameAvailable() { } void ConsumerBase::onBuffersReleased() { - sp<GraphicBuffer> bufRefs[BufferQueue::NUM_BUFFER_SLOTS]; - - { // Scope for the lock - Mutex::Autolock lock(mMutex); - - CB_LOGV("onBuffersReleased"); - - if (mAbandoned) { - // Nothing to do if we're already abandoned. - return; - } + Mutex::Autolock lock(mMutex); - uint32_t mask = 0; - mBufferQueue->getReleasedBuffers(&mask); - for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { - if (mask & (1 << i)) { - // Grab a local reference to the buffers so that they don't - // get freed while the lock is held. - bufRefs[i] = mSlots[i].mGraphicBuffer; + CB_LOGV("onBuffersReleased"); - freeBufferLocked(i); - } - } + if (mAbandoned) { + // Nothing to do if we're already abandoned. + return; } - // Clear the local buffer references. This would happen automatically - // when the array gets dtor'd, but I'm doing it explicitly for clarity. + uint32_t mask = 0; + mBufferQueue->getReleasedBuffers(&mask); for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { - bufRefs[i].clear(); + if (mask & (1 << i)) { + freeBufferLocked(i); + } } } |