blob: 901e4551b85e7e30e19600401f1007b3eeecc0d8 [file] [log] [blame]
Shunkai Yao6afc8552022-10-26 22:47:20 +00001/*
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 Yao6afc8552022-10-26 22:47:20 +000025
26namespace aidl::android::hardware::audio::effect {
27
Shunkai Yao6755d762022-11-02 00:21:02 +000028class BassBoostSwContext final : public EffectContext {
Shunkai Yao6afc8552022-10-26 22:47:20 +000029 public:
30 BassBoostSwContext(int statusDepth, const Parameter::Common& common)
31 : EffectContext(statusDepth, common) {
32 LOG(DEBUG) << __func__;
33 }
Shraddha Basantwanif627d802022-11-08 14:45:07 +053034
Sham Rathod8411fd22022-12-27 10:27:03 +053035 RetCode setBbStrengthPm(int strength);
Shraddha Basantwanif627d802022-11-08 14:45:07 +053036 int getBbStrengthPm() const { return mStrength; }
37
38 private:
Sham Rathodd7c6f322022-12-26 11:17:10 +053039 int mStrength = 0;
Shunkai Yao6afc8552022-10-26 22:47:20 +000040};
41
Shunkai Yao6755d762022-11-02 00:21:02 +000042class BassBoostSw final : public EffectImpl {
Shunkai Yao6afc8552022-10-26 22:47:20 +000043 public:
Shunkai Yaoc12e0822022-12-12 07:13:58 +000044 static const std::string kEffectName;
Shunkai Yao87811022023-02-13 17:40:37 +000045 static const Capability kCapability;
Shunkai Yaoc12e0822022-12-12 07:13:58 +000046 static const Descriptor kDescriptor;
Shunkai Yao6afc8552022-10-26 22:47:20 +000047 BassBoostSw() { LOG(DEBUG) << __func__; }
48 ~BassBoostSw() {
Shunkai Yao812d5b42022-11-16 18:08:50 +000049 cleanUp();
Shunkai Yao6afc8552022-10-26 22:47:20 +000050 LOG(DEBUG) << __func__;
Shunkai Yao6afc8552022-10-26 22:47:20 +000051 }
52
53 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
Shunkai Yao65c7c702024-01-09 20:50:53 +000054 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific)
55 REQUIRES(mImplMutex) override;
56 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific)
57 REQUIRES(mImplMutex) override;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053058
Shunkai Yao65c7c702024-01-09 20:50:53 +000059 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
60 REQUIRES(mImplMutex) override;
61 RetCode releaseContext() REQUIRES(mImplMutex) override;
Shunkai Yao6afc8552022-10-26 22:47:20 +000062
Shraddha Basantwanif627d802022-11-08 14:45:07 +053063 std::string getEffectName() override { return kEffectName; };
Shunkai Yao65c7c702024-01-09 20:50:53 +000064 IEffect::Status effectProcessImpl(float* in, float* out, int samples)
65 REQUIRES(mImplMutex) override;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053066
Shunkai Yao6afc8552022-10-26 22:47:20 +000067 private:
Shunkai Yao87811022023-02-13 17:40:37 +000068 static const std::vector<Range::BassBoostRange> kRanges;
Shunkai Yao65c7c702024-01-09 20:50:53 +000069 std::shared_ptr<BassBoostSwContext> mContext GUARDED_BY(mImplMutex);
Shraddha Basantwanif627d802022-11-08 14:45:07 +053070 ndk::ScopedAStatus getParameterBassBoost(const BassBoost::Tag& tag,
Shunkai Yao65c7c702024-01-09 20:50:53 +000071 Parameter::Specific* specific) REQUIRES(mImplMutex);
Shunkai Yao6afc8552022-10-26 22:47:20 +000072};
73} // namespace aidl::android::hardware::audio::effect