Shraddha Basantwani | cac2e68 | 2023-02-15 18:03:58 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2023 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include "effect-impl/EffectImpl.h" |
Shraddha Basantwani | cac2e68 | 2023-02-15 18:03:58 +0530 | [diff] [blame] | 20 | |
| 21 | namespace aidl::android::hardware::audio::effect { |
| 22 | |
| 23 | class AutomaticGainControlV1SwContext final : public EffectContext { |
| 24 | public: |
| 25 | AutomaticGainControlV1SwContext(int statusDepth, const Parameter::Common& common) |
| 26 | : EffectContext(statusDepth, common) { |
| 27 | LOG(DEBUG) << __func__; |
| 28 | } |
| 29 | |
| 30 | RetCode setTargetPeakLevel(int targetPeakLevel); |
| 31 | int getTargetPeakLevel(); |
| 32 | RetCode setMaxCompressionGain(int maxCompressionGainDb); |
| 33 | int getMaxCompressionGain(); |
| 34 | RetCode setEnableLimiter(bool enableLimiter); |
| 35 | bool getEnableLimiter(); |
| 36 | |
| 37 | private: |
| 38 | int mTargetPeakLevel = 0; |
| 39 | int mMaxCompressionGain = 0; |
| 40 | bool mEnableLimiter = false; |
| 41 | }; |
| 42 | |
| 43 | class AutomaticGainControlV1Sw final : public EffectImpl { |
| 44 | public: |
| 45 | static const std::string kEffectName; |
| 46 | static const bool kStrengthSupported; |
| 47 | static const Capability kCapability; |
| 48 | static const Descriptor kDescriptor; |
| 49 | AutomaticGainControlV1Sw() { LOG(DEBUG) << __func__; } |
| 50 | ~AutomaticGainControlV1Sw() { |
| 51 | cleanUp(); |
| 52 | LOG(DEBUG) << __func__; |
| 53 | } |
| 54 | |
| 55 | ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; |
| 56 | ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override; |
| 57 | ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, |
| 58 | Parameter::Specific* specific) override; |
| 59 | |
| 60 | std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override; |
| 61 | std::shared_ptr<EffectContext> getContext() override; |
| 62 | RetCode releaseContext() override; |
| 63 | |
| 64 | std::string getEffectName() override { return kEffectName; }; |
| 65 | IEffect::Status effectProcessImpl(float* in, float* out, int samples) override; |
| 66 | |
| 67 | private: |
| 68 | static const std::vector<Range::AutomaticGainControlV1Range> kRanges; |
| 69 | std::shared_ptr<AutomaticGainControlV1SwContext> mContext; |
| 70 | ndk::ScopedAStatus getParameterAutomaticGainControlV1(const AutomaticGainControlV1::Tag& tag, |
| 71 | Parameter::Specific* specific); |
| 72 | }; |
| 73 | } // namespace aidl::android::hardware::audio::effect |