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

Commit 0455f691 authored by jiabin's avatar jiabin
Browse files

Hold thread lock before calling updateSecondaryOutputsForTrack_l.

Bug: 276314585
Test: atest AudioPlaybackCaptureTest
Test: Live Caption
Change-Id: Ifddfb3d0e7f8057c3553b4ac1717fcc9bb6b53c7
parent 9e42c00d
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -1236,23 +1236,22 @@ status_t AudioFlinger::createTrack(const media::CreateTrackRequest& _input,
        output.portId = portId;

        if (lStatus == NO_ERROR) {
            // no risk of deadlock because AudioFlinger::mLock is held
            Mutex::Autolock _dl(thread->mLock);
            // Connect secondary outputs. Failure on a secondary output must not imped the primary
            // Any secondary output setup failure will lead to a desync between the AP and AF until
            // the track is destroyed.
            updateSecondaryOutputsForTrack_l(track.get(), thread, secondaryOutputs);
        }

            // move effect chain to this output thread if an effect on same session was waiting
            // for a track to be created
        if (lStatus == NO_ERROR && effectThread != NULL) {
            // no risk of deadlock because AudioFlinger::mLock is held
            Mutex::Autolock _dl(thread->mLock);
            if (effectThread != nullptr) {
                Mutex::Autolock _sl(effectThread->mLock);
                if (moveEffectChain_l(sessionId, effectThread, thread) == NO_ERROR) {
                    effectThreadId = thread->id();
                    effectIds = thread->getEffectIds_l(sessionId);
                }
            }
        }

        // Look for sync events awaiting for a session to be used.
        for (size_t i = 0; i < mPendingSyncEvents.size(); i++) {