blob: 76b91aef31b708e622c771d09ebfbabd1d102fdf [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"
Shraddha Basantwanicac2e682023-02-15 18:03:58 +053020
21namespace aidl::android::hardware::audio::effect {
22
23class 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
43class 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;
Shunkai Yao65c7c702024-01-09 20:50:53 +000056 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;
Shraddha Basantwanicac2e682023-02-15 18:03:58 +053060
Shunkai Yao65c7c702024-01-09 20:50:53 +000061 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
62 REQUIRES(mImplMutex) override;
63 RetCode releaseContext() REQUIRES(mImplMutex) override;
Shraddha Basantwanicac2e682023-02-15 18:03:58 +053064
65 std::string getEffectName() override { return kEffectName; };
Shunkai Yao65c7c702024-01-09 20:50:53 +000066 IEffect::Status effectProcessImpl(float* in, float* out, int samples)
67 REQUIRES(mImplMutex) override;
Shraddha Basantwanicac2e682023-02-15 18:03:58 +053068
69 private:
70 static const std::vector<Range::AutomaticGainControlV1Range> kRanges;
Shunkai Yao65c7c702024-01-09 20:50:53 +000071 std::shared_ptr<AutomaticGainControlV1SwContext> mContext GUARDED_BY(mImplMutex);
Shraddha Basantwanicac2e682023-02-15 18:03:58 +053072 ndk::ScopedAStatus getParameterAutomaticGainControlV1(const AutomaticGainControlV1::Tag& tag,
Shunkai Yao65c7c702024-01-09 20:50:53 +000073 Parameter::Specific* specific)
74 REQUIRES(mImplMutex);
Shraddha Basantwanicac2e682023-02-15 18:03:58 +053075};
76} // namespace aidl::android::hardware::audio::effect