blob: 2aa49538535031325de380f435d18bc0e96e8c23 [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"
25#include "effect-impl/EffectUUID.h"
26
27namespace aidl::android::hardware::audio::effect {
28
Shunkai Yao6755d762022-11-02 00:21:02 +000029class LoudnessEnhancerSwContext final : public EffectContext {
Shunkai Yao6afc8552022-10-26 22:47:20 +000030 public:
31 LoudnessEnhancerSwContext(int statusDepth, const Parameter::Common& common)
32 : EffectContext(statusDepth, common) {
33 LOG(DEBUG) << __func__;
34 }
Shraddha Basantwani68041ca2022-11-04 15:13:32 +053035
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 Yao6afc8552022-10-26 22:47:20 +000045};
46
Shunkai Yao6755d762022-11-02 00:21:02 +000047class LoudnessEnhancerSw final : public EffectImpl {
Shunkai Yao6afc8552022-10-26 22:47:20 +000048 public:
49 LoudnessEnhancerSw() { LOG(DEBUG) << __func__; }
50 ~LoudnessEnhancerSw() {
Shunkai Yao812d5b42022-11-16 18:08:50 +000051 cleanUp();
Shunkai Yao6afc8552022-10-26 22:47:20 +000052 LOG(DEBUG) << __func__;
Shunkai Yao6afc8552022-10-26 22:47:20 +000053 }
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;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053059
Shunkai Yao6afc8552022-10-26 22:47:20 +000060 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053061 std::shared_ptr<EffectContext> getContext() override;
Shunkai Yao6afc8552022-10-26 22:47:20 +000062 RetCode releaseContext() override;
63
Shraddha Basantwanif627d802022-11-08 14:45:07 +053064 IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
65 std::string getEffectName() override { return kEffectName; }
66
Shunkai Yao6afc8552022-10-26 22:47:20 +000067 private:
Shraddha Basantwanif627d802022-11-08 14:45:07 +053068 const std::string kEffectName = "LoudnessEnhancerSw";
Shunkai Yao6afc8552022-10-26 22:47:20 +000069 std::shared_ptr<LoudnessEnhancerSwContext> mContext;
70 /* capabilities */
71 const LoudnessEnhancer::Capability kCapability;
72 /* Effect descriptor */
73 const Descriptor kDescriptor = {
Shunkai Yao812d5b42022-11-16 18:08:50 +000074 .common = {.id = {.type = kLoudnessEnhancerTypeUUID,
75 .uuid = kLoudnessEnhancerSwImplUUID,
Shunkai Yao6afc8552022-10-26 22:47:20 +000076 .proxy = std::nullopt},
77 .flags = {.type = Flags::Type::INSERT,
78 .insert = Flags::Insert::FIRST,
79 .volume = Flags::Volume::CTRL},
Shraddha Basantwanif627d802022-11-08 14:45:07 +053080 .name = kEffectName,
Shunkai Yao812d5b42022-11-16 18:08:50 +000081 .implementor = "The Android Open Source Project"},
Shunkai Yao6afc8552022-10-26 22:47:20 +000082 .capability = Capability::make<Capability::loudnessEnhancer>(kCapability)};
83
Shraddha Basantwani68041ca2022-11-04 15:13:32 +053084 ndk::ScopedAStatus getParameterLoudnessEnhancer(const LoudnessEnhancer::Tag& tag,
85 Parameter::Specific* specific);
Shunkai Yao6afc8552022-10-26 22:47:20 +000086};
87} // namespace aidl::android::hardware::audio::effect