blob: 2c386d3deca209a086f4fdb175a169f01712fe32 [file] [log] [blame]
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07001/*
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 "AGC_Effect_HAL"
Yifan Hongf9d30342016-11-30 13:45:34 -080018#include <android/log.h>
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070019
20#include "AutomaticGainControlEffect.h"
21
22namespace android {
23namespace hardware {
24namespace audio {
25namespace effect {
26namespace V2_0 {
27namespace implementation {
28
29AutomaticGainControlEffect::AutomaticGainControlEffect(effect_handle_t handle)
30 : mEffect(new Effect(handle)) {
31}
32
33AutomaticGainControlEffect::~AutomaticGainControlEffect() {}
34
35void AutomaticGainControlEffect::propertiesFromHal(
36 const t_agc_settings& halProperties,
37 IAutomaticGainControlEffect::AllProperties* properties) {
38 properties->targetLevelMb = halProperties.targetLevel;
39 properties->compGainMb = halProperties.compGain;
40 properties->limiterEnabled = halProperties.limiterEnabled;
41}
42
43void AutomaticGainControlEffect::propertiesToHal(
44 const IAutomaticGainControlEffect::AllProperties& properties,
45 t_agc_settings* halProperties) {
46 halProperties->targetLevel = properties.targetLevelMb;
47 halProperties->compGain = properties.compGainMb;
48 halProperties->limiterEnabled = properties.limiterEnabled;
49}
50
51// Methods from ::android::hardware::audio::effect::V2_0::IEffect follow.
52Return<Result> AutomaticGainControlEffect::init() {
53 return mEffect->init();
54}
55
56Return<Result> AutomaticGainControlEffect::setConfig(
57 const EffectConfig& config,
58 const sp<IEffectBufferProviderCallback>& inputBufferProvider,
59 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
60 return mEffect->setConfig(config, inputBufferProvider, outputBufferProvider);
61}
62
63Return<Result> AutomaticGainControlEffect::reset() {
64 return mEffect->reset();
65}
66
67Return<Result> AutomaticGainControlEffect::enable() {
68 return mEffect->enable();
69}
70
71Return<Result> AutomaticGainControlEffect::disable() {
72 return mEffect->disable();
73}
74
75Return<Result> AutomaticGainControlEffect::setDevice(AudioDevice device) {
76 return mEffect->setDevice(device);
77}
78
79Return<void> AutomaticGainControlEffect::setAndGetVolume(
80 const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb) {
81 return mEffect->setAndGetVolume(volumes, _hidl_cb);
82}
83
84Return<Result> AutomaticGainControlEffect::setAudioMode(AudioMode mode) {
85 return mEffect->setAudioMode(mode);
86}
87
88Return<Result> AutomaticGainControlEffect::setConfigReverse(
89 const EffectConfig& config,
90 const sp<IEffectBufferProviderCallback>& inputBufferProvider,
91 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
92 return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
93}
94
95Return<Result> AutomaticGainControlEffect::setInputDevice(AudioDevice device) {
96 return mEffect->setInputDevice(device);
97}
98
99Return<void> AutomaticGainControlEffect::getConfig(getConfig_cb _hidl_cb) {
100 return mEffect->getConfig(_hidl_cb);
101}
102
103Return<void> AutomaticGainControlEffect::getConfigReverse(getConfigReverse_cb _hidl_cb) {
104 return mEffect->getConfigReverse(_hidl_cb);
105}
106
107Return<void> AutomaticGainControlEffect::getSupportedAuxChannelsConfigs(
108 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) {
109 return mEffect->getSupportedAuxChannelsConfigs(maxConfigs, _hidl_cb);
110}
111
112Return<void> AutomaticGainControlEffect::getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) {
113 return mEffect->getAuxChannelsConfig(_hidl_cb);
114}
115
116Return<Result> AutomaticGainControlEffect::setAuxChannelsConfig(
117 const EffectAuxChannelsConfig& config) {
118 return mEffect->setAuxChannelsConfig(config);
119}
120
121Return<Result> AutomaticGainControlEffect::setAudioSource(AudioSource source) {
122 return mEffect->setAudioSource(source);
123}
124
125Return<Result> AutomaticGainControlEffect::offload(const EffectOffloadParameter& param) {
126 return mEffect->offload(param);
127}
128
129Return<void> AutomaticGainControlEffect::getDescriptor(getDescriptor_cb _hidl_cb) {
130 return mEffect->getDescriptor(_hidl_cb);
131}
132
Mikhail Naganova331de12017-01-04 16:33:55 -0800133Return<void> AutomaticGainControlEffect::prepareForProcessing(
134 prepareForProcessing_cb _hidl_cb) {
135 return mEffect->prepareForProcessing(_hidl_cb);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700136}
137
Mikhail Naganova331de12017-01-04 16:33:55 -0800138Return<Result> AutomaticGainControlEffect::setProcessBuffers(
139 const AudioBuffer& inBuffer, const AudioBuffer& outBuffer) {
140 return mEffect->setProcessBuffers(inBuffer, outBuffer);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700141}
142
143Return<void> AutomaticGainControlEffect::command(
144 uint32_t commandId,
145 const hidl_vec<uint8_t>& data,
146 uint32_t resultMaxSize,
147 command_cb _hidl_cb) {
148 return mEffect->command(commandId, data, resultMaxSize, _hidl_cb);
149}
150
151Return<Result> AutomaticGainControlEffect::setParameter(
152 const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value) {
153 return mEffect->setParameter(parameter, value);
154}
155
156Return<void> AutomaticGainControlEffect::getParameter(
157 const hidl_vec<uint8_t>& parameter,
158 uint32_t valueMaxSize,
159 getParameter_cb _hidl_cb) {
160 return mEffect->getParameter(parameter, valueMaxSize, _hidl_cb);
161}
162
163Return<void> AutomaticGainControlEffect::getSupportedConfigsForFeature(
164 uint32_t featureId,
165 uint32_t maxConfigs,
166 uint32_t configSize,
167 getSupportedConfigsForFeature_cb _hidl_cb) {
168 return mEffect->getSupportedConfigsForFeature(featureId, maxConfigs, configSize, _hidl_cb);
169}
170
171Return<void> AutomaticGainControlEffect::getCurrentConfigForFeature(
172 uint32_t featureId,
173 uint32_t configSize,
174 getCurrentConfigForFeature_cb _hidl_cb) {
175 return mEffect->getCurrentConfigForFeature(featureId, configSize, _hidl_cb);
176}
177
178Return<Result> AutomaticGainControlEffect::setCurrentConfigForFeature(
179 uint32_t featureId, const hidl_vec<uint8_t>& configData) {
180 return mEffect->setCurrentConfigForFeature(featureId, configData);
181}
182
Mikhail Naganova331de12017-01-04 16:33:55 -0800183Return<Result> AutomaticGainControlEffect::close() {
184 return mEffect->close();
185}
186
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700187// Methods from ::android::hardware::audio::effect::V2_0::IAutomaticGainControlEffect follow.
188Return<Result> AutomaticGainControlEffect::setTargetLevel(int16_t targetLevelMb) {
189 return mEffect->setParam(AGC_PARAM_TARGET_LEVEL, targetLevelMb);
190}
191
192Return<void> AutomaticGainControlEffect::getTargetLevel(getTargetLevel_cb _hidl_cb) {
193 return mEffect->getIntegerParam(AGC_PARAM_TARGET_LEVEL, _hidl_cb);
194}
195
196Return<Result> AutomaticGainControlEffect::setCompGain(int16_t compGainMb) {
197 return mEffect->setParam(AGC_PARAM_COMP_GAIN, compGainMb);
198}
199
200Return<void> AutomaticGainControlEffect::getCompGain(getCompGain_cb _hidl_cb) {
201 return mEffect->getIntegerParam(AGC_PARAM_COMP_GAIN, _hidl_cb);
202}
203
204Return<Result> AutomaticGainControlEffect::setLimiterEnabled(bool enabled) {
205 return mEffect->setParam(AGC_PARAM_LIMITER_ENA, enabled);
206}
207
208Return<void> AutomaticGainControlEffect::isLimiterEnabled(isLimiterEnabled_cb _hidl_cb) {
209 return mEffect->getIntegerParam(AGC_PARAM_LIMITER_ENA, _hidl_cb);
210}
211
212Return<Result> AutomaticGainControlEffect::setAllProperties(const IAutomaticGainControlEffect::AllProperties& properties) {
213 t_agc_settings halProperties;
214 propertiesToHal(properties, &halProperties);
215 return mEffect->setParam(AGC_PARAM_PROPERTIES, halProperties);
216}
217
218Return<void> AutomaticGainControlEffect::getAllProperties(getAllProperties_cb _hidl_cb) {
219 t_agc_settings halProperties;
220 Result retval = mEffect->getParam(AGC_PARAM_PROPERTIES, halProperties);
221 AllProperties properties;
222 propertiesFromHal(halProperties, &properties);
223 _hidl_cb(retval, properties);
224 return Void();
225}
226
227} // namespace implementation
228} // namespace V2_0
229} // namespace effect
230} // namespace audio
231} // namespace hardware
232} // namespace android