blob: 6ba7328521b3d56bc7a72ec439f8a661ce9b341a [file] [log] [blame]
Shraddha Basantwanicac2e682023-02-15 18:03:58 +05301/*
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#include "effect-impl/EffectUUID.h"
21
22namespace aidl::android::hardware::audio::effect {
23
24class AutomaticGainControlV1SwContext final : public EffectContext {
25 public:
26 AutomaticGainControlV1SwContext(int statusDepth, const Parameter::Common& common)
27 : EffectContext(statusDepth, common) {
28 LOG(DEBUG) << __func__;
29 }
30
31 RetCode setTargetPeakLevel(int targetPeakLevel);
32 int getTargetPeakLevel();
33 RetCode setMaxCompressionGain(int maxCompressionGainDb);
34 int getMaxCompressionGain();
35 RetCode setEnableLimiter(bool enableLimiter);
36 bool getEnableLimiter();
37
38 private:
39 int mTargetPeakLevel = 0;
40 int mMaxCompressionGain = 0;
41 bool mEnableLimiter = false;
42};
43
44class AutomaticGainControlV1Sw final : public EffectImpl {
45 public:
46 static const std::string kEffectName;
47 static const bool kStrengthSupported;
48 static const Capability kCapability;
49 static const Descriptor kDescriptor;
50 AutomaticGainControlV1Sw() { LOG(DEBUG) << __func__; }
51 ~AutomaticGainControlV1Sw() {
52 cleanUp();
53 LOG(DEBUG) << __func__;
54 }
55
56 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
57 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
58 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
59 Parameter::Specific* specific) override;
60
61 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
62 std::shared_ptr<EffectContext> getContext() override;
63 RetCode releaseContext() override;
64
65 std::string getEffectName() override { return kEffectName; };
66 IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
67
68 private:
69 static const std::vector<Range::AutomaticGainControlV1Range> kRanges;
70 std::shared_ptr<AutomaticGainControlV1SwContext> mContext;
71 ndk::ScopedAStatus getParameterAutomaticGainControlV1(const AutomaticGainControlV1::Tag& tag,
72 Parameter::Specific* specific);
73};
74} // namespace aidl::android::hardware::audio::effect