1 /*
2  * Copyright (C) 2016 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 #ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H
18 #define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H
19 
20 #include <android/hardware/audio/effect/2.0/IVisualizerEffect.h>
21 #include <hidl/Status.h>
22 
23 #include <hidl/MQDescriptor.h>
24 
25 #include "Effect.h"
26 
27 namespace android {
28 namespace hardware {
29 namespace audio {
30 namespace effect {
31 namespace V2_0 {
32 namespace implementation {
33 
34 using ::android::hardware::audio::common::V2_0::AudioDevice;
35 using ::android::hardware::audio::common::V2_0::AudioMode;
36 using ::android::hardware::audio::common::V2_0::AudioSource;
37 using ::android::hardware::audio::effect::V2_0::AudioBuffer;
38 using ::android::hardware::audio::effect::V2_0::EffectAuxChannelsConfig;
39 using ::android::hardware::audio::effect::V2_0::EffectConfig;
40 using ::android::hardware::audio::effect::V2_0::EffectDescriptor;
41 using ::android::hardware::audio::effect::V2_0::EffectOffloadParameter;
42 using ::android::hardware::audio::effect::V2_0::IEffect;
43 using ::android::hardware::audio::effect::V2_0::IEffectBufferProviderCallback;
44 using ::android::hardware::audio::effect::V2_0::IVisualizerEffect;
45 using ::android::hardware::audio::effect::V2_0::Result;
46 using ::android::hardware::Return;
47 using ::android::hardware::Void;
48 using ::android::hardware::hidl_vec;
49 using ::android::hardware::hidl_string;
50 using ::android::sp;
51 
52 struct VisualizerEffect : public IVisualizerEffect {
53     explicit VisualizerEffect(effect_handle_t handle);
54 
55     // Methods from ::android::hardware::audio::effect::V2_0::IEffect follow.
56     Return<Result> init()  override;
57     Return<Result> setConfig(
58             const EffectConfig& config,
59             const sp<IEffectBufferProviderCallback>& inputBufferProvider,
60             const sp<IEffectBufferProviderCallback>& outputBufferProvider)  override;
61     Return<Result> reset()  override;
62     Return<Result> enable()  override;
63     Return<Result> disable()  override;
64     Return<Result> setDevice(AudioDevice device)  override;
65     Return<void> setAndGetVolume(
66             const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb)  override;
67     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes)  override;
68     Return<Result> setAudioMode(AudioMode mode)  override;
69     Return<Result> setConfigReverse(
70             const EffectConfig& config,
71             const sp<IEffectBufferProviderCallback>& inputBufferProvider,
72             const sp<IEffectBufferProviderCallback>& outputBufferProvider)  override;
73     Return<Result> setInputDevice(AudioDevice device)  override;
74     Return<void> getConfig(getConfig_cb _hidl_cb)  override;
75     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb)  override;
76     Return<void> getSupportedAuxChannelsConfigs(
77             uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb)  override;
78     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb)  override;
79     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config)  override;
80     Return<Result> setAudioSource(AudioSource source)  override;
81     Return<Result> offload(const EffectOffloadParameter& param)  override;
82     Return<void> getDescriptor(getDescriptor_cb _hidl_cb)  override;
83     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb)  override;
84     Return<Result> setProcessBuffers(
85             const AudioBuffer& inBuffer, const AudioBuffer& outBuffer)  override;
86     Return<void> command(
87             uint32_t commandId,
88             const hidl_vec<uint8_t>& data,
89             uint32_t resultMaxSize,
90             command_cb _hidl_cb)  override;
91     Return<Result> setParameter(
92             const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value)  override;
93     Return<void> getParameter(
94             const hidl_vec<uint8_t>& parameter,
95             uint32_t valueMaxSize,
96             getParameter_cb _hidl_cb)  override;
97     Return<void> getSupportedConfigsForFeature(
98             uint32_t featureId,
99             uint32_t maxConfigs,
100             uint32_t configSize,
101             getSupportedConfigsForFeature_cb _hidl_cb)  override;
102     Return<void> getCurrentConfigForFeature(
103             uint32_t featureId,
104             uint32_t configSize,
105             getCurrentConfigForFeature_cb _hidl_cb)  override;
106     Return<Result> setCurrentConfigForFeature(
107             uint32_t featureId, const hidl_vec<uint8_t>& configData)  override;
108     Return<Result> close()  override;
109 
110     // Methods from ::android::hardware::audio::effect::V2_0::IVisualizerEffect follow.
111     Return<Result> setCaptureSize(uint16_t captureSize)  override;
112     Return<void> getCaptureSize(getCaptureSize_cb _hidl_cb)  override;
113     Return<Result> setScalingMode(IVisualizerEffect::ScalingMode scalingMode)  override;
114     Return<void> getScalingMode(getScalingMode_cb _hidl_cb)  override;
115     Return<Result> setLatency(uint32_t latencyMs)  override;
116     Return<void> getLatency(getLatency_cb _hidl_cb)  override;
117     Return<Result> setMeasurementMode(IVisualizerEffect::MeasurementMode measurementMode)  override;
118     Return<void> getMeasurementMode(getMeasurementMode_cb _hidl_cb)  override;
119     Return<void> capture(capture_cb _hidl_cb)  override;
120     Return<void> measure(measure_cb _hidl_cb)  override;
121 
122   private:
123     sp<Effect> mEffect;
124     uint16_t mCaptureSize;
125     MeasurementMode mMeasurementMode;
126 
127     virtual ~VisualizerEffect();
128 };
129 
130 }  // namespace implementation
131 }  // namespace V2_0
132 }  // namespace effect
133 }  // namespace audio
134 }  // namespace hardware
135 }  // namespace android
136 
137 #endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H
138