blob: e9baece2c675fd195273fb5d0c57630fdd0ef326 [file] [log] [blame]
Shunkai Yao6afc8552022-10-26 22:47:20 +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 VisualizerSwContext : public EffectContext {
30 public:
31 VisualizerSwContext(int statusDepth, const Parameter::Common& common)
32 : EffectContext(statusDepth, common) {
33 LOG(DEBUG) << __func__;
34 }
35 // TODO: add specific context here
36};
37
38class VisualizerSw : public EffectImpl {
39 public:
40 VisualizerSw() { LOG(DEBUG) << __func__; }
41 ~VisualizerSw() {
42 LOG(DEBUG) << __func__;
43 releaseContext();
44 }
45
46 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
47 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
48 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
49 Parameter::Specific* specific) override;
50 IEffect::Status effectProcessImpl(float* in, float* out, int process) override;
51 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
52 RetCode releaseContext() override;
53
54 private:
55 std::shared_ptr<VisualizerSwContext> mContext;
56 /* capabilities */
57 const Visualizer::Capability kCapability;
58 /* Effect descriptor */
59 const Descriptor kDescriptor = {
60 .common = {.id = {.type = VisualizerTypeUUID,
61 .uuid = VisualizerSwImplUUID,
62 .proxy = std::nullopt},
63 .flags = {.type = Flags::Type::INSERT,
64 .insert = Flags::Insert::FIRST,
65 .volume = Flags::Volume::CTRL},
66 .name = "VisualizerSw"},
67 .capability = Capability::make<Capability::visualizer>(kCapability)};
68
69 /* parameters */
70 Visualizer mSpecificParam;
71};
72} // namespace aidl::android::hardware::audio::effect