diff options
| author | 2021-12-15 11:58:56 -0800 | |
|---|---|---|
| committer | 2022-01-05 14:20:49 -0800 | |
| commit | dbca1353f2c660ec4815da6497ee161cdda721ce (patch) | |
| tree | 22ec710a86c8c44997f27e0411f8cdae60138259 /libs/gui/BLASTBufferQueue.cpp | |
| parent | 14e7dc8bc7503d2ca0d525a0e5909c29056f8320 (diff) | |
keep a wp<BLASTBufferQueue> 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
Diffstat (limited to 'libs/gui/BLASTBufferQueue.cpp')
| -rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
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<BLASTBufferQueue> bbq = mBLASTBufferQueue.promote(); + if (bbq != nullptr) { sp<NativeHandle> 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 sp<SurfaceCont } BLASTBufferQueue::~BLASTBufferQueue() { - mBufferItemConsumer->setBlastBufferQueue(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; |