Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 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 | |
| 19 | #include <aidl/android/hardware/audio/effect/BnEffect.h> |
| 20 | #include <fmq/AidlMessageQueue.h> |
| 21 | #include <cstdlib> |
| 22 | #include <memory> |
| 23 | |
| 24 | #include "effect-impl/EffectImpl.h" |
| 25 | #include "effect-impl/EffectUUID.h" |
| 26 | |
| 27 | namespace aidl::android::hardware::audio::effect { |
| 28 | |
Shunkai Yao | 6755d76 | 2022-11-02 00:21:02 +0000 | [diff] [blame] | 29 | class LoudnessEnhancerSwContext final : public EffectContext { |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 30 | public: |
| 31 | LoudnessEnhancerSwContext(int statusDepth, const Parameter::Common& common) |
| 32 | : EffectContext(statusDepth, common) { |
| 33 | LOG(DEBUG) << __func__; |
| 34 | } |
Shraddha Basantwani | 68041ca | 2022-11-04 15:13:32 +0530 | [diff] [blame] | 35 | |
| 36 | RetCode setLeGainMb(int gainMb) { |
| 37 | // TODO : Add implementation to apply new gain |
| 38 | mGainMb = gainMb; |
| 39 | return RetCode::SUCCESS; |
| 40 | } |
| 41 | int getLeGainMb() const { return mGainMb; } |
| 42 | |
| 43 | private: |
| 44 | int mGainMb = 0; // Default Gain |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Shunkai Yao | 6755d76 | 2022-11-02 00:21:02 +0000 | [diff] [blame] | 47 | class LoudnessEnhancerSw final : public EffectImpl { |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 48 | public: |
| 49 | LoudnessEnhancerSw() { LOG(DEBUG) << __func__; } |
| 50 | ~LoudnessEnhancerSw() { |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame^] | 51 | cleanUp(); |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 52 | LOG(DEBUG) << __func__; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; |
| 56 | ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override; |
| 57 | ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, |
| 58 | Parameter::Specific* specific) override; |
| 59 | IEffect::Status effectProcessImpl(float* in, float* out, int process) override; |
| 60 | std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override; |
| 61 | RetCode releaseContext() override; |
| 62 | |
| 63 | private: |
| 64 | std::shared_ptr<LoudnessEnhancerSwContext> mContext; |
| 65 | /* capabilities */ |
| 66 | const LoudnessEnhancer::Capability kCapability; |
| 67 | /* Effect descriptor */ |
| 68 | const Descriptor kDescriptor = { |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame^] | 69 | .common = {.id = {.type = kLoudnessEnhancerTypeUUID, |
| 70 | .uuid = kLoudnessEnhancerSwImplUUID, |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 71 | .proxy = std::nullopt}, |
| 72 | .flags = {.type = Flags::Type::INSERT, |
| 73 | .insert = Flags::Insert::FIRST, |
| 74 | .volume = Flags::Volume::CTRL}, |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame^] | 75 | .name = "LoudnessEnhancerSw", |
| 76 | .implementor = "The Android Open Source Project"}, |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 77 | .capability = Capability::make<Capability::loudnessEnhancer>(kCapability)}; |
| 78 | |
Shraddha Basantwani | 68041ca | 2022-11-04 15:13:32 +0530 | [diff] [blame] | 79 | ndk::ScopedAStatus getParameterLoudnessEnhancer(const LoudnessEnhancer::Tag& tag, |
| 80 | Parameter::Specific* specific); |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 81 | }; |
| 82 | } // namespace aidl::android::hardware::audio::effect |