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

Commit 783a1eb9 authored by jiabin's avatar jiabin
Browse files

Fix internal mute issues with bit-perfect playback.

When updating internal mute, it accesses the track collection, which
should be protected by the lock.
For a bit-perfect client, if it is muted internally, it is no needed to
stream it bit-perfectly.

Bug: 357786293
Test: manually
Flag: EXEMPT bugfix
Change-Id: I0c66380558da82bbe05c22c97f8532d0dae5ea59
parent 5be5d604
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -11603,6 +11603,7 @@ void BitPerfectThread::threadLoop_mix() {

void BitPerfectThread::setTracksInternalMute(
        std::map<audio_port_handle_t, bool>* tracksInternalMute) {
    audio_utils::lock_guard _l(mutex());
    for (auto& track : mTracks) {
        if (auto it = tracksInternalMute->find(track->portId()); it != tracksInternalMute->end()) {
            track->setInternalMute(it->second);
@@ -11619,6 +11620,11 @@ sp<IAfTrack> BitPerfectThread::getTrackToStreamBitPerfectly_l() {
        // Return the bit perfect track if all other tracks are muted
        for (const auto& track : mActiveTracks) {
            if (track->isBitPerfect()) {
                if (track->getInternalMute()) {
                    // There can only be one bit-perfect client active. If it is mute internally,
                    // there is no need to stream bit-perfectly.
                    break;
                }
                bitPerfectTrack = track;
            } else if (track->getFinalVolume() != 0.f) {
                allOtherTracksMuted = false;