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 "Downmix_HAL"
18
19 #include "DownmixEffect.h"
20
21 #include <android/log.h>
22 #include <system/audio_effects/effect_downmix.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
DownmixEffect(effect_handle_t handle)33 DownmixEffect::DownmixEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
34
~DownmixEffect()35 DownmixEffect::~DownmixEffect() {}
36
37 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
init()38 Return<Result> DownmixEffect::init() {
39 return mEffect->init();
40 }
41
setConfig(const EffectConfig & config,const sp<IEffectBufferProviderCallback> & inputBufferProvider,const sp<IEffectBufferProviderCallback> & outputBufferProvider)42 Return<Result> DownmixEffect::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> DownmixEffect::reset() {
49 return mEffect->reset();
50 }
51
enable()52 Return<Result> DownmixEffect::enable() {
53 return mEffect->enable();
54 }
55
disable()56 Return<Result> DownmixEffect::disable() {
57 return mEffect->disable();
58 }
59
setDevice(AudioDeviceBitfield device)60 Return<Result> DownmixEffect::setDevice(AudioDeviceBitfield device) {
61 return mEffect->setDevice(device);
62 }
63
setAndGetVolume(const hidl_vec<uint32_t> & volumes,setAndGetVolume_cb _hidl_cb)64 Return<void> DownmixEffect::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> DownmixEffect::volumeChangeNotification(const hidl_vec<uint32_t>& volumes) {
70 return mEffect->volumeChangeNotification(volumes);
71 }
72
setAudioMode(AudioMode mode)73 Return<Result> DownmixEffect::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> DownmixEffect::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> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
84 return mEffect->setInputDevice(device);
85 }
86
getConfig(getConfig_cb _hidl_cb)87 Return<void> DownmixEffect::getConfig(getConfig_cb _hidl_cb) {
88 return mEffect->getConfig(_hidl_cb);
89 }
90
getConfigReverse(getConfigReverse_cb _hidl_cb)91 Return<void> DownmixEffect::getConfigReverse(getConfigReverse_cb _hidl_cb) {
92 return mEffect->getConfigReverse(_hidl_cb);
93 }
94
getSupportedAuxChannelsConfigs(uint32_t maxConfigs,getSupportedAuxChannelsConfigs_cb _hidl_cb)95 Return<void> DownmixEffect::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> DownmixEffect::getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) {
101 return mEffect->getAuxChannelsConfig(_hidl_cb);
102 }
103
setAuxChannelsConfig(const EffectAuxChannelsConfig & config)104 Return<Result> DownmixEffect::setAuxChannelsConfig(const EffectAuxChannelsConfig& config) {
105 return mEffect->setAuxChannelsConfig(config);
106 }
107
setAudioSource(AudioSource source)108 Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
109 return mEffect->setAudioSource(source);
110 }
111
offload(const EffectOffloadParameter & param)112 Return<Result> DownmixEffect::offload(const EffectOffloadParameter& param) {
113 return mEffect->offload(param);
114 }
115
getDescriptor(getDescriptor_cb _hidl_cb)116 Return<void> DownmixEffect::getDescriptor(getDescriptor_cb _hidl_cb) {
117 return mEffect->getDescriptor(_hidl_cb);
118 }
119
prepareForProcessing(prepareForProcessing_cb _hidl_cb)120 Return<void> DownmixEffect::prepareForProcessing(prepareForProcessing_cb _hidl_cb) {
121 return mEffect->prepareForProcessing(_hidl_cb);
122 }
123
setProcessBuffers(const AudioBuffer & inBuffer,const AudioBuffer & outBuffer)124 Return<Result> DownmixEffect::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> DownmixEffect::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> DownmixEffect::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> DownmixEffect::getParameter(const hidl_vec<uint8_t>& parameter, uint32_t valueMaxSize,
140 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> DownmixEffect::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> DownmixEffect::getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize,
151 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> DownmixEffect::setCurrentConfigForFeature(uint32_t featureId,
156 const hidl_vec<uint8_t>& configData) {
157 return mEffect->setCurrentConfigForFeature(featureId, configData);
158 }
159
close()160 Return<Result> DownmixEffect::close() {
161 return mEffect->close();
162 }
163
debug(const hidl_handle & fd,const hidl_vec<hidl_string> & options)164 Return<void> DownmixEffect::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) {
165 return mEffect->debug(fd, options);
166 }
167
168 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect follow.
setType(IDownmixEffect::Type preset)169 Return<Result> DownmixEffect::setType(IDownmixEffect::Type preset) {
170 return mEffect->setParam(DOWNMIX_PARAM_TYPE, static_cast<downmix_type_t>(preset));
171 }
172
getType(getType_cb _hidl_cb)173 Return<void> DownmixEffect::getType(getType_cb _hidl_cb) {
174 downmix_type_t halPreset = DOWNMIX_TYPE_INVALID;
175 Result retval = mEffect->getParam(DOWNMIX_PARAM_TYPE, halPreset);
176 _hidl_cb(retval, Type(halPreset));
177 return Void();
178 }
179
180 } // namespace implementation
181 } // namespace CPP_VERSION
182 } // namespace effect
183 } // namespace audio
184 } // namespace hardware
185 } // namespace android
186