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