From dc76ca00df27c563615d19727376c15c485c2b90 Mon Sep 17 00:00:00 2001 From: Ady Abraham Date: Wed, 15 Dec 2021 11:58:56 -0800 Subject: keep a wp in BufferItemConsumer Use a wp<> instead of raw pointer and remove the mutex around it to prevent potential deadlocks. Bug: 208121127 Test: stress test by partner Change-Id: Iffed80410aeffc9b724d5c01ca2ec589c9622990 Merged-In: Iffed80410aeffc9b724d5c01ca2ec589c9622990 --- libs/gui/BLASTBufferQueue.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'libs/gui/BLASTBufferQueue.cpp') diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index 94e1ae1c74..5b59c592df 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -117,16 +117,11 @@ void BLASTBufferItemConsumer::getConnectionEvents(uint64_t frameNumber, bool* ne if (needsDisconnect != nullptr) *needsDisconnect = disconnect; } -void BLASTBufferItemConsumer::setBlastBufferQueue(BLASTBufferQueue* blastbufferqueue) { - std::scoped_lock lock(mBufferQueueMutex); - mBLASTBufferQueue = blastbufferqueue; -} - void BLASTBufferItemConsumer::onSidebandStreamChanged() { - std::scoped_lock lock(mBufferQueueMutex); - if (mBLASTBufferQueue != nullptr) { + sp bbq = mBLASTBufferQueue.promote(); + if (bbq != nullptr) { sp stream = getSidebandStream(); - mBLASTBufferQueue->setSidebandStream(stream); + bbq->setSidebandStream(stream); } } @@ -147,7 +142,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const spsetBufferFreedListener(this); mBufferItemConsumer->setDefaultBufferSize(mSize.width, mSize.height); mBufferItemConsumer->setDefaultBufferFormat(convertBufferFormat(format)); - mBufferItemConsumer->setBlastBufferQueue(this); ComposerService::getComposerService()->getMaxAcquiredBufferCount(&mMaxAcquiredBuffers); mBufferItemConsumer->setMaxAcquiredBufferCount(mMaxAcquiredBuffers); @@ -177,7 +171,6 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const spsetBlastBufferQueue(nullptr); if (mPendingTransactions.empty()) { return; } -- cgit v1.2.3-59-g8ed1b