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

Commit 580a0d55 authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge "AudioMixer: Enable 5.1 based for fallback downmix"

parents abfb9a54 3adc55b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ status_t AudioMixer::Track::prepareForDownmix()

    // See if we should use our built-in non-effect downmixer.
    if (mMixerInFormat == AUDIO_FORMAT_PCM_FLOAT
            && mMixerChannelMask == AUDIO_CHANNEL_OUT_STEREO
            && ChannelMixBufferProvider::isOutputChannelMaskSupported(mMixerChannelMask)
            && audio_channel_mask_get_representation(channelMask)
                    == AUDIO_CHANNEL_REPRESENTATION_POSITION) {
        mDownmixerBufferProvider.reset(new ChannelMixBufferProvider(channelMask,
+10 −5
Original line number Diff line number Diff line
@@ -373,18 +373,23 @@ ChannelMixBufferProvider::ChannelMixBufferProvider(audio_channel_mask_t inputCha
                audio_bytes_per_sample(format)
                    * audio_channel_count_from_out_mask(outputChannelMask),
                bufferFrameCount)
        , mChannelMix{format == AUDIO_FORMAT_PCM_FLOAT
                ? audio_utils::channels::IChannelMix::create(outputChannelMask) : nullptr}
        , mIsValid{mChannelMix && mChannelMix->setInputChannelMask(inputChannelMask)}
{
    ALOGV("ChannelMixBufferProvider(%p)(%#x, %#x, %#x)",
            this, format, inputChannelMask, outputChannelMask);
    if (outputChannelMask == AUDIO_CHANNEL_OUT_STEREO && format == AUDIO_FORMAT_PCM_FLOAT) {
        mIsValid = mChannelMix.setInputChannelMask(inputChannelMask);
    }
}

void ChannelMixBufferProvider::copyFrames(void *dst, const void *src, size_t frames)
{
    mChannelMix.process(static_cast<const float *>(src), static_cast<float *>(dst),
    if (mIsValid) {
        mChannelMix->process(static_cast<const float *>(src), static_cast<float *>(dst),
                frames, false /* accumulate */);
    } else {
        // Should fall back to a different BufferProvider if not valid.
        ALOGE("%s: Use without being valid!", __func__);
    }
}

ReformatBufferProvider::ReformatBufferProvider(int32_t channelCount,
+7 −2
Original line number Diff line number Diff line
@@ -142,9 +142,14 @@ public:

    bool isValid() const { return mIsValid; }

    static bool isOutputChannelMaskSupported(audio_channel_mask_t outputChannelMask) {
        return audio_utils::channels::IChannelMix::isOutputChannelMaskSupported(
                outputChannelMask);
    }

protected:
    audio_utils::channels::ChannelMix<AUDIO_CHANNEL_OUT_STEREO> mChannelMix;
    bool mIsValid = false;
    const std::shared_ptr<audio_utils::channels::IChannelMix> mChannelMix;
    const bool mIsValid;
};

// RemixBufferProvider derives from CopyBufferProvider to perform an
+2 −2
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ static int32_t DownmixLib_Create(const effect_uuid_t *uuid,
    ret = Downmix_Init(module);
    if (ret < 0) {
        ALOGW("DownmixLib_Create() init failed");
        free(module);
        delete module;
        return ret;
    }

@@ -582,7 +582,7 @@ static int Downmix_Init(downmix_module_t *pDwmModule) {
    ALOGV("Downmix_Init module %p", pDwmModule);
    int ret = 0;

    memset(&pDwmModule->context, 0, sizeof(downmix_object_t));
    pDwmModule->context = downmix_object_t{};  // zero initialize (contains class with vtable).

    pDwmModule->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
    pDwmModule->config.inputCfg.format = AUDIO_FORMAT_PCM_FLOAT;