xref: /aosp_15_r20/frameworks/av/media/libeffects/dynamicsproc/aidl/DynamicsProcessing.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
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 <aidl/android/hardware/audio/effect/BnEffect.h>
20 
21 #include "DynamicsProcessingContext.h"
22 #include "EffectRangeSpecific.h"
23 #include "effect-impl/EffectImpl.h"
24 
25 namespace aidl::android::hardware::audio::effect {
26 
27 class DynamicsProcessingImpl final : public EffectImpl {
28   public:
29     static const std::string kEffectName;
30     static const Descriptor kDescriptor;
31     static const Capability kCapability;
32 
33     DynamicsProcessingImpl() = default;
~DynamicsProcessingImpl()34     ~DynamicsProcessingImpl() { cleanUp(); }
35 
36     ndk::ScopedAStatus open(const Parameter::Common& common,
37                             const std::optional<Parameter::Specific>& specific,
38                             OpenEffectReturn* ret) override;
39     ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
40     ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific)
41             REQUIRES(mImplMutex) override;
42     ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific)
43             REQUIRES(mImplMutex) override;
44     IEffect::Status effectProcessImpl(float* in, float* out, int process)
45             REQUIRES(mImplMutex) override;
46     std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
47             REQUIRES(mImplMutex) override;
48     RetCode releaseContext() REQUIRES(mImplMutex) override;
49 
getEffectName()50     std::string getEffectName() override { return kEffectName; }
51 
52   private:
53     std::shared_ptr<DynamicsProcessingContext> mContext GUARDED_BY(mImplMutex);
54     ndk::ScopedAStatus getParameterDynamicsProcessing(const DynamicsProcessing::Tag& tag,
55                                                       Parameter::Specific* specific)
56             REQUIRES(mImplMutex);
57     bool isParamInRange(const Parameter::Specific& specific);
58 };
59 
60 }  // namespace aidl::android::hardware::audio::effect
61