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 #define LOG_TAG "PresetReverb_HAL"
18 #include <system/audio_effects/effect_presetreverb.h>
19 #include <android/log.h>
20
21 #include "PresetReverbEffect.h"
22
23 namespace android {
24 namespace hardware {
25 namespace audio {
26 namespace effect {
27 namespace V2_0 {
28 namespace implementation {
29
PresetReverbEffect(effect_handle_t handle)30 PresetReverbEffect::PresetReverbEffect(effect_handle_t handle)
31 : mEffect(new Effect(handle)) {
32 }
33
~PresetReverbEffect()34 PresetReverbEffect::~PresetReverbEffect() {}
35
36 // Methods from ::android::hardware::audio::effect::V2_0::IEffect follow.
init()37 Return<Result> PresetReverbEffect::init() {
38 return mEffect->init();
39 }
40
setConfig(const EffectConfig & config,const sp<IEffectBufferProviderCallback> & inputBufferProvider,const sp<IEffectBufferProviderCallback> & outputBufferProvider)41 Return<Result> PresetReverbEffect::setConfig(
42 const EffectConfig& config,
43 const sp<IEffectBufferProviderCallback>& inputBufferProvider,
44 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
45 return mEffect->setConfig(config, inputBufferProvider, outputBufferProvider);
46 }
47
reset()48 Return<Result> PresetReverbEffect::reset() {
49 return mEffect->reset();
50 }
51
enable()52 Return<Result> PresetReverbEffect::enable() {
53 return mEffect->enable();
54 }
55
disable()56 Return<Result> PresetReverbEffect::disable() {
57 return mEffect->disable();
58 }
59
setDevice(AudioDevice device)60 Return<Result> PresetReverbEffect::setDevice(AudioDevice device) {
61 return mEffect->setDevice(device);
62 }
63
setAndGetVolume(const hidl_vec<uint32_t> & volumes,setAndGetVolume_cb _hidl_cb)64 Return<void> PresetReverbEffect::setAndGetVolume(
65 const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb) {
66 return mEffect->setAndGetVolume(volumes, _hidl_cb);
67 }
68
volumeChangeNotification(const hidl_vec<uint32_t> & volumes)69 Return<Result> PresetReverbEffect::volumeChangeNotification(
70 const hidl_vec<uint32_t>& volumes) {
71 return mEffect->volumeChangeNotification(volumes);
72 }
73
setAudioMode(AudioMode mode)74 Return<Result> PresetReverbEffect::setAudioMode(AudioMode mode) {
75 return mEffect->setAudioMode(mode);
76 }
77
setConfigReverse(const EffectConfig & config,const sp<IEffectBufferProviderCallback> & inputBufferProvider,const sp<IEffectBufferProviderCallback> & outputBufferProvider)78 Return<Result> PresetReverbEffect::setConfigReverse(
79 const EffectConfig& config,
80 const sp<IEffectBufferProviderCallback>& inputBufferProvider,
81 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
82 return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
83 }
84
setInputDevice(AudioDevice device)85 Return<Result> PresetReverbEffect::setInputDevice(AudioDevice device) {
86 return mEffect->setInputDevice(device);
87 }
88
getConfig(getConfig_cb _hidl_cb)89 Return<void> PresetReverbEffect::getConfig(getConfig_cb _hidl_cb) {
90 return mEffect->getConfig(_hidl_cb);
91 }
92
getConfigReverse(getConfigReverse_cb _hidl_cb)93 Return<void> PresetReverbEffect::getConfigReverse(getConfigReverse_cb _hidl_cb) {
94 return mEffect->getConfigReverse(_hidl_cb);
95 }
96
getSupportedAuxChannelsConfigs(uint32_t maxConfigs,getSupportedAuxChannelsConfigs_cb _hidl_cb)97 Return<void> PresetReverbEffect::getSupportedAuxChannelsConfigs(
98 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) {
99 return mEffect->getSupportedAuxChannelsConfigs(maxConfigs, _hidl_cb);
100 }
101
getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb)102 Return<void> PresetReverbEffect::getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) {
103 return mEffect->getAuxChannelsConfig(_hidl_cb);
104 }
105
setAuxChannelsConfig(const EffectAuxChannelsConfig & config)106 Return<Result> PresetReverbEffect::setAuxChannelsConfig(
107 const EffectAuxChannelsConfig& config) {
108 return mEffect->setAuxChannelsConfig(config);
109 }
110
setAudioSource(AudioSource source)111 Return<Result> PresetReverbEffect::setAudioSource(AudioSource source) {
112 return mEffect->setAudioSource(source);
113 }
114
offload(const EffectOffloadParameter & param)115 Return<Result> PresetReverbEffect::offload(const EffectOffloadParameter& param) {
116 return mEffect->offload(param);
117 }
118
getDescriptor(getDescriptor_cb _hidl_cb)119 Return<void> PresetReverbEffect::getDescriptor(getDescriptor_cb _hidl_cb) {
120 return mEffect->getDescriptor(_hidl_cb);
121 }
122
prepareForProcessing(prepareForProcessing_cb _hidl_cb)123 Return<void> PresetReverbEffect::prepareForProcessing(
124 prepareForProcessing_cb _hidl_cb) {
125 return mEffect->prepareForProcessing(_hidl_cb);
126 }
127
setProcessBuffers(const AudioBuffer & inBuffer,const AudioBuffer & outBuffer)128 Return<Result> PresetReverbEffect::setProcessBuffers(
129 const AudioBuffer& inBuffer, const AudioBuffer& outBuffer) {
130 return mEffect->setProcessBuffers(inBuffer, outBuffer);
131 }
132
command(uint32_t commandId,const hidl_vec<uint8_t> & data,uint32_t resultMaxSize,command_cb _hidl_cb)133 Return<void> PresetReverbEffect::command(
134 uint32_t commandId,
135 const hidl_vec<uint8_t>& data,
136 uint32_t resultMaxSize,
137 command_cb _hidl_cb) {
138 return mEffect->command(commandId, data, resultMaxSize, _hidl_cb);
139 }
140
setParameter(const hidl_vec<uint8_t> & parameter,const hidl_vec<uint8_t> & value)141 Return<Result> PresetReverbEffect::setParameter(
142 const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value) {
143 return mEffect->setParameter(parameter, value);
144 }
145
getParameter(const hidl_vec<uint8_t> & parameter,uint32_t valueMaxSize,getParameter_cb _hidl_cb)146 Return<void> PresetReverbEffect::getParameter(
147 const hidl_vec<uint8_t>& parameter,
148 uint32_t valueMaxSize,
149 getParameter_cb _hidl_cb) {
150 return mEffect->getParameter(parameter, valueMaxSize, _hidl_cb);
151 }
152
getSupportedConfigsForFeature(uint32_t featureId,uint32_t maxConfigs,uint32_t configSize,getSupportedConfigsForFeature_cb _hidl_cb)153 Return<void> PresetReverbEffect::getSupportedConfigsForFeature(
154 uint32_t featureId,
155 uint32_t maxConfigs,
156 uint32_t configSize,
157 getSupportedConfigsForFeature_cb _hidl_cb) {
158 return mEffect->getSupportedConfigsForFeature(featureId, maxConfigs, configSize, _hidl_cb);
159 }
160
getCurrentConfigForFeature(uint32_t featureId,uint32_t configSize,getCurrentConfigForFeature_cb _hidl_cb)161 Return<void> PresetReverbEffect::getCurrentConfigForFeature(
162 uint32_t featureId,
163 uint32_t configSize,
164 getCurrentConfigForFeature_cb _hidl_cb) {
165 return mEffect->getCurrentConfigForFeature(featureId, configSize, _hidl_cb);
166 }
167
setCurrentConfigForFeature(uint32_t featureId,const hidl_vec<uint8_t> & configData)168 Return<Result> PresetReverbEffect::setCurrentConfigForFeature(
169 uint32_t featureId, const hidl_vec<uint8_t>& configData) {
170 return mEffect->setCurrentConfigForFeature(featureId, configData);
171 }
172
close()173 Return<Result> PresetReverbEffect::close() {
174 return mEffect->close();
175 }
176
177 // Methods from ::android::hardware::audio::effect::V2_0::IPresetReverbEffect follow.
setPreset(IPresetReverbEffect::Preset preset)178 Return<Result> PresetReverbEffect::setPreset(IPresetReverbEffect::Preset preset) {
179 return mEffect->setParam(REVERB_PARAM_PRESET, static_cast<t_reverb_presets>(preset));
180 }
181
getPreset(getPreset_cb _hidl_cb)182 Return<void> PresetReverbEffect::getPreset(getPreset_cb _hidl_cb) {
183 t_reverb_presets halPreset = REVERB_PRESET_NONE;
184 Result retval = mEffect->getParam(REVERB_PARAM_PRESET, halPreset);
185 _hidl_cb(retval, Preset(halPreset));
186 return Void();
187 }
188
189 } // namespace implementation
190 } // namespace V2_0
191 } // namespace effect
192 } // namespace audio
193 } // namespace hardware
194 } // namespace android
195