xref: /aosp_15_r20/frameworks/av/media/libeffects/lvm/wrapper/Aidl/EffectBundleAidl.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
1 /*
2  * Copyright (C) 2022 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 #include <functional>
19 #include <map>
20 #include <memory>
21 
22 #include <aidl/android/hardware/audio/effect/BnEffect.h>
23 #include <android-base/logging.h>
24 
25 #include "effect-impl/EffectImpl.h"
26 
27 #include "BundleContext.h"
28 #include "BundleTypes.h"
29 #include "GlobalSession.h"
30 
31 namespace aidl::android::hardware::audio::effect {
32 
33 class EffectBundleAidl final : public EffectImpl {
34   public:
35     explicit EffectBundleAidl(const AudioUuid& uuid);
36     ~EffectBundleAidl() override;
37 
38     ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
39     ndk::ScopedAStatus setParameterCommon(const Parameter& param) REQUIRES(mImplMutex) 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 
45     std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
46             REQUIRES(mImplMutex) override;
47     RetCode releaseContext() REQUIRES(mImplMutex) override;
48 
49     IEffect::Status effectProcessImpl(float* in, float* out, int samples)
50             REQUIRES(mImplMutex) override;
51 
getEffectName()52     std::string getEffectName() override { return *mEffectName; }
53 
54   private:
55     std::shared_ptr<BundleContext> mContext GUARDED_BY(mImplMutex);
56     const Descriptor* mDescriptor;
57     const std::string* mEffectName;
58     lvm::BundleEffectType mType = lvm::BundleEffectType::EQUALIZER;
59 
60     IEffect::Status status(binder_status_t status, size_t consumed, size_t produced);
61 
62     ndk::ScopedAStatus setParameterBassBoost(const Parameter::Specific& specific)
63             REQUIRES(mImplMutex);
64     ndk::ScopedAStatus getParameterBassBoost(const BassBoost::Id& id, Parameter::Specific* specific)
65             REQUIRES(mImplMutex);
66 
67     ndk::ScopedAStatus setParameterEqualizer(const Parameter::Specific& specific)
68             REQUIRES(mImplMutex);
69     ndk::ScopedAStatus getParameterEqualizer(const Equalizer::Id& id, Parameter::Specific* specific)
70             REQUIRES(mImplMutex);
71     ndk::ScopedAStatus setParameterVolume(const Parameter::Specific& specific) REQUIRES(mImplMutex);
72     ndk::ScopedAStatus getParameterVolume(const Volume::Id& id, Parameter::Specific* specific)
73             REQUIRES(mImplMutex);
74     ndk::ScopedAStatus setParameterVirtualizer(const Parameter::Specific& specific)
75             REQUIRES(mImplMutex);
76     ndk::ScopedAStatus getParameterVirtualizer(const Virtualizer::Id& id,
77                                                Parameter::Specific* specific) REQUIRES(mImplMutex);
78 };
79 
80 }  // namespace aidl::android::hardware::audio::effect
81