Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c8b18c9 authored by Alec Mouri's avatar Alec Mouri Committed by Ady Abraham
Browse files

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
parent 66a59c3e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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<NativeHandle> stream = getSidebandStream();
        mBLASTBufferQueue->setSidebandStream(stream);
+2 −1
Original line number Diff line number Diff line
@@ -62,11 +62,12 @@ private:
    uint64_t mCurrentFrameNumber = 0;

    Mutex mMutex;
    std::mutex mBufferQueueMutex;
    ConsumerFrameEventHistory mFrameEventHistory GUARDED_BY(mMutex);
    std::queue<uint64_t> mDisconnectEvents GUARDED_BY(mMutex);
    bool mCurrentlyConnected GUARDED_BY(mMutex);
    bool mPreviouslyConnected GUARDED_BY(mMutex);
    BLASTBufferQueue* mBLASTBufferQueue GUARDED_BY(mMutex);
    BLASTBufferQueue* mBLASTBufferQueue GUARDED_BY(mBufferQueueMutex);
};

class BLASTBufferQueue