1 /*
2  * Copyright (C) 2020 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 <android/hardware/audio/effect/7.0/IEffect.h>
20 
21 namespace android::hardware::audio::effect::V7_0::implementation {
22 
23 class Effect : public IEffect {
24   public:
Effect(const EffectDescriptor & descriptor)25     explicit Effect(const EffectDescriptor& descriptor) : mDescriptor(descriptor) {}
26 
27     ::android::hardware::Return<Result> init() override;
28     ::android::hardware::Return<Result> setConfig(
29             const EffectConfig& config,
30             const ::android::sp<IEffectBufferProviderCallback>& inputBufferProvider,
31             const ::android::sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
32     ::android::hardware::Return<Result> reset() override;
33     ::android::hardware::Return<Result> enable() override;
34     ::android::hardware::Return<Result> disable() override;
35     ::android::hardware::Return<Result> setDevice(
36             const ::android::hardware::audio::common::V7_0::DeviceAddress& device) override;
37     ::android::hardware::Return<void> setAndGetVolume(
38             const ::android::hardware::hidl_vec<uint32_t>& volumes,
39             setAndGetVolume_cb _hidl_cb) override;
40     ::android::hardware::Return<Result> volumeChangeNotification(
41             const ::android::hardware::hidl_vec<uint32_t>& volumes) override;
42     ::android::hardware::Return<Result> setAudioMode(
43             ::android::hardware::audio::common::V7_0::AudioMode mode) override;
44     ::android::hardware::Return<Result> setConfigReverse(
45             const EffectConfig& config,
46             const ::android::sp<IEffectBufferProviderCallback>& inputBufferProvider,
47             const ::android::sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
48     ::android::hardware::Return<Result> setInputDevice(
49             const ::android::hardware::audio::common::V7_0::DeviceAddress& device) override;
50     ::android::hardware::Return<void> getConfig(getConfig_cb _hidl_cb) override;
51     ::android::hardware::Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
52     ::android::hardware::Return<void> getSupportedAuxChannelsConfigs(
53             uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
54     ::android::hardware::Return<void> getAuxChannelsConfig(
55             getAuxChannelsConfig_cb _hidl_cb) override;
56     ::android::hardware::Return<Result> setAuxChannelsConfig(
57             const EffectAuxChannelsConfig& config) override;
58     ::android::hardware::Return<Result> setAudioSource(
59             const ::android::hardware::hidl_string& source) override;
60     ::android::hardware::Return<Result> offload(const EffectOffloadParameter& param) override;
61     ::android::hardware::Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
62     ::android::hardware::Return<void> prepareForProcessing(
63             prepareForProcessing_cb _hidl_cb) override;
64     ::android::hardware::Return<Result> setProcessBuffers(const AudioBuffer& inBuffer,
65                                                           const AudioBuffer& outBuffer) override;
66     ::android::hardware::Return<void> command(uint32_t commandId,
67                                               const ::android::hardware::hidl_vec<uint8_t>& data,
68                                               uint32_t resultMaxSize, command_cb _hidl_cb) override;
69     ::android::hardware::Return<Result> setParameter(
70             const ::android::hardware::hidl_vec<uint8_t>& parameter,
71             const ::android::hardware::hidl_vec<uint8_t>& value) override;
72     ::android::hardware::Return<void> getParameter(
73             const ::android::hardware::hidl_vec<uint8_t>& parameter, uint32_t valueMaxSize,
74             getParameter_cb _hidl_cb) override;
75     ::android::hardware::Return<void> getSupportedConfigsForFeature(
76             uint32_t featureId, uint32_t maxConfigs, uint32_t configSize,
77             getSupportedConfigsForFeature_cb _hidl_cb) override;
78     ::android::hardware::Return<void> getCurrentConfigForFeature(
79             uint32_t featureId, uint32_t configSize,
80             getCurrentConfigForFeature_cb _hidl_cb) override;
81     ::android::hardware::Return<Result> setCurrentConfigForFeature(
82             uint32_t featureId, const ::android::hardware::hidl_vec<uint8_t>& configData) override;
83     ::android::hardware::Return<Result> close() override;
84 
85   private:
86     const EffectDescriptor mDescriptor;
87     bool mEnabled = false;
88 };
89 
90 }  // namespace android::hardware::audio::effect::V7_0::implementation
91