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 #ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
     18 #define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
     19 
     20 #include <system/audio_effects/effect_agc.h>
     21 
     22 #include <android/hardware/audio/effect/2.0/IAutomaticGainControlEffect.h>
     23 #include <hidl/Status.h>
     24 
     25 #include <hidl/MQDescriptor.h>
     26 
     27 #include "Effect.h"
     28 
     29 namespace android {
     30 namespace hardware {
     31 namespace audio {
     32 namespace effect {
     33 namespace V2_0 {
     34 namespace implementation {
     35 
     36 using ::android::hardware::audio::effect::V2_0::IAutomaticGainControlEffect;
     37 using ::android::hardware::audio::effect::V2_0::Result;
     38 using ::android::hardware::Return;
     39 using ::android::hardware::Void;
     40 using ::android::hardware::hidl_vec;
     41 using ::android::hardware::hidl_string;
     42 using ::android::sp;
     43 
     44 struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
     45     explicit AutomaticGainControlEffect(effect_handle_t handle);
     46 
     47     // Methods from ::android::hardware::audio::effect::V2_0::IEffect follow.
     48     Return<Result> init()  override;
     49     Return<Result> setConfig(
     50             const EffectConfig& config,
     51             const sp<IEffectBufferProviderCallback>& inputBufferProvider,
     52             const sp<IEffectBufferProviderCallback>& outputBufferProvider)  override;
     53     Return<Result> reset()  override;
     54     Return<Result> enable()  override;
     55     Return<Result> disable()  override;
     56     Return<Result> setDevice(AudioDevice device)  override;
     57     Return<void> setAndGetVolume(
     58             const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb)  override;
     59     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes)  override;
     60     Return<Result> setAudioMode(AudioMode mode)  override;
     61     Return<Result> setConfigReverse(
     62             const EffectConfig& config,
     63             const sp<IEffectBufferProviderCallback>& inputBufferProvider,
     64             const sp<IEffectBufferProviderCallback>& outputBufferProvider)  override;
     65     Return<Result> setInputDevice(AudioDevice device)  override;
     66     Return<void> getConfig(getConfig_cb _hidl_cb)  override;
     67     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb)  override;
     68     Return<void> getSupportedAuxChannelsConfigs(
     69             uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb)  override;
     70     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb)  override;
     71     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config)  override;
     72     Return<Result> setAudioSource(AudioSource source)  override;
     73     Return<Result> offload(const EffectOffloadParameter& param)  override;
     74     Return<void> getDescriptor(getDescriptor_cb _hidl_cb)  override;
     75     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb)  override;
     76     Return<Result> setProcessBuffers(
     77             const AudioBuffer& inBuffer, const AudioBuffer& outBuffer)  override;
     78     Return<void> command(
     79             uint32_t commandId,
     80             const hidl_vec<uint8_t>& data,
     81             uint32_t resultMaxSize,
     82             command_cb _hidl_cb)  override;
     83     Return<Result> setParameter(
     84             const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value)  override;
     85     Return<void> getParameter(
     86             const hidl_vec<uint8_t>& parameter,
     87             uint32_t valueMaxSize,
     88             getParameter_cb _hidl_cb)  override;
     89     Return<void> getSupportedConfigsForFeature(
     90             uint32_t featureId,
     91             uint32_t maxConfigs,
     92             uint32_t configSize,
     93             getSupportedConfigsForFeature_cb _hidl_cb)  override;
     94     Return<void> getCurrentConfigForFeature(
     95             uint32_t featureId,
     96             uint32_t configSize,
     97             getCurrentConfigForFeature_cb _hidl_cb)  override;
     98     Return<Result> setCurrentConfigForFeature(
     99             uint32_t featureId, const hidl_vec<uint8_t>& configData)  override;
    100     Return<Result> close()  override;
    101 
    102     // Methods from ::android::hardware::audio::effect::V2_0::IAutomaticGainControlEffect follow.
    103     Return<Result> setTargetLevel(int16_t targetLevelMb)  override;
    104     Return<void> getTargetLevel(getTargetLevel_cb _hidl_cb)  override;
    105     Return<Result> setCompGain(int16_t compGainMb)  override;
    106     Return<void> getCompGain(getCompGain_cb _hidl_cb)  override;
    107     Return<Result> setLimiterEnabled(bool enabled)  override;
    108     Return<void> isLimiterEnabled(isLimiterEnabled_cb _hidl_cb)  override;
    109     Return<Result> setAllProperties(
    110             const IAutomaticGainControlEffect::AllProperties& properties)  override;
    111     Return<void> getAllProperties(getAllProperties_cb _hidl_cb)  override;
    112 
    113   private:
    114     sp<Effect> mEffect;
    115 
    116     virtual ~AutomaticGainControlEffect();
    117 
    118     void propertiesFromHal(
    119             const t_agc_settings& halProperties,
    120             IAutomaticGainControlEffect::AllProperties* properties);
    121     void propertiesToHal(
    122             const IAutomaticGainControlEffect::AllProperties& properties,
    123             t_agc_settings* halProperties);
    124 };
    125 
    126 }  // namespace implementation
    127 }  // namespace V2_0
    128 }  // namespace effect
    129 }  // namespace audio
    130 }  // namespace hardware
    131 }  // namespace android
    132 
    133 #endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
    134