Mikhail Naganov | 7cbf2f1 | 2016-10-27 20:05:35 -0700 | [diff] [blame] | 1 | /* |
| 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 "Downmix_HAL" |
| 18 | #include <system/audio_effects/effect_downmix.h> |
Yifan Hong | f9d3034 | 2016-11-30 13:45:34 -0800 | [diff] [blame] | 19 | #include <android/log.h> |
Mikhail Naganov | 7cbf2f1 | 2016-10-27 20:05:35 -0700 | [diff] [blame] | 20 | |
| 21 | #include "DownmixEffect.h" |
| 22 | |
| 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace audio { |
| 26 | namespace effect { |
| 27 | namespace V2_0 { |
| 28 | namespace implementation { |
| 29 | |
| 30 | DownmixEffect::DownmixEffect(effect_handle_t handle) |
| 31 | : mEffect(new Effect(handle)) { |
| 32 | } |
| 33 | |
| 34 | DownmixEffect::~DownmixEffect() {} |
| 35 | |
| 36 | // Methods from ::android::hardware::audio::effect::V2_0::IEffect follow. |
| 37 | Return<Result> DownmixEffect::init() { |
| 38 | return mEffect->init(); |
| 39 | } |
| 40 | |
| 41 | Return<Result> DownmixEffect::setConfig( |
| 42 | const EffectConfig& config, |
| 43 | const sp<IEffectBufferProviderCallback>& inputBufferProvider, |
| 44 | const sp<IEffectBufferProviderCallback>& outputBufferProvider) { |
| 45 | return mEffect->setConfig(config, inputBufferProvider, outputBufferProvider); |
| 46 | } |
| 47 | |
| 48 | Return<Result> DownmixEffect::reset() { |
| 49 | return mEffect->reset(); |
| 50 | } |
| 51 | |
| 52 | Return<Result> DownmixEffect::enable() { |
| 53 | return mEffect->enable(); |
| 54 | } |
| 55 | |
| 56 | Return<Result> DownmixEffect::disable() { |
| 57 | return mEffect->disable(); |
| 58 | } |
| 59 | |
| 60 | Return<Result> DownmixEffect::setDevice(AudioDevice device) { |
| 61 | return mEffect->setDevice(device); |
| 62 | } |
| 63 | |
| 64 | Return<void> DownmixEffect::setAndGetVolume( |
| 65 | const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb) { |
| 66 | return mEffect->setAndGetVolume(volumes, _hidl_cb); |
| 67 | } |
| 68 | |
| 69 | Return<Result> DownmixEffect::setAudioMode(AudioMode mode) { |
| 70 | return mEffect->setAudioMode(mode); |
| 71 | } |
| 72 | |
| 73 | Return<Result> DownmixEffect::setConfigReverse( |
| 74 | const EffectConfig& config, |
| 75 | const sp<IEffectBufferProviderCallback>& inputBufferProvider, |
| 76 | const sp<IEffectBufferProviderCallback>& outputBufferProvider) { |
| 77 | return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider); |
| 78 | } |
| 79 | |
| 80 | Return<Result> DownmixEffect::setInputDevice(AudioDevice device) { |
| 81 | return mEffect->setInputDevice(device); |
| 82 | } |
| 83 | |
| 84 | Return<void> DownmixEffect::getConfig(getConfig_cb _hidl_cb) { |
| 85 | return mEffect->getConfig(_hidl_cb); |
| 86 | } |
| 87 | |
| 88 | Return<void> DownmixEffect::getConfigReverse(getConfigReverse_cb _hidl_cb) { |
| 89 | return mEffect->getConfigReverse(_hidl_cb); |
| 90 | } |
| 91 | |
| 92 | Return<void> DownmixEffect::getSupportedAuxChannelsConfigs( |
| 93 | uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) { |
| 94 | return mEffect->getSupportedAuxChannelsConfigs(maxConfigs, _hidl_cb); |
| 95 | } |
| 96 | |
| 97 | Return<void> DownmixEffect::getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) { |
| 98 | return mEffect->getAuxChannelsConfig(_hidl_cb); |
| 99 | } |
| 100 | |
| 101 | Return<Result> DownmixEffect::setAuxChannelsConfig( |
| 102 | const EffectAuxChannelsConfig& config) { |
| 103 | return mEffect->setAuxChannelsConfig(config); |
| 104 | } |
| 105 | |
| 106 | Return<Result> DownmixEffect::setAudioSource(AudioSource source) { |
| 107 | return mEffect->setAudioSource(source); |
| 108 | } |
| 109 | |
| 110 | Return<Result> DownmixEffect::offload(const EffectOffloadParameter& param) { |
| 111 | return mEffect->offload(param); |
| 112 | } |
| 113 | |
| 114 | Return<void> DownmixEffect::getDescriptor(getDescriptor_cb _hidl_cb) { |
| 115 | return mEffect->getDescriptor(_hidl_cb); |
| 116 | } |
| 117 | |
| 118 | Return<void> DownmixEffect::process( |
| 119 | const AudioBuffer& inBuffer, uint32_t outFrameSize, process_cb _hidl_cb) { |
| 120 | return mEffect->process(inBuffer, outFrameSize, _hidl_cb); |
| 121 | } |
| 122 | |
| 123 | Return<void> DownmixEffect::processReverse( |
| 124 | const AudioBuffer& inBuffer, |
| 125 | uint32_t outFrameSize, |
| 126 | processReverse_cb _hidl_cb) { |
| 127 | return mEffect->processReverse(inBuffer, outFrameSize, _hidl_cb); |
| 128 | } |
| 129 | |
| 130 | Return<void> DownmixEffect::command( |
| 131 | uint32_t commandId, |
| 132 | const hidl_vec<uint8_t>& data, |
| 133 | uint32_t resultMaxSize, |
| 134 | command_cb _hidl_cb) { |
| 135 | return mEffect->command(commandId, data, resultMaxSize, _hidl_cb); |
| 136 | } |
| 137 | |
| 138 | Return<Result> DownmixEffect::setParameter( |
| 139 | const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value) { |
| 140 | return mEffect->setParameter(parameter, value); |
| 141 | } |
| 142 | |
| 143 | Return<void> DownmixEffect::getParameter( |
| 144 | const hidl_vec<uint8_t>& parameter, |
| 145 | uint32_t valueMaxSize, |
| 146 | getParameter_cb _hidl_cb) { |
| 147 | return mEffect->getParameter(parameter, valueMaxSize, _hidl_cb); |
| 148 | } |
| 149 | |
| 150 | Return<void> DownmixEffect::getSupportedConfigsForFeature( |
| 151 | uint32_t featureId, |
| 152 | uint32_t maxConfigs, |
| 153 | uint32_t configSize, |
| 154 | getSupportedConfigsForFeature_cb _hidl_cb) { |
| 155 | return mEffect->getSupportedConfigsForFeature(featureId, maxConfigs, configSize, _hidl_cb); |
| 156 | } |
| 157 | |
| 158 | Return<void> DownmixEffect::getCurrentConfigForFeature( |
| 159 | uint32_t featureId, |
| 160 | uint32_t configSize, |
| 161 | getCurrentConfigForFeature_cb _hidl_cb) { |
| 162 | return mEffect->getCurrentConfigForFeature(featureId, configSize, _hidl_cb); |
| 163 | } |
| 164 | |
| 165 | Return<Result> DownmixEffect::setCurrentConfigForFeature( |
| 166 | uint32_t featureId, const hidl_vec<uint8_t>& configData) { |
| 167 | return mEffect->setCurrentConfigForFeature(featureId, configData); |
| 168 | } |
| 169 | |
| 170 | // Methods from ::android::hardware::audio::effect::V2_0::IDownmixEffect follow. |
| 171 | Return<Result> DownmixEffect::setType(IDownmixEffect::Type preset) { |
| 172 | return mEffect->setParam(DOWNMIX_PARAM_TYPE, static_cast<downmix_type_t>(preset)); |
| 173 | } |
| 174 | |
| 175 | Return<void> DownmixEffect::getType(getType_cb _hidl_cb) { |
| 176 | downmix_type_t halPreset = DOWNMIX_TYPE_INVALID; |
| 177 | Result retval = mEffect->getParam(DOWNMIX_PARAM_TYPE, halPreset); |
| 178 | _hidl_cb(retval, Type(halPreset)); |
| 179 | return Void(); |
| 180 | } |
| 181 | |
| 182 | } // namespace implementation |
| 183 | } // namespace V2_0 |
| 184 | } // namespace effect |
| 185 | } // namespace audio |
| 186 | } // namespace hardware |
| 187 | } // namespace android |