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 26 namespace aidl::android::hardware::audio::effect { 27 28 class LoudnessEnhancerSwContext final : public EffectContext { 29 public: LoudnessEnhancerSwContext(int statusDepth,const Parameter::Common & common)30 LoudnessEnhancerSwContext(int statusDepth, const Parameter::Common& common) 31 : EffectContext(statusDepth, common) { 32 LOG(DEBUG) << __func__; 33 } 34 setLeGainMb(int gainMb)35 RetCode setLeGainMb(int gainMb) { 36 // TODO : Add implementation to apply new gain 37 mGainMb = gainMb; 38 return RetCode::SUCCESS; 39 } getLeGainMb()40 int getLeGainMb() const { return mGainMb; } 41 42 private: 43 int mGainMb = 0; // Default Gain 44 }; 45 46 class LoudnessEnhancerSw final : public EffectImpl { 47 public: 48 static const std::string kEffectName; 49 static const Descriptor kDescriptor; LoudnessEnhancerSw()50 LoudnessEnhancerSw() { LOG(DEBUG) << __func__; } ~LoudnessEnhancerSw()51 ~LoudnessEnhancerSw() { 52 cleanUp(); 53 LOG(DEBUG) << __func__; 54 } 55 56 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; 57 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; 61 62 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) 63 REQUIRES(mImplMutex) override; 64 RetCode releaseContext() REQUIRES(mImplMutex) override; 65 66 IEffect::Status effectProcessImpl(float* in, float* out, int samples) 67 REQUIRES(mImplMutex) override; getEffectName()68 std::string getEffectName() override { return kEffectName; } 69 70 private: 71 std::shared_ptr<LoudnessEnhancerSwContext> mContext GUARDED_BY(mImplMutex); 72 ndk::ScopedAStatus getParameterLoudnessEnhancer(const LoudnessEnhancer::Tag& tag, 73 Parameter::Specific* specific) 74 REQUIRES(mImplMutex); 75 }; 76 } // namespace aidl::android::hardware::audio::effect 77