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