Loading media/libeffects/downmix/aidl/DownmixContext.cpp +50 −16 Original line number Diff line number Diff line Loading @@ -20,12 +20,60 @@ #include "DownmixContext.h" using aidl::android::hardware::audio::effect::IEffect; using aidl::android::hardware::audio::common::getChannelCount; using aidl::android::hardware::audio::effect::IEffect; using aidl::android::media::audio::common::AudioChannelLayout; using aidl::android::media::audio::common::AudioConfig; namespace aidl::android::hardware::audio::effect { namespace { inline bool isChannelMaskValid(const AudioChannelLayout& channelMask) { if (channelMask.getTag() != AudioChannelLayout::layoutMask) return false; int chMask = channelMask.get<AudioChannelLayout::layoutMask>(); // check against unsupported channels (up to FCC_26) constexpr uint32_t MAXIMUM_CHANNEL_MASK = AudioChannelLayout::LAYOUT_22POINT2 | AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT | AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT; if (chMask & ~MAXIMUM_CHANNEL_MASK) { LOG(ERROR) << "Unsupported channels in " << (chMask & ~MAXIMUM_CHANNEL_MASK); return false; } return true; } inline bool isStereoChannelMask(const AudioChannelLayout& channelMask) { if (channelMask.getTag() != AudioChannelLayout::layoutMask) return false; return channelMask.get<AudioChannelLayout::layoutMask>() == AudioChannelLayout::LAYOUT_STEREO; } } // namespace bool DownmixContext::validateCommonConfig(const Parameter::Common& common) { const AudioConfig& input = common.input; const AudioConfig& output = common.output; if (input.base.sampleRate != output.base.sampleRate) { LOG(ERROR) << __func__ << ": SRC not supported, input: " << input.toString() << " output: " << output.toString(); return false; } if (!isStereoChannelMask(output.base.channelMask)) { LOG(ERROR) << __func__ << ": output should be stereo, not " << output.base.channelMask.toString(); return false; } if (!isChannelMaskValid(input.base.channelMask)) { LOG(ERROR) << __func__ << ": invalid input channel, " << input.base.channelMask.toString(); return false; } return true; } DownmixContext::DownmixContext(int statusDepth, const Parameter::Common& common) : EffectContext(statusDepth, common) { LOG(DEBUG) << __func__; Loading Loading @@ -62,7 +110,7 @@ void DownmixContext::reset() { resetBuffer(); } IEffect::Status DownmixContext::lvmProcess(float* in, float* out, int samples) { IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int samples) { LOG(DEBUG) << __func__ << " in " << in << " out " << out << " sample " << samples; IEffect::Status status = {EX_ILLEGAL_ARGUMENT, 0, 0}; Loading Loading @@ -122,18 +170,4 @@ void DownmixContext::init_params(const Parameter::Common& common) { } } bool DownmixContext::isChannelMaskValid(AudioChannelLayout channelMask) { if (channelMask.getTag() != AudioChannelLayout::layoutMask) return false; int chMask = channelMask.get<AudioChannelLayout::layoutMask>(); // check against unsupported channels (up to FCC_26) constexpr uint32_t MAXIMUM_CHANNEL_MASK = AudioChannelLayout::LAYOUT_22POINT2 | AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT | AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT; if (chMask & ~MAXIMUM_CHANNEL_MASK) { LOG(ERROR) << "Unsupported channels in " << (chMask & ~MAXIMUM_CHANNEL_MASK); return false; } return true; } } // namespace aidl::android::hardware::audio::effect media/libeffects/downmix/aidl/DownmixContext.h +3 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,9 @@ class DownmixContext final : public EffectContext { return RetCode::SUCCESS; } IEffect::Status lvmProcess(float* in, float* out, int samples); IEffect::Status downmixProcess(float* in, float* out, int samples); static bool validateCommonConfig(const Parameter::Common& common); private: DownmixState mState; Loading @@ -60,7 +62,6 @@ class DownmixContext final : public EffectContext { // Common Params void init_params(const Parameter::Common& common); bool isChannelMaskValid(::aidl::android::media::audio::common::AudioChannelLayout channelMask); }; } // namespace aidl::android::hardware::audio::effect media/libeffects/downmix/aidl/EffectDownmix.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -193,6 +193,8 @@ std::shared_ptr<EffectContext> DownmixImpl::createContext(const Parameter::Commo return mContext; } if (!DownmixContext::validateCommonConfig(common)) return nullptr; mContext = std::make_shared<DownmixContext>(1 /* statusFmqDepth */, common); return mContext; } Loading @@ -210,7 +212,7 @@ IEffect::Status DownmixImpl::effectProcessImpl(float* in, float* out, int sample LOG(ERROR) << __func__ << " nullContext"; return {EX_NULL_POINTER, 0, 0}; } return mContext->lvmProcess(in, out, sampleToProcess); return mContext->downmixProcess(in, out, sampleToProcess); } } // namespace aidl::android::hardware::audio::effect Loading
media/libeffects/downmix/aidl/DownmixContext.cpp +50 −16 Original line number Diff line number Diff line Loading @@ -20,12 +20,60 @@ #include "DownmixContext.h" using aidl::android::hardware::audio::effect::IEffect; using aidl::android::hardware::audio::common::getChannelCount; using aidl::android::hardware::audio::effect::IEffect; using aidl::android::media::audio::common::AudioChannelLayout; using aidl::android::media::audio::common::AudioConfig; namespace aidl::android::hardware::audio::effect { namespace { inline bool isChannelMaskValid(const AudioChannelLayout& channelMask) { if (channelMask.getTag() != AudioChannelLayout::layoutMask) return false; int chMask = channelMask.get<AudioChannelLayout::layoutMask>(); // check against unsupported channels (up to FCC_26) constexpr uint32_t MAXIMUM_CHANNEL_MASK = AudioChannelLayout::LAYOUT_22POINT2 | AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT | AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT; if (chMask & ~MAXIMUM_CHANNEL_MASK) { LOG(ERROR) << "Unsupported channels in " << (chMask & ~MAXIMUM_CHANNEL_MASK); return false; } return true; } inline bool isStereoChannelMask(const AudioChannelLayout& channelMask) { if (channelMask.getTag() != AudioChannelLayout::layoutMask) return false; return channelMask.get<AudioChannelLayout::layoutMask>() == AudioChannelLayout::LAYOUT_STEREO; } } // namespace bool DownmixContext::validateCommonConfig(const Parameter::Common& common) { const AudioConfig& input = common.input; const AudioConfig& output = common.output; if (input.base.sampleRate != output.base.sampleRate) { LOG(ERROR) << __func__ << ": SRC not supported, input: " << input.toString() << " output: " << output.toString(); return false; } if (!isStereoChannelMask(output.base.channelMask)) { LOG(ERROR) << __func__ << ": output should be stereo, not " << output.base.channelMask.toString(); return false; } if (!isChannelMaskValid(input.base.channelMask)) { LOG(ERROR) << __func__ << ": invalid input channel, " << input.base.channelMask.toString(); return false; } return true; } DownmixContext::DownmixContext(int statusDepth, const Parameter::Common& common) : EffectContext(statusDepth, common) { LOG(DEBUG) << __func__; Loading Loading @@ -62,7 +110,7 @@ void DownmixContext::reset() { resetBuffer(); } IEffect::Status DownmixContext::lvmProcess(float* in, float* out, int samples) { IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int samples) { LOG(DEBUG) << __func__ << " in " << in << " out " << out << " sample " << samples; IEffect::Status status = {EX_ILLEGAL_ARGUMENT, 0, 0}; Loading Loading @@ -122,18 +170,4 @@ void DownmixContext::init_params(const Parameter::Common& common) { } } bool DownmixContext::isChannelMaskValid(AudioChannelLayout channelMask) { if (channelMask.getTag() != AudioChannelLayout::layoutMask) return false; int chMask = channelMask.get<AudioChannelLayout::layoutMask>(); // check against unsupported channels (up to FCC_26) constexpr uint32_t MAXIMUM_CHANNEL_MASK = AudioChannelLayout::LAYOUT_22POINT2 | AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT | AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT; if (chMask & ~MAXIMUM_CHANNEL_MASK) { LOG(ERROR) << "Unsupported channels in " << (chMask & ~MAXIMUM_CHANNEL_MASK); return false; } return true; } } // namespace aidl::android::hardware::audio::effect
media/libeffects/downmix/aidl/DownmixContext.h +3 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,9 @@ class DownmixContext final : public EffectContext { return RetCode::SUCCESS; } IEffect::Status lvmProcess(float* in, float* out, int samples); IEffect::Status downmixProcess(float* in, float* out, int samples); static bool validateCommonConfig(const Parameter::Common& common); private: DownmixState mState; Loading @@ -60,7 +62,6 @@ class DownmixContext final : public EffectContext { // Common Params void init_params(const Parameter::Common& common); bool isChannelMaskValid(::aidl::android::media::audio::common::AudioChannelLayout channelMask); }; } // namespace aidl::android::hardware::audio::effect
media/libeffects/downmix/aidl/EffectDownmix.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -193,6 +193,8 @@ std::shared_ptr<EffectContext> DownmixImpl::createContext(const Parameter::Commo return mContext; } if (!DownmixContext::validateCommonConfig(common)) return nullptr; mContext = std::make_shared<DownmixContext>(1 /* statusFmqDepth */, common); return mContext; } Loading @@ -210,7 +212,7 @@ IEffect::Status DownmixImpl::effectProcessImpl(float* in, float* out, int sample LOG(ERROR) << __func__ << " nullContext"; return {EX_NULL_POINTER, 0, 0}; } return mContext->lvmProcess(in, out, sampleToProcess); return mContext->downmixProcess(in, out, sampleToProcess); } } // namespace aidl::android::hardware::audio::effect