Merge "BufferQueue: Hook up IProducerListener"

This commit is contained in:
Dan Stoza 2014-04-14 16:26:42 +00:00 committed by Android (Google) Code Review
commit 7f605bd4c0

View File

@ -22,6 +22,7 @@
#include <gui/BufferQueueConsumer.h>
#include <gui/BufferQueueCore.h>
#include <gui/IConsumerListener.h>
#include <gui/IProducerListener.h>
namespace android {
@ -261,6 +262,8 @@ status_t BufferQueueConsumer::releaseBuffer(int slot, uint64_t frameNumber,
return BAD_VALUE;
}
sp<IProducerListener> listener;
{ // Autolock scope
Mutex::Autolock lock(mCore->mMutex);
// If the frame number has changed because the buffer has been reallocated,
@ -285,6 +288,8 @@ status_t BufferQueueConsumer::releaseBuffer(int slot, uint64_t frameNumber,
mSlots[slot].mEglFence = eglFence;
mSlots[slot].mFence = releaseFence;
mSlots[slot].mBufferState = BufferSlot::FREE;
listener = mCore->mConnectedProducerListener;
BQ_LOGV("releaseBuffer: releasing slot %d", slot);
} else if (mSlots[slot].mNeedsCleanupOnRelease) {
BQ_LOGV("releaseBuffer: releasing a stale buffer slot %d "
"(state = %d)", slot, mSlots[slot].mBufferState);
@ -297,6 +302,12 @@ status_t BufferQueueConsumer::releaseBuffer(int slot, uint64_t frameNumber,
}
mCore->mDequeueCondition.broadcast();
} // Autolock scope
// Call back without lock held
if (listener != NULL) {
listener->onBufferReleased();
}
return NO_ERROR;
}