From b6f8479039c1462a0f2e041d6376e3e208bbb70f 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 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 2104c77275..f034642681 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); @@ -173,7 +167,6 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const spsetBlastBufferQueue(nullptr); if (mPendingTransactions.empty()) { return; } -- cgit v1.2.3-59-g8ed1b