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" |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 25 | |
| 26 | namespace aidl::android::hardware::audio::effect { |
| 27 | |
Shunkai Yao | 6755d76 | 2022-11-02 00:21:02 +0000 | [diff] [blame] | 28 | class BassBoostSwContext final : public EffectContext { |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 29 | public: |
| 30 | BassBoostSwContext(int statusDepth, const Parameter::Common& common) |
| 31 | : EffectContext(statusDepth, common) { |
| 32 | LOG(DEBUG) << __func__; |
| 33 | } |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 34 | |
Sham Rathod | 8411fd2 | 2022-12-27 10:27:03 +0530 | [diff] [blame] | 35 | RetCode setBbStrengthPm(int strength); |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 36 | int getBbStrengthPm() const { return mStrength; } |
| 37 | |
| 38 | private: |
Sham Rathod | d7c6f32 | 2022-12-26 11:17:10 +0530 | [diff] [blame] | 39 | int mStrength = 0; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
Shunkai Yao | 6755d76 | 2022-11-02 00:21:02 +0000 | [diff] [blame] | 42 | class BassBoostSw final : public EffectImpl { |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 43 | public: |
Shunkai Yao | c12e082 | 2022-12-12 07:13:58 +0000 | [diff] [blame] | 44 | static const std::string kEffectName; |
Shunkai Yao | 8781102 | 2023-02-13 17:40:37 +0000 | [diff] [blame] | 45 | static const Capability kCapability; |
Shunkai Yao | c12e082 | 2022-12-12 07:13:58 +0000 | [diff] [blame] | 46 | static const Descriptor kDescriptor; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 47 | BassBoostSw() { LOG(DEBUG) << __func__; } |
| 48 | ~BassBoostSw() { |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame] | 49 | cleanUp(); |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 50 | LOG(DEBUG) << __func__; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; |
| 54 | ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override; |
| 55 | ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, |
| 56 | Parameter::Specific* specific) override; |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 57 | |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 58 | std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override; |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 59 | std::shared_ptr<EffectContext> getContext() override; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 60 | RetCode releaseContext() override; |
| 61 | |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 62 | std::string getEffectName() override { return kEffectName; }; |
| 63 | IEffect::Status effectProcessImpl(float* in, float* out, int samples) override; |
| 64 | |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 65 | private: |
Shunkai Yao | 8781102 | 2023-02-13 17:40:37 +0000 | [diff] [blame] | 66 | static const std::vector<Range::BassBoostRange> kRanges; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 67 | std::shared_ptr<BassBoostSwContext> mContext; |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 68 | ndk::ScopedAStatus getParameterBassBoost(const BassBoost::Tag& tag, |
| 69 | Parameter::Specific* specific); |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 70 | }; |
| 71 | } // namespace aidl::android::hardware::audio::effect |