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 PresetReverbSwContext final : public EffectContext { 29 public: PresetReverbSwContext(int statusDepth,const Parameter::Common & common)30 PresetReverbSwContext(int statusDepth, const Parameter::Common& common) 31 : EffectContext(statusDepth, common) { 32 LOG(DEBUG) << __func__; 33 } setPRPreset(PresetReverb::Presets preset)34 RetCode setPRPreset(PresetReverb::Presets preset) { 35 // TODO : Add implementation to modify Presets 36 mPreset = preset; 37 return RetCode::SUCCESS; 38 } getPRPreset()39 PresetReverb::Presets getPRPreset() const { return mPreset; } 40 41 private: 42 PresetReverb::Presets mPreset = PresetReverb::Presets::NONE; 43 }; 44 45 class PresetReverbSw final : public EffectImpl { 46 public: 47 static const std::string kEffectName; 48 static const std::vector<PresetReverb::Presets> kSupportedPresets; 49 static const std::vector<Range::PresetReverbRange> kRanges; 50 static const Capability kCapability; 51 static const Descriptor kDescriptor; PresetReverbSw()52 PresetReverbSw() { LOG(DEBUG) << __func__; } ~PresetReverbSw()53 ~PresetReverbSw() { 54 cleanUp(); 55 LOG(DEBUG) << __func__; 56 } 57 58 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; 59 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) 60 REQUIRES(mImplMutex) override; 61 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific) 62 REQUIRES(mImplMutex) override; 63 64 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) 65 REQUIRES(mImplMutex) override; 66 RetCode releaseContext() REQUIRES(mImplMutex) override; 67 68 IEffect::Status effectProcessImpl(float* in, float* out, int samples) 69 REQUIRES(mImplMutex) override; getEffectName()70 std::string getEffectName() override { return kEffectName; } 71 72 private: 73 std::shared_ptr<PresetReverbSwContext> mContext GUARDED_BY(mImplMutex); 74 75 ndk::ScopedAStatus getParameterPresetReverb(const PresetReverb::Tag& tag, 76 Parameter::Specific* specific) REQUIRES(mImplMutex); 77 }; 78 } // namespace aidl::android::hardware::audio::effect 79