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 "EnvReverb_HAL"
18 #include <android/log.h>
19
20 #include "EnvironmentalReverbEffect.h"
21
22 namespace android {
23 namespace hardware {
24 namespace audio {
25 namespace effect {
26 namespace V2_0 {
27 namespace implementation {
28
EnvironmentalReverbEffect(effect_handle_t handle)29 EnvironmentalReverbEffect::EnvironmentalReverbEffect(effect_handle_t handle)
30 : mEffect(new Effect(handle)) {
31 }
32
~EnvironmentalReverbEffect()33 EnvironmentalReverbEffect::~EnvironmentalReverbEffect() {}
34
propertiesFromHal(const t_reverb_settings & halProperties,IEnvironmentalReverbEffect::AllProperties * properties)35 void EnvironmentalReverbEffect::propertiesFromHal(
36 const t_reverb_settings& halProperties,
37 IEnvironmentalReverbEffect::AllProperties* properties) {
38 properties->roomLevel = halProperties.roomLevel;
39 properties->roomHfLevel = halProperties.roomHFLevel;
40 properties->decayTime = halProperties.decayTime;
41 properties->decayHfRatio = halProperties.decayHFRatio;
42 properties->reflectionsLevel = halProperties.reflectionsLevel;
43 properties->reflectionsDelay = halProperties.reflectionsDelay;
44 properties->reverbLevel = halProperties.reverbLevel;
45 properties->reverbDelay = halProperties.reverbDelay;
46 properties->diffusion = halProperties.diffusion;
47 properties->density = halProperties.density;
48 }
49
propertiesToHal(const IEnvironmentalReverbEffect::AllProperties & properties,t_reverb_settings * halProperties)50 void EnvironmentalReverbEffect::propertiesToHal(
51 const IEnvironmentalReverbEffect::AllProperties& properties,
52 t_reverb_settings* halProperties) {
53 halProperties->roomLevel = properties.roomLevel;
54 halProperties->roomHFLevel = properties.roomHfLevel;
55 halProperties->decayTime = properties.decayTime;
56 halProperties->decayHFRatio = properties.decayHfRatio;
57 halProperties->reflectionsLevel = properties.reflectionsLevel;
58 halProperties->reflectionsDelay = properties.reflectionsDelay;
59 halProperties->reverbLevel = properties.reverbLevel;
60 halProperties->reverbDelay = properties.reverbDelay;
61 halProperties->diffusion = properties.diffusion;
62 halProperties->density = properties.density;
63 }
64
65 // Methods from ::android::hardware::audio::effect::V2_0::IEffect follow.
init()66 Return<Result> EnvironmentalReverbEffect::init() {
67 return mEffect->init();
68 }
69
setConfig(const EffectConfig & config,const sp<IEffectBufferProviderCallback> & inputBufferProvider,const sp<IEffectBufferProviderCallback> & outputBufferProvider)70 Return<Result> EnvironmentalReverbEffect::setConfig(
71 const EffectConfig& config,
72 const sp<IEffectBufferProviderCallback>& inputBufferProvider,
73 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
74 return mEffect->setConfig(config, inputBufferProvider, outputBufferProvider);
75 }
76
reset()77 Return<Result> EnvironmentalReverbEffect::reset() {
78 return mEffect->reset();
79 }
80
enable()81 Return<Result> EnvironmentalReverbEffect::enable() {
82 return mEffect->enable();
83 }
84
disable()85 Return<Result> EnvironmentalReverbEffect::disable() {
86 return mEffect->disable();
87 }
88
setDevice(AudioDevice device)89 Return<Result> EnvironmentalReverbEffect::setDevice(AudioDevice device) {
90 return mEffect->setDevice(device);
91 }
92
setAndGetVolume(const hidl_vec<uint32_t> & volumes,setAndGetVolume_cb _hidl_cb)93 Return<void> EnvironmentalReverbEffect::setAndGetVolume(
94 const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb) {
95 return mEffect->setAndGetVolume(volumes, _hidl_cb);
96 }
97
volumeChangeNotification(const hidl_vec<uint32_t> & volumes)98 Return<Result> EnvironmentalReverbEffect::volumeChangeNotification(
99 const hidl_vec<uint32_t>& volumes) {
100 return mEffect->volumeChangeNotification(volumes);
101 }
102
setAudioMode(AudioMode mode)103 Return<Result> EnvironmentalReverbEffect::setAudioMode(AudioMode mode) {
104 return mEffect->setAudioMode(mode);
105 }
106
setConfigReverse(const EffectConfig & config,const sp<IEffectBufferProviderCallback> & inputBufferProvider,const sp<IEffectBufferProviderCallback> & outputBufferProvider)107 Return<Result> EnvironmentalReverbEffect::setConfigReverse(
108 const EffectConfig& config,
109 const sp<IEffectBufferProviderCallback>& inputBufferProvider,
110 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
111 return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
112 }
113
setInputDevice(AudioDevice device)114 Return<Result> EnvironmentalReverbEffect::setInputDevice(AudioDevice device) {
115 return mEffect->setInputDevice(device);
116 }
117
getConfig(getConfig_cb _hidl_cb)118 Return<void> EnvironmentalReverbEffect::getConfig(getConfig_cb _hidl_cb) {
119 return mEffect->getConfig(_hidl_cb);
120 }
121
getConfigReverse(getConfigReverse_cb _hidl_cb)122 Return<void> EnvironmentalReverbEffect::getConfigReverse(getConfigReverse_cb _hidl_cb) {
123 return mEffect->getConfigReverse(_hidl_cb);
124 }
125
getSupportedAuxChannelsConfigs(uint32_t maxConfigs,getSupportedAuxChannelsConfigs_cb _hidl_cb)126 Return<void> EnvironmentalReverbEffect::getSupportedAuxChannelsConfigs(
127 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) {
128 return mEffect->getSupportedAuxChannelsConfigs(maxConfigs, _hidl_cb);
129 }
130
getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb)131 Return<void> EnvironmentalReverbEffect::getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) {
132 return mEffect->getAuxChannelsConfig(_hidl_cb);
133 }
134
setAuxChannelsConfig(const EffectAuxChannelsConfig & config)135 Return<Result> EnvironmentalReverbEffect::setAuxChannelsConfig(
136 const EffectAuxChannelsConfig& config) {
137 return mEffect->setAuxChannelsConfig(config);
138 }
139
setAudioSource(AudioSource source)140 Return<Result> EnvironmentalReverbEffect::setAudioSource(AudioSource source) {
141 return mEffect->setAudioSource(source);
142 }
143
offload(const EffectOffloadParameter & param)144 Return<Result> EnvironmentalReverbEffect::offload(const EffectOffloadParameter& param) {
145 return mEffect->offload(param);
146 }
147
getDescriptor(getDescriptor_cb _hidl_cb)148 Return<void> EnvironmentalReverbEffect::getDescriptor(getDescriptor_cb _hidl_cb) {
149 return mEffect->getDescriptor(_hidl_cb);
150 }
151
prepareForProcessing(prepareForProcessing_cb _hidl_cb)152 Return<void> EnvironmentalReverbEffect::prepareForProcessing(
153 prepareForProcessing_cb _hidl_cb) {
154 return mEffect->prepareForProcessing(_hidl_cb);
155 }
156
setProcessBuffers(const AudioBuffer & inBuffer,const AudioBuffer & outBuffer)157 Return<Result> EnvironmentalReverbEffect::setProcessBuffers(
158 const AudioBuffer& inBuffer, const AudioBuffer& outBuffer) {
159 return mEffect->setProcessBuffers(inBuffer, outBuffer);
160 }
161
command(uint32_t commandId,const hidl_vec<uint8_t> & data,uint32_t resultMaxSize,command_cb _hidl_cb)162 Return<void> EnvironmentalReverbEffect::command(
163 uint32_t commandId,
164 const hidl_vec<uint8_t>& data,
165 uint32_t resultMaxSize,
166 command_cb _hidl_cb) {
167 return mEffect->command(commandId, data, resultMaxSize, _hidl_cb);
168 }
169
setParameter(const hidl_vec<uint8_t> & parameter,const hidl_vec<uint8_t> & value)170 Return<Result> EnvironmentalReverbEffect::setParameter(
171 const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value) {
172 return mEffect->setParameter(parameter, value);
173 }
174
getParameter(const hidl_vec<uint8_t> & parameter,uint32_t valueMaxSize,getParameter_cb _hidl_cb)175 Return<void> EnvironmentalReverbEffect::getParameter(
176 const hidl_vec<uint8_t>& parameter,
177 uint32_t valueMaxSize,
178 getParameter_cb _hidl_cb) {
179 return mEffect->getParameter(parameter, valueMaxSize, _hidl_cb);
180 }
181
getSupportedConfigsForFeature(uint32_t featureId,uint32_t maxConfigs,uint32_t configSize,getSupportedConfigsForFeature_cb _hidl_cb)182 Return<void> EnvironmentalReverbEffect::getSupportedConfigsForFeature(
183 uint32_t featureId,
184 uint32_t maxConfigs,
185 uint32_t configSize,
186 getSupportedConfigsForFeature_cb _hidl_cb) {
187 return mEffect->getSupportedConfigsForFeature(featureId, maxConfigs, configSize, _hidl_cb);
188 }
189
getCurrentConfigForFeature(uint32_t featureId,uint32_t configSize,getCurrentConfigForFeature_cb _hidl_cb)190 Return<void> EnvironmentalReverbEffect::getCurrentConfigForFeature(
191 uint32_t featureId,
192 uint32_t configSize,
193 getCurrentConfigForFeature_cb _hidl_cb) {
194 return mEffect->getCurrentConfigForFeature(featureId, configSize, _hidl_cb);
195 }
196
setCurrentConfigForFeature(uint32_t featureId,const hidl_vec<uint8_t> & configData)197 Return<Result> EnvironmentalReverbEffect::setCurrentConfigForFeature(
198 uint32_t featureId, const hidl_vec<uint8_t>& configData) {
199 return mEffect->setCurrentConfigForFeature(featureId, configData);
200 }
201
close()202 Return<Result> EnvironmentalReverbEffect::close() {
203 return mEffect->close();
204 }
205
206 // Methods from ::android::hardware::audio::effect::V2_0::IEnvironmentalReverbEffect follow.
setBypass(bool bypass)207 Return<Result> EnvironmentalReverbEffect::setBypass(bool bypass) {
208 return mEffect->setParam(REVERB_PARAM_BYPASS, bypass);
209 }
210
getBypass(getBypass_cb _hidl_cb)211 Return<void> EnvironmentalReverbEffect::getBypass(getBypass_cb _hidl_cb) {
212 return mEffect->getIntegerParam(REVERB_PARAM_BYPASS, _hidl_cb);
213 }
214
setRoomLevel(int16_t roomLevel)215 Return<Result> EnvironmentalReverbEffect::setRoomLevel(int16_t roomLevel) {
216 return mEffect->setParam(REVERB_PARAM_ROOM_LEVEL, roomLevel);
217 }
218
getRoomLevel(getRoomLevel_cb _hidl_cb)219 Return<void> EnvironmentalReverbEffect::getRoomLevel(getRoomLevel_cb _hidl_cb) {
220 return mEffect->getIntegerParam(REVERB_PARAM_ROOM_LEVEL, _hidl_cb);
221 }
222
setRoomHfLevel(int16_t roomHfLevel)223 Return<Result> EnvironmentalReverbEffect::setRoomHfLevel(int16_t roomHfLevel) {
224 return mEffect->setParam(REVERB_PARAM_ROOM_HF_LEVEL, roomHfLevel);
225 }
226
getRoomHfLevel(getRoomHfLevel_cb _hidl_cb)227 Return<void> EnvironmentalReverbEffect::getRoomHfLevel(getRoomHfLevel_cb _hidl_cb) {
228 return mEffect->getIntegerParam(REVERB_PARAM_ROOM_HF_LEVEL, _hidl_cb);
229 }
230
setDecayTime(uint32_t decayTime)231 Return<Result> EnvironmentalReverbEffect::setDecayTime(uint32_t decayTime) {
232 return mEffect->setParam(REVERB_PARAM_DECAY_TIME, decayTime);
233 }
234
getDecayTime(getDecayTime_cb _hidl_cb)235 Return<void> EnvironmentalReverbEffect::getDecayTime(getDecayTime_cb _hidl_cb) {
236 return mEffect->getIntegerParam(REVERB_PARAM_DECAY_TIME, _hidl_cb);
237 }
238
setDecayHfRatio(int16_t decayHfRatio)239 Return<Result> EnvironmentalReverbEffect::setDecayHfRatio(int16_t decayHfRatio) {
240 return mEffect->setParam(REVERB_PARAM_DECAY_HF_RATIO, decayHfRatio);
241 }
242
getDecayHfRatio(getDecayHfRatio_cb _hidl_cb)243 Return<void> EnvironmentalReverbEffect::getDecayHfRatio(getDecayHfRatio_cb _hidl_cb) {
244 return mEffect->getIntegerParam(REVERB_PARAM_DECAY_HF_RATIO, _hidl_cb);
245 }
246
setReflectionsLevel(int16_t reflectionsLevel)247 Return<Result> EnvironmentalReverbEffect::setReflectionsLevel(int16_t reflectionsLevel) {
248 return mEffect->setParam(REVERB_PARAM_REFLECTIONS_LEVEL, reflectionsLevel);
249 }
250
getReflectionsLevel(getReflectionsLevel_cb _hidl_cb)251 Return<void> EnvironmentalReverbEffect::getReflectionsLevel(getReflectionsLevel_cb _hidl_cb) {
252 return mEffect->getIntegerParam(REVERB_PARAM_REFLECTIONS_LEVEL, _hidl_cb);
253 }
254
setReflectionsDelay(uint32_t reflectionsDelay)255 Return<Result> EnvironmentalReverbEffect::setReflectionsDelay(uint32_t reflectionsDelay) {
256 return mEffect->setParam(REVERB_PARAM_REFLECTIONS_DELAY, reflectionsDelay);
257 }
258
getReflectionsDelay(getReflectionsDelay_cb _hidl_cb)259 Return<void> EnvironmentalReverbEffect::getReflectionsDelay(getReflectionsDelay_cb _hidl_cb) {
260 return mEffect->getIntegerParam(REVERB_PARAM_REFLECTIONS_DELAY, _hidl_cb);
261 }
262
setReverbLevel(int16_t reverbLevel)263 Return<Result> EnvironmentalReverbEffect::setReverbLevel(int16_t reverbLevel) {
264 return mEffect->setParam(REVERB_PARAM_REVERB_LEVEL, reverbLevel);
265 }
266
getReverbLevel(getReverbLevel_cb _hidl_cb)267 Return<void> EnvironmentalReverbEffect::getReverbLevel(getReverbLevel_cb _hidl_cb) {
268 return mEffect->getIntegerParam(REVERB_PARAM_REVERB_LEVEL, _hidl_cb);
269 }
270
setReverbDelay(uint32_t reverbDelay)271 Return<Result> EnvironmentalReverbEffect::setReverbDelay(uint32_t reverbDelay) {
272 return mEffect->setParam(REVERB_PARAM_REVERB_DELAY, reverbDelay);
273 }
274
getReverbDelay(getReverbDelay_cb _hidl_cb)275 Return<void> EnvironmentalReverbEffect::getReverbDelay(getReverbDelay_cb _hidl_cb) {
276 return mEffect->getIntegerParam(REVERB_PARAM_REVERB_DELAY, _hidl_cb);
277 }
278
setDiffusion(int16_t diffusion)279 Return<Result> EnvironmentalReverbEffect::setDiffusion(int16_t diffusion) {
280 return mEffect->setParam(REVERB_PARAM_DIFFUSION, diffusion);
281 }
282
getDiffusion(getDiffusion_cb _hidl_cb)283 Return<void> EnvironmentalReverbEffect::getDiffusion(getDiffusion_cb _hidl_cb) {
284 return mEffect->getIntegerParam(REVERB_PARAM_DIFFUSION, _hidl_cb);
285 }
286
setDensity(int16_t density)287 Return<Result> EnvironmentalReverbEffect::setDensity(int16_t density) {
288 return mEffect->setParam(REVERB_PARAM_DENSITY, density);
289 }
290
getDensity(getDensity_cb _hidl_cb)291 Return<void> EnvironmentalReverbEffect::getDensity(getDensity_cb _hidl_cb) {
292 return mEffect->getIntegerParam(REVERB_PARAM_DENSITY, _hidl_cb);
293 }
294
setAllProperties(const IEnvironmentalReverbEffect::AllProperties & properties)295 Return<Result> EnvironmentalReverbEffect::setAllProperties(
296 const IEnvironmentalReverbEffect::AllProperties& properties) {
297 t_reverb_settings halProperties;
298 propertiesToHal(properties, &halProperties);
299 return mEffect->setParam(REVERB_PARAM_PROPERTIES, halProperties);
300 }
301
getAllProperties(getAllProperties_cb _hidl_cb)302 Return<void> EnvironmentalReverbEffect::getAllProperties(getAllProperties_cb _hidl_cb) {
303 t_reverb_settings halProperties;
304 Result retval = mEffect->getParam(REVERB_PARAM_PROPERTIES, halProperties);
305 AllProperties properties;
306 propertiesFromHal(halProperties, &properties);
307 _hidl_cb(retval, properties);
308 return Void();
309 }
310
311 } // namespace implementation
312 } // namespace V2_0
313 } // namespace effect
314 } // namespace audio
315 } // namespace hardware
316 } // namespace android
317