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
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index 56a9683..d860f30 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -118,12 +118,12 @@
}
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<NativeHandle> stream = getSidebandStream();
mBLASTBufferQueue->setSidebandStream(stream);