blob: 753207df9cff90f541997280a68ea820866f5aea [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>
Shunkai Yao87811022023-02-13 17:40:37 +000020#include <aidl/android/hardware/audio/effect/Range.h>
Shunkai Yaobd862b82022-12-20 00:11:41 +000021#include <fmq/AidlMessageQueue.h>
22#include <cstdlib>
23#include <memory>
24
25#include "effect-impl/EffectImpl.h"
26#include "effect-impl/EffectUUID.h"
27
28namespace aidl::android::hardware::audio::effect {
29
30class AcousticEchoCancelerSwContext final : public EffectContext {
31 public:
32 AcousticEchoCancelerSwContext(int statusDepth, const Parameter::Common& common)
33 : EffectContext(statusDepth, common) {
34 LOG(DEBUG) << __func__;
35 }
36
37 RetCode setEchoDelay(int echoDelayUs);
38 int getEchoDelay() const { return mEchoDelayUs; }
39
40 private:
Sham Rathodd7c6f322022-12-26 11:17:10 +053041 int mEchoDelayUs = 0;
Shunkai Yaobd862b82022-12-20 00:11:41 +000042};
43
44class AcousticEchoCancelerSw final : public EffectImpl {
45 public:
46 static const std::string kEffectName;
Shunkai Yao87811022023-02-13 17:40:37 +000047 static const Capability kCapability;
Shunkai Yaobd862b82022-12-20 00:11:41 +000048 static const Descriptor kDescriptor;
49 AcousticEchoCancelerSw() { LOG(DEBUG) << __func__; }
50 ~AcousticEchoCancelerSw() {
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:
Shunkai Yao87811022023-02-13 17:40:37 +000068 static const std::vector<Range::AcousticEchoCancelerRange> kRanges;
Shunkai Yaobd862b82022-12-20 00:11:41 +000069 std::shared_ptr<AcousticEchoCancelerSwContext> mContext;
70 ndk::ScopedAStatus getParameterAcousticEchoCanceler(const AcousticEchoCanceler::Tag& tag,
71 Parameter::Specific* specific);
72};
73} // namespace aidl::android::hardware::audio::effect