From dbca1353f2c660ec4815da6497ee161cdda721ce 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 Test: atest BLASTBufferQueueTest Change-Id: Iffed80410aeffc9b724d5c01ca2ec589c9622990 --- libs/gui/BLASTBufferQueue.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'libs/gui/BLASTBufferQueue.cpp') diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index 34faf87546..46de2cb222 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -119,16 +119,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); } } @@ -148,7 +143,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name) mBufferItemConsumer = new BLASTBufferItemConsumer(mConsumer, GraphicBuffer::USAGE_HW_COMPOSER | GraphicBuffer::USAGE_HW_TEXTURE, - 1, false); + 1, false, this); static int32_t id = 0; mName = name + "#" + std::to_string(id); auto consumerName = mName + "(BLAST Consumer)" + std::to_string(id); @@ -157,7 +152,6 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name) mBufferItemConsumer->setName(String8(consumerName.c_str())); mBufferItemConsumer->setFrameAvailableListener(this); mBufferItemConsumer->setBufferFreedListener(this); - mBufferItemConsumer->setBlastBufferQueue(this); ComposerService::getComposerService()->getMaxAcquiredBufferCount(&mMaxAcquiredBuffers); mBufferItemConsumer->setMaxAcquiredBufferCount(mMaxAcquiredBuffers); @@ -174,7 +168,6 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const spsetBlastBufferQueue(nullptr); if (mPendingTransactions.empty()) { return; } @@ -1025,7 +1018,6 @@ void BLASTBufferQueue::abandon() { mBufferItemConsumer->abandon(); mBufferItemConsumer->setFrameAvailableListener(nullptr); mBufferItemConsumer->setBufferFreedListener(nullptr); - mBufferItemConsumer->setBlastBufferQueue(nullptr); } mBufferItemConsumer = nullptr; mConsumer = nullptr; -- cgit v1.2.3-59-g8ed1b