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

Commit 7de02c90 authored by Andy Hung's avatar Andy Hung
Browse files

AudioFlinger: Fix FastMixer balance initialization

Fixes potential race conditon.
Fixes potential double application of balance in DuplicatingThread.

Flag: EXEMPT bugfix
Test: Balance settings work
Bug: 339571376
Bug: 339753488
Merged-In: Ica7c0deaa0d61fc356ceed0cbdc467a7d88770ac
Change-Id: Ica7c0deaa0d61fc356ceed0cbdc467a7d88770ac
parent ddc2de8f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -5092,7 +5092,6 @@ MixerThread::MixerThread(const sp<IAfThreadCallback>& afThreadCallback, AudioStr
        // mPipeSink below
        // mNormalSink below
{
    setMasterBalance(afThreadCallback->getMasterBalance_l());
    ALOGV("MixerThread() id=%d type=%d", id, type);
    ALOGV("mSampleRate=%u, mChannelMask=%#x, mChannelCount=%u, mFormat=%#x, mFrameSize=%zu, "
            "mFrameCount=%zu, mNormalFrameCount=%zu",
@@ -5104,6 +5103,8 @@ MixerThread::MixerThread(const sp<IAfThreadCallback>& afThreadCallback, AudioStr
        // The Duplicating thread uses the AudioMixer and delivers data to OutputTracks
        // (downstream MixerThreads) in DuplicatingThread::threadLoop_write().
        // Do not create or use mFastMixer, mOutputSink, mPipeSink, or mNormalSink.
        // Balance is *not* set in the DuplicatingThread here (or from AudioFlinger),
        // as the downstream MixerThreads implement it.
        return;
    }
    // create an NBAIO sink for the HAL output stream, and negotiate
@@ -5263,6 +5264,9 @@ MixerThread::MixerThread(const sp<IAfThreadCallback>& afThreadCallback, AudioStr
        mNormalSink = initFastMixer ? mPipeSink : mOutputSink;
        break;
    }
    // setMasterBalance needs to be called after the FastMixer
    // (if any) is set up, in order to deliver the balance settings to it.
    setMasterBalance(afThreadCallback->getMasterBalance_l());
}

MixerThread::~MixerThread()