Revert "ConsumerBase: free buffers outside the lock"

This reverts commit b21a4e3b5f.
This commit is contained in:
Jamie Gennis 2012-12-07 00:41:56 -08:00
parent 2e59d2c3fd
commit 72c3f7d881

View File

@ -109,35 +109,21 @@ void ConsumerBase::onFrameAvailable() {
}
void ConsumerBase::onBuffersReleased() {
sp<GraphicBuffer> bufRefs[BufferQueue::NUM_BUFFER_SLOTS];
Mutex::Autolock lock(mMutex);
{ // Scope for the lock
Mutex::Autolock lock(mMutex);
CB_LOGV("onBuffersReleased");
CB_LOGV("onBuffersReleased");
if (mAbandoned) {
// Nothing to do if we're already abandoned.
return;
}
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;
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);
}
}
}