blob: 73d94a5a44b5605243b61426591408c2bb51198b [file] [log] [blame]
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07001/*
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
Steven Morelandd6e4f032016-11-28 18:37:07 -080017#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
18#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070019
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
29namespace android {
30namespace hardware {
31namespace audio {
32namespace effect {
33namespace V2_0 {
34namespace implementation {
35
36using ::android::hardware::audio::effect::V2_0::IAutomaticGainControlEffect;
37using ::android::hardware::audio::effect::V2_0::Result;
38using ::android::hardware::Return;
39using ::android::hardware::Void;
40using ::android::hardware::hidl_vec;
41using ::android::hardware::hidl_string;
42using ::android::sp;
43
44struct 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> setAudioMode(AudioMode mode) override;
60 Return<Result> setConfigReverse(
61 const EffectConfig& config,
62 const sp<IEffectBufferProviderCallback>& inputBufferProvider,
63 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
64 Return<Result> setInputDevice(AudioDevice device) override;
65 Return<void> getConfig(getConfig_cb _hidl_cb) override;
66 Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
67 Return<void> getSupportedAuxChannelsConfigs(
68 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
69 Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
70 Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
71 Return<Result> setAudioSource(AudioSource source) override;
72 Return<Result> offload(const EffectOffloadParameter& param) override;
73 Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Mikhail Naganova331de12017-01-04 16:33:55 -080074 Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
75 Return<Result> setProcessBuffers(
76 const AudioBuffer& inBuffer, const AudioBuffer& outBuffer) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070077 Return<void> command(
78 uint32_t commandId,
79 const hidl_vec<uint8_t>& data,
80 uint32_t resultMaxSize,
81 command_cb _hidl_cb) override;
82 Return<Result> setParameter(
83 const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value) override;
84 Return<void> getParameter(
85 const hidl_vec<uint8_t>& parameter,
86 uint32_t valueMaxSize,
87 getParameter_cb _hidl_cb) override;
88 Return<void> getSupportedConfigsForFeature(
89 uint32_t featureId,
90 uint32_t maxConfigs,
91 uint32_t configSize,
92 getSupportedConfigsForFeature_cb _hidl_cb) override;
93 Return<void> getCurrentConfigForFeature(
94 uint32_t featureId,
95 uint32_t configSize,
96 getCurrentConfigForFeature_cb _hidl_cb) override;
97 Return<Result> setCurrentConfigForFeature(
98 uint32_t featureId, const hidl_vec<uint8_t>& configData) override;
Mikhail Naganova331de12017-01-04 16:33:55 -080099 Return<Result> close() override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700100
101 // Methods from ::android::hardware::audio::effect::V2_0::IAutomaticGainControlEffect follow.
102 Return<Result> setTargetLevel(int16_t targetLevelMb) override;
103 Return<void> getTargetLevel(getTargetLevel_cb _hidl_cb) override;
104 Return<Result> setCompGain(int16_t compGainMb) override;
105 Return<void> getCompGain(getCompGain_cb _hidl_cb) override;
106 Return<Result> setLimiterEnabled(bool enabled) override;
107 Return<void> isLimiterEnabled(isLimiterEnabled_cb _hidl_cb) override;
108 Return<Result> setAllProperties(
109 const IAutomaticGainControlEffect::AllProperties& properties) override;
110 Return<void> getAllProperties(getAllProperties_cb _hidl_cb) override;
111
112 private:
113 sp<Effect> mEffect;
114
115 virtual ~AutomaticGainControlEffect();
116
117 void propertiesFromHal(
118 const t_agc_settings& halProperties,
119 IAutomaticGainControlEffect::AllProperties* properties);
120 void propertiesToHal(
121 const IAutomaticGainControlEffect::AllProperties& properties,
122 t_agc_settings* halProperties);
123};
124
125} // namespace implementation
126} // namespace V2_0
127} // namespace effect
128} // namespace audio
129} // namespace hardware
130} // namespace android
131
Steven Morelandd6e4f032016-11-28 18:37:07 -0800132#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H