Loading media/libaudioprocessing/AudioMixer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading media/libaudioprocessing/BufferProviders.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -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, Loading media/libaudioprocessing/include/media/BufferProviders.h +7 −2 Original line number Diff line number Diff line Loading @@ -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 Loading media/libeffects/downmix/EffectDownmix.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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; Loading Loading
media/libaudioprocessing/AudioMixer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -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, Loading
media/libaudioprocessing/BufferProviders.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -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, Loading
media/libaudioprocessing/include/media/BufferProviders.h +7 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
media/libeffects/downmix/EffectDownmix.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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; Loading