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