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

Commit e5b113e9 authored by David Li's avatar David Li Committed by Automerger Merge Worker
Browse files

Merge "AudioFlinger: avoid doing balance before downmixing" into tm-d1-dev am: 8edaa192

parents 88b2eee3 8edaa192
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -3967,20 +3967,25 @@ bool AudioFlinger::PlaybackThread::threadLoop()
                void *buffer = mEffectBufferValid ? mEffectBuffer : mSinkBuffer;
                audio_format_t format = mEffectBufferValid ? mEffectBufferFormat : mFormat;

                // Apply mono blending and balancing if the effect buffer is not valid. Otherwise,
                // do these processes after effects are applied.
                if (!mEffectBufferValid) {
                    // mono blend occurs for mixer threads only (not direct or offloaded)
                    // and is handled here if we're going directly to the sink.
                if (requireMonoBlend() && !mEffectBufferValid) {
                    mono_blend(mMixerBuffer, mMixerBufferFormat, mChannelCount, mNormalFrameCount,
                               true /*limit*/);
                    if (requireMonoBlend()) {
                        mono_blend(mMixerBuffer, mMixerBufferFormat, mChannelCount,
                                mNormalFrameCount, true /*limit*/);
                    }

                    if (!hasFastMixer()) {
                        // Balance must take effect after mono conversion.
                        // We do it here if there is no FastMixer.
                    // mBalance detects zero balance within the class for speed (not needed here).
                        // mBalance detects zero balance within the class for speed
                        // (not needed here).
                        mBalance.setBalance(mMasterBalance.load());
                        mBalance.process((float *)mMixerBuffer, mNormalFrameCount);
                    }
                }

                memcpy_by_audio_format(buffer, format, mMixerBuffer, mMixerBufferFormat,
                        mNormalFrameCount * (mixerChannelCount + mHapticChannelCount));