Commit 245cc5b5 authored by Pablo Ceballos's avatar Pablo Ceballos
Browse files

BQ: Avoid unnecessary calls to consumer listener

Try to avoid unnecessary calls to the consumer listener's
onBuffersReleased() since they can potentially deadlock.

Bug 28254168

Change-Id: Ib064e5ebe1403a1028589342b3c33e6f40bb54a9
parent 9ffa1a4d
......@@ -622,6 +622,10 @@ status_t BufferQueueConsumer::setMaxAcquiredBufferCount(
return NO_INIT;
}
if (maxAcquiredBuffers == mCore->mMaxAcquiredBufferCount) {
return NO_ERROR;
}
// The new maxAcquiredBuffers count should not be violated by the number
// of currently acquired buffers
int acquiredCount = 0;
......
......@@ -101,6 +101,10 @@ status_t BufferQueueProducer::setMaxDequeuedBufferCount(
return NO_INIT;
}
if (maxDequeuedBuffers == mCore->mMaxDequeuedBufferCount) {
return NO_ERROR;
}
// The new maxDequeuedBuffer count should not be violated by the number
// of currently dequeued buffers
int dequeuedCount = 0;
......@@ -175,6 +179,10 @@ status_t BufferQueueProducer::setAsyncMode(bool async) {
return NO_INIT;
}
if (async == mCore->mAsyncMode) {
return NO_ERROR;
}
if ((mCore->mMaxAcquiredBufferCount + mCore->mMaxDequeuedBufferCount +
(async || mCore->mDequeueBufferCannotBlock ? 1 : 0)) >
mCore->mMaxBufferCount) {
......@@ -199,7 +207,9 @@ status_t BufferQueueProducer::setAsyncMode(bool async) {
mCore->mAsyncMode = async;
VALIDATE_CONSISTENCY();
mCore->mDequeueCondition.broadcast();
listener = mCore->mConsumerListener;
if (delta < 0) {
listener = mCore->mConsumerListener;
}
} // Autolock scope
// Call back without lock held
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment