blob: c001a5f4dc5ef26a6933fda2ae82ed7e46a867d3 [file] [log] [blame]
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07001/*
Kevin Rocard96d2cd92018-11-14 16:22:07 -08002 * Copyright (C) 2018 The Android Open Source Project
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07003 *
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
Kevin Rocard96d2cd92018-11-14 16:22:07 -080017#define LOG_TAG "Downmix_HAL"
18
19#include "DownmixEffect.h"
Kevin Rocard62588b62017-12-20 11:07:12 -080020
Yifan Hongf9d30342016-11-30 13:45:34 -080021#include <android/log.h>
Kevin Rocard22505e62017-12-14 18:50:12 -080022#include <system/audio_effects/effect_downmix.h>
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070023
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080024#include "VersionUtils.h"
25
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070026namespace android {
27namespace hardware {
28namespace audio {
29namespace effect {
Kevin Rocard96d2cd92018-11-14 16:22:07 -080030namespace CPP_VERSION {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070031namespace implementation {
32
Kevin Rocard22505e62017-12-14 18:50:12 -080033DownmixEffect::DownmixEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070034
35DownmixEffect::~DownmixEffect() {}
36
Kevin Rocard96d2cd92018-11-14 16:22:07 -080037// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070038Return<Result> DownmixEffect::init() {
39 return mEffect->init();
40}
41
42Return<Result> DownmixEffect::setConfig(
Kevin Rocard22505e62017-12-14 18:50:12 -080043 const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
44 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070045 return mEffect->setConfig(config, inputBufferProvider, outputBufferProvider);
46}
47
48Return<Result> DownmixEffect::reset() {
49 return mEffect->reset();
50}
51
52Return<Result> DownmixEffect::enable() {
53 return mEffect->enable();
54}
55
56Return<Result> DownmixEffect::disable() {
57 return mEffect->disable();
58}
59
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080060Return<Result> DownmixEffect::setDevice(AudioDeviceBitfield device) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070061 return mEffect->setDevice(device);
62}
63
Kevin Rocard22505e62017-12-14 18:50:12 -080064Return<void> DownmixEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
65 setAndGetVolume_cb _hidl_cb) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070066 return mEffect->setAndGetVolume(volumes, _hidl_cb);
67}
68
Kevin Rocard22505e62017-12-14 18:50:12 -080069Return<Result> DownmixEffect::volumeChangeNotification(const hidl_vec<uint32_t>& volumes) {
Mikhail Naganovf4f2ff32017-01-19 12:38:39 -080070 return mEffect->volumeChangeNotification(volumes);
71}
72
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070073Return<Result> DownmixEffect::setAudioMode(AudioMode mode) {
74 return mEffect->setAudioMode(mode);
75}
76
77Return<Result> DownmixEffect::setConfigReverse(
Kevin Rocard22505e62017-12-14 18:50:12 -080078 const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
79 const sp<IEffectBufferProviderCallback>& outputBufferProvider) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070080 return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
81}
82
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080083Return<Result> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070084 return mEffect->setInputDevice(device);
85}
86
87Return<void> DownmixEffect::getConfig(getConfig_cb _hidl_cb) {
88 return mEffect->getConfig(_hidl_cb);
89}
90
91Return<void> DownmixEffect::getConfigReverse(getConfigReverse_cb _hidl_cb) {
92 return mEffect->getConfigReverse(_hidl_cb);
93}
94
95Return<void> DownmixEffect::getSupportedAuxChannelsConfigs(
Kevin Rocard22505e62017-12-14 18:50:12 -080096 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070097 return mEffect->getSupportedAuxChannelsConfigs(maxConfigs, _hidl_cb);
98}
99
100Return<void> DownmixEffect::getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) {
101 return mEffect->getAuxChannelsConfig(_hidl_cb);
102}
103
Kevin Rocard22505e62017-12-14 18:50:12 -0800104Return<Result> DownmixEffect::setAuxChannelsConfig(const EffectAuxChannelsConfig& config) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700105 return mEffect->setAuxChannelsConfig(config);
106}
107
108Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
109 return mEffect->setAudioSource(source);
110}
111
112Return<Result> DownmixEffect::offload(const EffectOffloadParameter& param) {
113 return mEffect->offload(param);
114}
115
116Return<void> DownmixEffect::getDescriptor(getDescriptor_cb _hidl_cb) {
117 return mEffect->getDescriptor(_hidl_cb);
118}
119
Kevin Rocard22505e62017-12-14 18:50:12 -0800120Return<void> DownmixEffect::prepareForProcessing(prepareForProcessing_cb _hidl_cb) {
Mikhail Naganova331de12017-01-04 16:33:55 -0800121 return mEffect->prepareForProcessing(_hidl_cb);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700122}
123
Kevin Rocard22505e62017-12-14 18:50:12 -0800124Return<Result> DownmixEffect::setProcessBuffers(const AudioBuffer& inBuffer,
125 const AudioBuffer& outBuffer) {
Mikhail Naganova331de12017-01-04 16:33:55 -0800126 return mEffect->setProcessBuffers(inBuffer, outBuffer);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700127}
128
Kevin Rocard22505e62017-12-14 18:50:12 -0800129Return<void> DownmixEffect::command(uint32_t commandId, const hidl_vec<uint8_t>& data,
130 uint32_t resultMaxSize, command_cb _hidl_cb) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700131 return mEffect->command(commandId, data, resultMaxSize, _hidl_cb);
132}
133
Kevin Rocard22505e62017-12-14 18:50:12 -0800134Return<Result> DownmixEffect::setParameter(const hidl_vec<uint8_t>& parameter,
135 const hidl_vec<uint8_t>& value) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700136 return mEffect->setParameter(parameter, value);
137}
138
Kevin Rocard22505e62017-12-14 18:50:12 -0800139Return<void> DownmixEffect::getParameter(const hidl_vec<uint8_t>& parameter, uint32_t valueMaxSize,
140 getParameter_cb _hidl_cb) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700141 return mEffect->getParameter(parameter, valueMaxSize, _hidl_cb);
142}
143
144Return<void> DownmixEffect::getSupportedConfigsForFeature(
Kevin Rocard22505e62017-12-14 18:50:12 -0800145 uint32_t featureId, uint32_t maxConfigs, uint32_t configSize,
146 getSupportedConfigsForFeature_cb _hidl_cb) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700147 return mEffect->getSupportedConfigsForFeature(featureId, maxConfigs, configSize, _hidl_cb);
148}
149
Kevin Rocard22505e62017-12-14 18:50:12 -0800150Return<void> DownmixEffect::getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize,
151 getCurrentConfigForFeature_cb _hidl_cb) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700152 return mEffect->getCurrentConfigForFeature(featureId, configSize, _hidl_cb);
153}
154
Kevin Rocard22505e62017-12-14 18:50:12 -0800155Return<Result> DownmixEffect::setCurrentConfigForFeature(uint32_t featureId,
156 const hidl_vec<uint8_t>& configData) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700157 return mEffect->setCurrentConfigForFeature(featureId, configData);
158}
159
Mikhail Naganova331de12017-01-04 16:33:55 -0800160Return<Result> DownmixEffect::close() {
161 return mEffect->close();
162}
163
Mikhail Naganovfa021442019-02-22 14:28:26 -0800164Return<void> DownmixEffect::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) {
165 return mEffect->debug(fd, options);
166}
167
Kevin Rocard96d2cd92018-11-14 16:22:07 -0800168// Methods from ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect follow.
Kevin Rocard22505e62017-12-14 18:50:12 -0800169Return<Result> DownmixEffect::setType(IDownmixEffect::Type preset) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700170 return mEffect->setParam(DOWNMIX_PARAM_TYPE, static_cast<downmix_type_t>(preset));
171}
172
Kevin Rocard22505e62017-12-14 18:50:12 -0800173Return<void> DownmixEffect::getType(getType_cb _hidl_cb) {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700174 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
Kevin Rocard22505e62017-12-14 18:50:12 -0800180} // namespace implementation
Kevin Rocard96d2cd92018-11-14 16:22:07 -0800181} // namespace CPP_VERSION
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700182} // namespace effect
183} // namespace audio
184} // namespace hardware
185} // namespace android