blob: 9ceee7cca9c926239650218c0ea46baaefc4dd55 [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 Yao812d5b42022-11-16 18:08:50 +000028class PresetReverbSwContext final : public EffectContext {
Shunkai Yao6afc8552022-10-26 22:47:20 +000029 public:
Shunkai Yao812d5b42022-11-16 18:08:50 +000030 PresetReverbSwContext(int statusDepth, const Parameter::Common& common)
Shunkai Yao6afc8552022-10-26 22:47:20 +000031 : EffectContext(statusDepth, common) {
32 LOG(DEBUG) << __func__;
33 }
Sham Rathod73aa2c32022-12-20 17:03:40 +053034 RetCode setPRPreset(PresetReverb::Presets preset) {
35 // TODO : Add implementation to modify Presets
36 mPreset = preset;
37 return RetCode::SUCCESS;
38 }
39 PresetReverb::Presets getPRPreset() const { return mPreset; }
40
41 private:
42 PresetReverb::Presets mPreset = PresetReverb::Presets::NONE;
Shunkai Yao6afc8552022-10-26 22:47:20 +000043};
44
Shunkai Yao812d5b42022-11-16 18:08:50 +000045class PresetReverbSw final : public EffectImpl {
Shunkai Yao6afc8552022-10-26 22:47:20 +000046 public:
Shunkai Yaoc12e0822022-12-12 07:13:58 +000047 static const std::string kEffectName;
Shunkai Yao87811022023-02-13 17:40:37 +000048 static const std::vector<PresetReverb::Presets> kSupportedPresets;
49 static const std::vector<Range::PresetReverbRange> kRanges;
50 static const Capability kCapability;
Shunkai Yaoc12e0822022-12-12 07:13:58 +000051 static const Descriptor kDescriptor;
Shunkai Yao812d5b42022-11-16 18:08:50 +000052 PresetReverbSw() { LOG(DEBUG) << __func__; }
53 ~PresetReverbSw() {
54 cleanUp();
Shunkai Yao6afc8552022-10-26 22:47:20 +000055 LOG(DEBUG) << __func__;
Shunkai Yao6afc8552022-10-26 22:47:20 +000056 }
57
58 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
59 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
60 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
61 Parameter::Specific* specific) override;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053062
Shunkai Yao6afc8552022-10-26 22:47:20 +000063 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
Shraddha Basantwanif627d802022-11-08 14:45:07 +053064 std::shared_ptr<EffectContext> getContext() override;
Shunkai Yao6afc8552022-10-26 22:47:20 +000065 RetCode releaseContext() override;
66
Shraddha Basantwanif627d802022-11-08 14:45:07 +053067 IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
68 std::string getEffectName() override { return kEffectName; }
69
Shunkai Yao6afc8552022-10-26 22:47:20 +000070 private:
Shunkai Yao812d5b42022-11-16 18:08:50 +000071 std::shared_ptr<PresetReverbSwContext> mContext;
Sham Rathod73aa2c32022-12-20 17:03:40 +053072
73 ndk::ScopedAStatus getParameterPresetReverb(const PresetReverb::Tag& tag,
74 Parameter::Specific* specific);
Shunkai Yao6afc8552022-10-26 22:47:20 +000075};
76} // namespace aidl::android::hardware::audio::effect