blob: f432d4096dd41439cd3df805326b3c27b69ca1bb [file] [log] [blame]
Shunkai Yao85b01692023-02-15 22:04:57 +00001/*
2 * Copyright (C) 2023 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 <memory>
22#include <vector>
23
24#include "effect-impl/EffectImpl.h"
25#include "effect-impl/EffectUUID.h"
26
27namespace aidl::android::hardware::audio::effect {
28
29class ExtensionEffectContext final : public EffectContext {
30 public:
31 ExtensionEffectContext(int statusDepth, const Parameter::Common& common)
32 : EffectContext(statusDepth, common) {
33 LOG(DEBUG) << __func__;
34 }
35
36 RetCode setParams(const std::vector<uint8_t>& params) {
37 mParams = params;
38 return RetCode::SUCCESS;
39 }
Shunkai Yaob2325e52023-03-03 19:34:47 +000040 std::vector<uint8_t> getParams(std::vector<uint8_t> id __unused) const { return mParams; }
Shunkai Yao85b01692023-02-15 22:04:57 +000041
42 private:
43 std::vector<uint8_t> mParams;
44};
45
46class ExtensionEffect final : public EffectImpl {
47 public:
48 static const std::string kEffectName;
49 static const Capability kCapability;
50 static const Descriptor kDescriptor;
51 ExtensionEffect() { LOG(DEBUG) << __func__; }
52 ~ExtensionEffect() {
53 cleanUp();
54 LOG(DEBUG) << __func__;
55 }
56
57 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
58 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
59 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
60 Parameter::Specific* specific) override;
61
62 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
63 std::shared_ptr<EffectContext> getContext() override;
64 RetCode releaseContext() override;
65
66 std::string getEffectName() override { return kEffectName; };
67 IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
68
69 private:
70 std::shared_ptr<ExtensionEffectContext> mContext;
71};
72} // namespace aidl::android::hardware::audio::effect