Shunkai Yao | 85b0169 | 2023-02-15 22:04:57 +0000 | [diff] [blame] | 1 | /* |
| 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" |
Shunkai Yao | 85b0169 | 2023-02-15 22:04:57 +0000 | [diff] [blame] | 25 | |
| 26 | namespace aidl::android::hardware::audio::effect { |
| 27 | |
| 28 | class ExtensionEffectContext final : public EffectContext { |
| 29 | public: |
| 30 | ExtensionEffectContext(int statusDepth, const Parameter::Common& common) |
| 31 | : EffectContext(statusDepth, common) { |
| 32 | LOG(DEBUG) << __func__; |
| 33 | } |
| 34 | |
| 35 | RetCode setParams(const std::vector<uint8_t>& params) { |
| 36 | mParams = params; |
| 37 | return RetCode::SUCCESS; |
| 38 | } |
Shunkai Yao | b2325e5 | 2023-03-03 19:34:47 +0000 | [diff] [blame] | 39 | std::vector<uint8_t> getParams(std::vector<uint8_t> id __unused) const { return mParams; } |
Shunkai Yao | 85b0169 | 2023-02-15 22:04:57 +0000 | [diff] [blame] | 40 | |
| 41 | private: |
| 42 | std::vector<uint8_t> mParams; |
| 43 | }; |
| 44 | |
| 45 | class ExtensionEffect final : public EffectImpl { |
| 46 | public: |
| 47 | static const std::string kEffectName; |
| 48 | static const Capability kCapability; |
| 49 | static const Descriptor kDescriptor; |
| 50 | ExtensionEffect() { LOG(DEBUG) << __func__; } |
| 51 | ~ExtensionEffect() { |
| 52 | cleanUp(); |
| 53 | LOG(DEBUG) << __func__; |
| 54 | } |
| 55 | |
| 56 | ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; |
Shunkai Yao | 65c7c70 | 2024-01-09 20:50:53 +0000 | [diff] [blame] | 57 | ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) |
| 58 | REQUIRES(mImplMutex) override; |
| 59 | ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific) |
| 60 | REQUIRES(mImplMutex) override; |
Shunkai Yao | 85b0169 | 2023-02-15 22:04:57 +0000 | [diff] [blame] | 61 | |
Shunkai Yao | 65c7c70 | 2024-01-09 20:50:53 +0000 | [diff] [blame] | 62 | std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) |
| 63 | REQUIRES(mImplMutex) override; |
| 64 | RetCode releaseContext() REQUIRES(mImplMutex) override; |
Shunkai Yao | 85b0169 | 2023-02-15 22:04:57 +0000 | [diff] [blame] | 65 | |
| 66 | std::string getEffectName() override { return kEffectName; }; |
Shunkai Yao | 65c7c70 | 2024-01-09 20:50:53 +0000 | [diff] [blame] | 67 | IEffect::Status effectProcessImpl(float* in, float* out, int samples) |
| 68 | REQUIRES(mImplMutex) override; |
Shunkai Yao | 85b0169 | 2023-02-15 22:04:57 +0000 | [diff] [blame] | 69 | |
| 70 | private: |
Shunkai Yao | 65c7c70 | 2024-01-09 20:50:53 +0000 | [diff] [blame] | 71 | std::shared_ptr<ExtensionEffectContext> mContext GUARDED_BY(mImplMutex); |
Shunkai Yao | 85b0169 | 2023-02-15 22:04:57 +0000 | [diff] [blame] | 72 | }; |
| 73 | } // namespace aidl::android::hardware::audio::effect |