blob: acef8ee1354dfa2e5ad584578997edafb9dafcaa [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
Shunkai Yaobd862b82022-12-20 00:11:41 +000019#include <cstdlib>
20#include <memory>
21
Shunkai Yaof8be1ac2023-03-06 18:41:27 +000022#include <aidl/android/hardware/audio/effect/BnEffect.h>
23#include <fmq/AidlMessageQueue.h>
24
Shunkai Yaobd862b82022-12-20 00:11:41 +000025#include "effect-impl/EffectImpl.h"
Shunkai Yaobd862b82022-12-20 00:11:41 +000026
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();
Shunkai Yao58aaf5b2023-02-06 07:25:09 +000038 RetCode setType(NoiseSuppression::Type type);
39 NoiseSuppression::Type getType() { return mType; }
Shunkai Yaobd862b82022-12-20 00:11:41 +000040
41 private:
Sham Rathodd7c6f322022-12-26 11:17:10 +053042 NoiseSuppression::Level mLevel = NoiseSuppression::Level::LOW;
Shunkai Yao58aaf5b2023-02-06 07:25:09 +000043 NoiseSuppression::Type mType = NoiseSuppression::Type::SINGLE_CHANNEL;
Shunkai Yaobd862b82022-12-20 00:11:41 +000044};
45
46class NoiseSuppressionSw final : public EffectImpl {
47 public:
48 static const std::string kEffectName;
49 static const bool kStrengthSupported;
Shunkai Yaobd862b82022-12-20 00:11:41 +000050 static const Descriptor kDescriptor;
51 NoiseSuppressionSw() { LOG(DEBUG) << __func__; }
52 ~NoiseSuppressionSw() {
53 cleanUp();
54 LOG(DEBUG) << __func__;
55 }
56
57 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
Shunkai Yao65c7c702024-01-09 20:50:53 +000058 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific)
59 REQUIRES(mImplMutex) override;
60 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific)
61 REQUIRES(mImplMutex) override;
Shunkai Yaobd862b82022-12-20 00:11:41 +000062
Shunkai Yao65c7c702024-01-09 20:50:53 +000063 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common)
64 REQUIRES(mImplMutex) override;
65 RetCode releaseContext() REQUIRES(mImplMutex) override;
Shunkai Yaobd862b82022-12-20 00:11:41 +000066
67 std::string getEffectName() override { return kEffectName; };
Shunkai Yao65c7c702024-01-09 20:50:53 +000068 IEffect::Status effectProcessImpl(float* in, float* out, int samples)
69 REQUIRES(mImplMutex) override;
Shunkai Yaobd862b82022-12-20 00:11:41 +000070
71 private:
Shunkai Yao65c7c702024-01-09 20:50:53 +000072 std::shared_ptr<NoiseSuppressionSwContext> mContext GUARDED_BY(mImplMutex);
Shunkai Yaobd862b82022-12-20 00:11:41 +000073 ndk::ScopedAStatus getParameterNoiseSuppression(const NoiseSuppression::Tag& tag,
Shunkai Yao65c7c702024-01-09 20:50:53 +000074 Parameter::Specific* specific)
75 REQUIRES(mImplMutex);
Shunkai Yaobd862b82022-12-20 00:11:41 +000076};
77} // namespace aidl::android::hardware::audio::effect