blob: 0c030382265bbe02e3676e54caee21b5f610008e [file] [log] [blame]
Shunkai Yaobd862b82022-12-20 00:11:41 +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"
25#include "effect-impl/EffectUUID.h"
26
27namespace aidl::android::hardware::audio::effect {
28
29class NoiseSuppressionSwContext final : public EffectContext {
30 public:
31 NoiseSuppressionSwContext(int statusDepth, const Parameter::Common& common)
32 : EffectContext(statusDepth, common) {
33 LOG(DEBUG) << __func__;
34 }
35
36 RetCode setLevel(NoiseSuppression::Level level);
37 NoiseSuppression::Level getLevel();
38
39 private:
40 NoiseSuppression::Level mLevel;
41};
42
43class NoiseSuppressionSw final : public EffectImpl {
44 public:
45 static const std::string kEffectName;
46 static const bool kStrengthSupported;
47 static const NoiseSuppression::Capability kCapability;
48 static const Descriptor kDescriptor;
49 NoiseSuppressionSw() { LOG(DEBUG) << __func__; }
50 ~NoiseSuppressionSw() {
51 cleanUp();
52 LOG(DEBUG) << __func__;
53 }
54
55 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
56 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
57 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
58 Parameter::Specific* specific) override;
59
60 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
61 std::shared_ptr<EffectContext> getContext() override;
62 RetCode releaseContext() override;
63
64 std::string getEffectName() override { return kEffectName; };
65 IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
66
67 private:
68 std::shared_ptr<NoiseSuppressionSwContext> mContext;
69 ndk::ScopedAStatus getParameterNoiseSuppression(const NoiseSuppression::Tag& tag,
70 Parameter::Specific* specific);
71};
72} // namespace aidl::android::hardware::audio::effect