am b21a4e3b: ConsumerBase: free buffers outside the lock

* commit 'b21a4e3b5f7f07ed160ca6e1809313e2a8e2a6a4':
  ConsumerBase: free buffers outside the lock
This commit is contained in:
Jamie Gennis 2012-12-06 18:37:24 -08:00 committed by Android Git Automerger
commit 3ed2736c10

View File

@ -109,6 +109,9 @@ void ConsumerBase::onFrameAvailable() {
}
void ConsumerBase::onBuffersReleased() {
sp<GraphicBuffer> bufRefs[BufferQueue::NUM_BUFFER_SLOTS];
{ // Scope for the lock
Mutex::Autolock lock(mMutex);
CB_LOGV("onBuffersReleased");
@ -122,9 +125,20 @@ void ConsumerBase::onBuffersReleased() {
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);
}
}
}
// Clear the local buffer references. This would happen automatically
// when the array gets dtor'd, but I'm doing it explicitly for clarity.
for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
bufRefs[i].clear();
}
}
void ConsumerBase::abandon() {