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