Effect AIDL: Refactor effect capability with Range implementation
Bug: 258124419
Test: atest --test-mapping hardware/interfaces/audio/aidl/vts:presubmit
Change-Id: Ie76270e91471a30f7dda1883c510cd318745855f
diff --git a/audio/aidl/default/equalizer/EqualizerSw.h b/audio/aidl/default/equalizer/EqualizerSw.h
index fabcfeb..f8987c7 100644
--- a/audio/aidl/default/equalizer/EqualizerSw.h
+++ b/audio/aidl/default/equalizer/EqualizerSw.h
@@ -34,7 +34,7 @@
}
RetCode setEqPreset(const int& presetIdx) {
- if (presetIdx < 0 || presetIdx >= NUM_OF_PRESETS) {
+ if (presetIdx < 0 || presetIdx >= kMaxPresetNumber) {
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
mPreset = presetIdx;
@@ -43,13 +43,13 @@
int getEqPreset() { return mPreset; }
RetCode setEqBandLevels(const std::vector<Equalizer::BandLevel>& bandLevels) {
- if (bandLevels.size() > NUM_OF_BANDS) {
- LOG(ERROR) << __func__ << " return because size exceed " << NUM_OF_BANDS;
+ if (bandLevels.size() > kMaxBandNumber) {
+ LOG(ERROR) << __func__ << " return because size exceed " << kMaxBandNumber;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
RetCode ret = RetCode::SUCCESS;
for (auto& it : bandLevels) {
- if (it.index >= NUM_OF_BANDS || it.index < 0) {
+ if (it.index >= kMaxBandNumber || it.index < 0) {
LOG(ERROR) << __func__ << " index illegal, skip: " << it.index << " - "
<< it.levelMb;
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
@@ -62,7 +62,7 @@
std::vector<Equalizer::BandLevel> getEqBandLevels() {
std::vector<Equalizer::BandLevel> bandLevels;
- for (int i = 0; i < NUM_OF_BANDS; i++) {
+ for (int i = 0; i < kMaxBandNumber; i++) {
bandLevels.push_back({i, mBandLevels[i]});
}
return bandLevels;
@@ -71,16 +71,16 @@
std::vector<int> getCenterFreqs() {
return {std::begin(kPresetsFrequencies), std::end(kPresetsFrequencies)};
}
+ static const int kMaxBandNumber = 5;
+ static const int kMaxPresetNumber = 10;
+ static const int kCustomPreset = -1;
private:
- static const int NUM_OF_BANDS = 5;
- static const int NUM_OF_PRESETS = 10;
- static const int PRESET_CUSTOM = -1;
- static constexpr std::array<uint16_t, NUM_OF_BANDS> kPresetsFrequencies = {60, 230, 910, 3600,
- 14000};
+ static constexpr std::array<uint16_t, kMaxBandNumber> kPresetsFrequencies = {60, 230, 910, 3600,
+ 14000};
// preset band level
- int mPreset = PRESET_CUSTOM;
- int32_t mBandLevels[NUM_OF_BANDS] = {3, 0, 0, 0, 3};
+ int mPreset = kCustomPreset;
+ int32_t mBandLevels[kMaxBandNumber] = {3, 0, 0, 0, 3};
// Add equalizer specific context for processing here
};
@@ -88,9 +88,7 @@
class EqualizerSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const std::vector<Equalizer::BandFrequency> kBandFrequency;
- static const std::vector<Equalizer::Preset> kPresets;
- static const Equalizer::Capability kEqCap;
+ static const Capability kEqCap;
static const Descriptor kDesc;
EqualizerSw() { LOG(DEBUG) << __func__; }
@@ -112,6 +110,9 @@
std::string getEffectName() override { return kEffectName; }
private:
+ static const std::vector<Equalizer::BandFrequency> kBandFrequency;
+ static const std::vector<Equalizer::Preset> kPresets;
+ static const std::vector<Range::EqualizerRange> kRanges;
ndk::ScopedAStatus getParameterEqualizer(const Equalizer::Tag& tag,
Parameter::Specific* specific);
std::shared_ptr<EqualizerSwContext> mContext;