Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 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 | #include "effect-impl/EffectUUID.h" |
| 26 | |
| 27 | namespace aidl::android::hardware::audio::effect { |
| 28 | |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame] | 29 | class PresetReverbSwContext final : public EffectContext { |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 30 | public: |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame] | 31 | PresetReverbSwContext(int statusDepth, const Parameter::Common& common) |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 32 | : EffectContext(statusDepth, common) { |
| 33 | LOG(DEBUG) << __func__; |
| 34 | } |
Sham Rathod | 73aa2c3 | 2022-12-20 17:03:40 +0530 | [diff] [blame^] | 35 | RetCode setPRPreset(PresetReverb::Presets preset) { |
| 36 | // TODO : Add implementation to modify Presets |
| 37 | mPreset = preset; |
| 38 | return RetCode::SUCCESS; |
| 39 | } |
| 40 | PresetReverb::Presets getPRPreset() const { return mPreset; } |
| 41 | |
| 42 | private: |
| 43 | PresetReverb::Presets mPreset = PresetReverb::Presets::NONE; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame] | 46 | class PresetReverbSw final : public EffectImpl { |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 47 | public: |
Shunkai Yao | c12e082 | 2022-12-12 07:13:58 +0000 | [diff] [blame] | 48 | static const std::string kEffectName; |
| 49 | static const PresetReverb::Capability kCapability; |
| 50 | static const Descriptor kDescriptor; |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame] | 51 | PresetReverbSw() { LOG(DEBUG) << __func__; } |
| 52 | ~PresetReverbSw() { |
| 53 | cleanUp(); |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 54 | LOG(DEBUG) << __func__; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; |
| 58 | ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override; |
| 59 | ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, |
| 60 | Parameter::Specific* specific) override; |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 61 | |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 62 | std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override; |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 63 | std::shared_ptr<EffectContext> getContext() override; |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 64 | RetCode releaseContext() override; |
| 65 | |
Shraddha Basantwani | f627d80 | 2022-11-08 14:45:07 +0530 | [diff] [blame] | 66 | IEffect::Status effectProcessImpl(float* in, float* out, int samples) override; |
| 67 | std::string getEffectName() override { return kEffectName; } |
| 68 | |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 69 | private: |
Shunkai Yao | 812d5b4 | 2022-11-16 18:08:50 +0000 | [diff] [blame] | 70 | std::shared_ptr<PresetReverbSwContext> mContext; |
Sham Rathod | 73aa2c3 | 2022-12-20 17:03:40 +0530 | [diff] [blame^] | 71 | |
| 72 | ndk::ScopedAStatus getParameterPresetReverb(const PresetReverb::Tag& tag, |
| 73 | Parameter::Specific* specific); |
Shunkai Yao | 6afc855 | 2022-10-26 22:47:20 +0000 | [diff] [blame] | 74 | }; |
| 75 | } // namespace aidl::android::hardware::audio::effect |