• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
20 
21 namespace aidl::android::hardware::audio::effect {
22 
23 class AutomaticGainControlV1SwContext final : public EffectContext {
24   public:
AutomaticGainControlV1SwContext(int statusDepth,const Parameter::Common & common)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;
AutomaticGainControlV1Sw()49     AutomaticGainControlV1Sw() { LOG(DEBUG) << __func__; }
~AutomaticGainControlV1Sw()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)
57             REQUIRES(mImplMutex) override;
58     ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific)
59             REQUIRES(mImplMutex) override;
60 
61     std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
62             REQUIRES(mImplMutex) override;
63     RetCode releaseContext() REQUIRES(mImplMutex) override;
64 
getEffectName()65     std::string getEffectName() override { return kEffectName; };
66     IEffect::Status effectProcessImpl(float* in, float* out, int samples)
67             REQUIRES(mImplMutex) override;
68 
69   private:
70     static const std::vector<Range::AutomaticGainControlV1Range> kRanges;
71     std::shared_ptr<AutomaticGainControlV1SwContext> mContext GUARDED_BY(mImplMutex);
72     ndk::ScopedAStatus getParameterAutomaticGainControlV1(const AutomaticGainControlV1::Tag& tag,
73                                                           Parameter::Specific* specific)
74             REQUIRES(mImplMutex);
75 };
76 }  // namespace aidl::android::hardware::audio::effect
77