blob: 7bf2f577d801e5f30d448710553a09e86fa56354 [file] [log] [blame]
Shunkai Yao922576f2024-10-17 00:05:58 +00001/*
2 * Copyright (C) 2024 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 "effect-impl/EffectContext.h"
20#include "effect-impl/EffectImpl.h"
21
22#include <fmq/AidlMessageQueue.h>
23
24#include <unordered_map>
25#include <vector>
26
27namespace aidl::android::hardware::audio::effect {
28
29class EraserSwContext final : public EffectContext {
30 public:
31 EraserSwContext(int statusDepth, const Parameter::Common& common);
32 ~EraserSwContext() final;
33
34 template <typename TAG>
35 std::optional<Eraser> getParam(TAG tag);
36 template <typename TAG>
37 ndk::ScopedAStatus setParam(TAG tag, Eraser eraser);
38
39 IEffect::Status process(float* in, float* out, int samples);
40
41 private:
42 std::unordered_map<Eraser::Tag, Eraser> mParamsMap;
43};
44
45class EraserSw final : public EffectImpl {
46 public:
47 static const std::string kEffectName;
48 static const Capability kCapability;
49 static const Descriptor kDescriptor;
50 ~EraserSw() final;
51
52 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) final;
53 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific)
54 REQUIRES(mImplMutex) final;
55 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific)
56 REQUIRES(mImplMutex) final;
57
58 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
59 REQUIRES(mImplMutex) final;
60 RetCode releaseContext() REQUIRES(mImplMutex) final;
61
62 std::string getEffectName() final { return kEffectName; };
63 IEffect::Status effectProcessImpl(float* in, float* out, int samples)
64 REQUIRES(mImplMutex) final;
65
Shunkai Yao240c1d42024-11-24 18:40:58 +000066 ndk::ScopedAStatus command(CommandId command) final;
67 void drainingComplete_l() REQUIRES(mImplMutex);
68
Shunkai Yao922576f2024-10-17 00:05:58 +000069 private:
70 static const std::vector<Range::SpatializerRange> kRanges;
71 std::shared_ptr<EraserSwContext> mContext GUARDED_BY(mImplMutex);
72};
73} // namespace aidl::android::hardware::audio::effect