From 5c8b18c90806307939fd44c57855621ab004af8a Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Thu, 19 Aug 2021 16:52:34 -0700 Subject: Use a separate mutex for BLASTBufferQueue in BLASTBufferItemConsumer Avoids the following deadlock... Thread 1: * BLASTBufferQueue::transactionCallback acquires BLASTBufferQueue::mMutex * BLASTBufferItemConsumer::updateFrameTimestamps waits to acquire BLASTBufferItemConsumer::mMutex Thread 2: * BLASTBufferItemConsumer::onSidebandStreamChanged acquires BLASTBufferItemConsumer::mMutex * BLASTBufferQueue::setSidebandStream tries to acquire BLASTBufferQueue::mMutex Bug: 192998815 Test: Both CTS Media and Mediav2 (by partner) Change-Id: I37523031841db3f1a29481bbfa76d6c028a6942e --- libs/gui/BLASTBufferQueue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libs/gui/BLASTBufferQueue.cpp') diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index 56a9683773..d860f30617 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -118,12 +118,12 @@ void BLASTBufferItemConsumer::getConnectionEvents(uint64_t frameNumber, bool* ne } void BLASTBufferItemConsumer::setBlastBufferQueue(BLASTBufferQueue* blastbufferqueue) { - Mutex::Autolock lock(mMutex); + std::scoped_lock lock(mBufferQueueMutex); mBLASTBufferQueue = blastbufferqueue; } void BLASTBufferItemConsumer::onSidebandStreamChanged() { - Mutex::Autolock lock(mMutex); + std::scoped_lock lock(mBufferQueueMutex); if (mBLASTBufferQueue != nullptr) { sp stream = getSidebandStream(); mBLASTBufferQueue->setSidebandStream(stream); -- cgit v1.2.3-59-g8ed1b