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

Commit 66942550 authored by Andy Hung's avatar Andy Hung
Browse files

AudioMixer: Accept a float downmixer

Test: Play Music with multichannel source using float and int16 downmixer
Bug: 121222814
Change-Id: I1057b3a2f342e42ab56652f724111fa7cd68d1cf
parent ddafe428
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -302,15 +302,20 @@ status_t AudioMixer::Track::prepareForDownmix()
    if (audio_channel_mask_get_representation(channelMask)
                == AUDIO_CHANNEL_REPRESENTATION_POSITION
            && DownmixerBufferProvider::isMultichannelCapable()) {
        mDownmixerBufferProvider.reset(new DownmixerBufferProvider(channelMask,
                mMixerChannelMask,
                AUDIO_FORMAT_PCM_16_BIT /* TODO: use mMixerInFormat, now only PCM 16 */,

        // Check if we have a float or int16 downmixer, in that order.
        for (const audio_format_t format : { AUDIO_FORMAT_PCM_FLOAT, AUDIO_FORMAT_PCM_16_BIT }) {
            mDownmixerBufferProvider.reset(new DownmixerBufferProvider(
                    channelMask, mMixerChannelMask,
                    format,
                    sampleRate, sessionId, kCopyBufferFrameCount));
        if (static_cast<DownmixerBufferProvider *>(mDownmixerBufferProvider.get())->isValid()) {
            mDownmixRequiresFormat = AUDIO_FORMAT_PCM_16_BIT; // PCM 16 bit required for downmix
            if (static_cast<DownmixerBufferProvider *>(mDownmixerBufferProvider.get())
                    ->isValid()) {
                mDownmixRequiresFormat = format;
                reconfigureBufferProviders();
                return NO_ERROR;
            }
        }
        // mDownmixerBufferProvider reset below.
    }