am 72c3f7d8
: Revert "ConsumerBase: free buffers outside the lock"
* commit '72c3f7d88160b7c279f90f0efe3c1cb12cd140ae': Revert "ConsumerBase: free buffers outside the lock"
This commit is contained in:
commit
d4e706208c
@ -109,35 +109,21 @@ void ConsumerBase::onFrameAvailable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConsumerBase::onBuffersReleased() {
|
void ConsumerBase::onBuffersReleased() {
|
||||||
sp<GraphicBuffer> bufRefs[BufferQueue::NUM_BUFFER_SLOTS];
|
Mutex::Autolock lock(mMutex);
|
||||||
|
|
||||||
{ // Scope for the lock
|
CB_LOGV("onBuffersReleased");
|
||||||
Mutex::Autolock lock(mMutex);
|
|
||||||
|
|
||||||
CB_LOGV("onBuffersReleased");
|
if (mAbandoned) {
|
||||||
|
// Nothing to do if we're already abandoned.
|
||||||
if (mAbandoned) {
|
return;
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the local buffer references. This would happen automatically
|
uint32_t mask = 0;
|
||||||
// when the array gets dtor'd, but I'm doing it explicitly for clarity.
|
mBufferQueue->getReleasedBuffers(&mask);
|
||||||
for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
|
for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
|
||||||
bufRefs[i].clear();
|
if (mask & (1 << i)) {
|
||||||
|
freeBufferLocked(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user