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

Commit 03c48d5a authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Add limiter for mono blend

Bug: 26904791
Change-Id: I76b16e70871cd9fc0a9b8badc66f27069fabe1cb
parent 16558ea3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -416,7 +416,7 @@ void FastMixer::onWork()
        }
        }


        if (mMasterMono.load()) {  // memory_order_seq_cst
        if (mMasterMono.load()) {  // memory_order_seq_cst
            mono_blend(mMixerBuffer, mMixerBufferFormat, Format_channelCount(mFormat), frameCount);
            mono_blend(mMixerBuffer, mMixerBufferFormat, Format_channelCount(mFormat), frameCount, true /*limit*/);
        }
        }
        // prepare the buffer used to write to sink
        // prepare the buffer used to write to sink
        void *buffer = mSinkBuffer != NULL ? mSinkBuffer : mMixerBuffer;
        void *buffer = mSinkBuffer != NULL ? mSinkBuffer : mMixerBuffer;
+4 −3
Original line number Original line Diff line number Diff line
@@ -2917,8 +2917,8 @@ bool AudioFlinger::PlaybackThread::threadLoop()
                // mono blend occurs for mixer threads only (not direct or offloaded)
                // mono blend occurs for mixer threads only (not direct or offloaded)
                // and is handled here if we're going directly to the sink.
                // and is handled here if we're going directly to the sink.
                if (requireMonoBlend() && !mEffectBufferValid) {
                if (requireMonoBlend() && !mEffectBufferValid) {
                    mono_blend(
                    mono_blend(mMixerBuffer, mMixerBufferFormat, mChannelCount, mNormalFrameCount,
                            mMixerBuffer, mMixerBufferFormat, mChannelCount, mNormalFrameCount);
                               true /*limit*/);
                }
                }


                memcpy_by_audio_format(buffer, format, mMixerBuffer, mMixerBufferFormat,
                memcpy_by_audio_format(buffer, format, mMixerBuffer, mMixerBufferFormat,
@@ -2958,7 +2958,8 @@ bool AudioFlinger::PlaybackThread::threadLoop()
            //ALOGV("writing effect buffer to sink buffer format %#x", mFormat);
            //ALOGV("writing effect buffer to sink buffer format %#x", mFormat);


            if (requireMonoBlend()) {
            if (requireMonoBlend()) {
                mono_blend(mEffectBuffer, mEffectBufferFormat, mChannelCount, mNormalFrameCount);
                mono_blend(mEffectBuffer, mEffectBufferFormat, mChannelCount, mNormalFrameCount,
                           true /*limit*/);
            }
            }


            memcpy_by_audio_format(mSinkBuffer, mFormat, mEffectBuffer, mEffectBufferFormat,
            memcpy_by_audio_format(mSinkBuffer, mFormat, mEffectBuffer, mEffectBufferFormat,
+2 −0
Original line number Original line Diff line number Diff line
@@ -927,6 +927,8 @@ protected:
                               }
                               }
                           }
                           }
                // the FastMixer performs mono blend if it exists.
                // the FastMixer performs mono blend if it exists.
                // Blending with limiter is not idempotent,
                // and blending without limiter is idempotent but inefficient to do twice.
    virtual     bool       requireMonoBlend() { return mMasterMono.load() && !hasFastMixer(); }
    virtual     bool       requireMonoBlend() { return mMasterMono.load() && !hasFastMixer(); }
};
};