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

Commit 95c94a2e authored by Andy Hung's avatar Andy Hung
Browse files

AudioFlinger: Fix lock inversion for timestampCorrectionEnabled

Test: see bug for dynamic lock inversion detection
Bug: 302532421
Bug: 306751935
Change-Id: I31b6c3494ba710fba9ebee42f6570ff9b38fe221
parent bb6b1223
Loading
Loading
Loading
Loading
+4 −7
Original line number Original line Diff line number Diff line
@@ -8106,6 +8106,9 @@ reacquire_wakelock:
    // used to request a deferred sleep, to be executed later while mutex is unlocked
    // used to request a deferred sleep, to be executed later while mutex is unlocked
    uint32_t sleepUs = 0;
    uint32_t sleepUs = 0;


    // timestamp correction enable is determined under lock, used in processing step.
    bool timestampCorrectionEnabled = false;

    int64_t lastLoopCountRead = -2;  // never matches "previous" loop, when loopCount = 0.
    int64_t lastLoopCountRead = -2;  // never matches "previous" loop, when loopCount = 0.


    // loop while there is work to do
    // loop while there is work to do
@@ -8276,6 +8279,7 @@ reacquire_wakelock:
            }
            }
            sleepUs = 0;
            sleepUs = 0;


            timestampCorrectionEnabled = isTimestampCorrectionEnabled_l();
            lockEffectChains_l(effectChains);
            lockEffectChains_l(effectChains);
        }
        }


@@ -8432,13 +8436,6 @@ reacquire_wakelock:
                    && time > mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL]) {
                    && time > mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL]) {


                mTimestampVerifier.add(position, time, mSampleRate);
                mTimestampVerifier.add(position, time, mSampleRate);

                // Correct timestamps
                bool timestampCorrectionEnabled = false;
                {
                    audio_utils::lock_guard l(mutex());
                    timestampCorrectionEnabled = isTimestampCorrectionEnabled_l();
                }
                if (timestampCorrectionEnabled) {
                if (timestampCorrectionEnabled) {
                    ALOGVV("TS_BEFORE: %d %lld %lld",
                    ALOGVV("TS_BEFORE: %d %lld %lld",
                            id(), (long long)time, (long long)position);
                            id(), (long long)time, (long long)position);