blob: cf71a5f03ff716ee4f38e6247553c3289370dfd5 [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 LoudnessEnhancerSwContext final : public EffectContext {
Shunkai Yao6afc8552022-10-26 22:47:20 +000029 public:
30 LoudnessEnhancerSwContext(int statusDepth, const Parameter::Common& common)
31 : EffectContext(statusDepth, common) {
32 LOG(DEBUG) << __func__;
33 }
Shraddha Basantwani68041ca2022-11-04 15:13:32 +053034
35 RetCode setLeGainMb(int gainMb) {
36 // TODO : Add implementation to apply new gain
37 mGainMb = gainMb;
38 return RetCode::SUCCESS;
39 }
40 int getLeGainMb() const { return mGainMb; }
41
42 private:
43 int mGainMb = 0; // Default Gain
Shunkai Yao6afc8552022-10-26 22:47:20 +000044};
45
Shunkai Yao6755d762022-11-02 00:21:02 +000046class LoudnessEnhancerSw final : public EffectImpl {
Shunkai Yao6afc8552022-10-26 22:47:20 +000047 public:
Shunkai Yaoc12e0822022-12-12 07:13:58 +000048 static const std::string kEffectName;
Shunkai Yaoc12e0822022-12-12 07:13:58 +000049 static const Descriptor kDescriptor;
Shunkai Yao6afc8552022-10-26 22:47:20 +000050 LoudnessEnhancerSw() { LOG(DEBUG) << __func__; }
51 ~LoudnessEnhancerSw() {
Shunkai Yao812d5b42022-11-16 18:08:50 +000052 cleanUp();
Shunkai Yao6afc8552022-10-26 22:47:20 +000053 LOG(DEBUG) << __func__;
Shunkai Yao6afc8552022-10-26 22:47:20 +000054 }
55
56 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
Shunkai Yao65c7c702024-01-09 20:50:53 +000057 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific)
58 REQUIRES(mImplMutex) override;
59 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific)
60 REQUIRES(mImplMutex) override;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053061
Shunkai Yao65c7c702024-01-09 20:50:53 +000062 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
63 REQUIRES(mImplMutex) override;
64 RetCode releaseContext() REQUIRES(mImplMutex) override;
Shunkai Yao6afc8552022-10-26 22:47:20 +000065
Shunkai Yao65c7c702024-01-09 20:50:53 +000066 IEffect::Status effectProcessImpl(float* in, float* out, int samples)
67 REQUIRES(mImplMutex) override;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053068 std::string getEffectName() override { return kEffectName; }
69
Shunkai Yao6afc8552022-10-26 22:47:20 +000070 private:
Shunkai Yao65c7c702024-01-09 20:50:53 +000071 std::shared_ptr<LoudnessEnhancerSwContext> mContext GUARDED_BY(mImplMutex);
Shraddha Basantwani68041ca2022-11-04 15:13:32 +053072 ndk::ScopedAStatus getParameterLoudnessEnhancer(const LoudnessEnhancer::Tag& tag,
Shunkai Yao65c7c702024-01-09 20:50:53 +000073 Parameter::Specific* specific)
74 REQUIRES(mImplMutex);
Shunkai Yao6afc8552022-10-26 22:47:20 +000075};
76} // namespace aidl::android::hardware::audio::effect