blob: 5536e148dd97cc4c8eeb9797b151d4be1e469e1d [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.
Kevin Rocard22505e62017-12-14 18:50:12 -080048 Return<Result> init() override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070049 Return<Result> setConfig(
Kevin Rocard22505e62017-12-14 18:50:12 -080050 const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
51 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
52 Return<Result> reset() override;
53 Return<Result> enable() override;
54 Return<Result> disable() override;
55 Return<Result> setDevice(AudioDevice device) override;
56 Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
57 setAndGetVolume_cb _hidl_cb) override;
58 Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
59 Return<Result> setAudioMode(AudioMode mode) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070060 Return<Result> setConfigReverse(
Kevin Rocard22505e62017-12-14 18:50:12 -080061 const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
62 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
63 Return<Result> setInputDevice(AudioDevice device) override;
64 Return<void> getConfig(getConfig_cb _hidl_cb) override;
65 Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070066 Return<void> getSupportedAuxChannelsConfigs(
Kevin Rocard22505e62017-12-14 18:50:12 -080067 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
68 Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
69 Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
70 Return<Result> setAudioSource(AudioSource source) override;
71 Return<Result> offload(const EffectOffloadParameter& param) override;
72 Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
73 Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
74 Return<Result> setProcessBuffers(const AudioBuffer& inBuffer,
75 const AudioBuffer& outBuffer) override;
76 Return<void> command(uint32_t commandId, const hidl_vec<uint8_t>& data, uint32_t resultMaxSize,
77 command_cb _hidl_cb) override;
78 Return<Result> setParameter(const hidl_vec<uint8_t>& parameter,
79 const hidl_vec<uint8_t>& value) override;
80 Return<void> getParameter(const hidl_vec<uint8_t>& parameter, uint32_t valueMaxSize,
81 getParameter_cb _hidl_cb) override;
82 Return<void> getSupportedConfigsForFeature(uint32_t featureId, uint32_t maxConfigs,
83 uint32_t configSize,
84 getSupportedConfigsForFeature_cb _hidl_cb) override;
85 Return<void> getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize,
86 getCurrentConfigForFeature_cb _hidl_cb) override;
87 Return<Result> setCurrentConfigForFeature(uint32_t featureId,
88 const hidl_vec<uint8_t>& configData) override;
89 Return<Result> close() override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070090
91 // Methods from ::android::hardware::audio::effect::V2_0::IAutomaticGainControlEffect follow.
Kevin Rocard22505e62017-12-14 18:50:12 -080092 Return<Result> setTargetLevel(int16_t targetLevelMb) override;
93 Return<void> getTargetLevel(getTargetLevel_cb _hidl_cb) override;
94 Return<Result> setCompGain(int16_t compGainMb) override;
95 Return<void> getCompGain(getCompGain_cb _hidl_cb) override;
96 Return<Result> setLimiterEnabled(bool enabled) override;
97 Return<void> isLimiterEnabled(isLimiterEnabled_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070098 Return<Result> setAllProperties(
Kevin Rocard22505e62017-12-14 18:50:12 -080099 const IAutomaticGainControlEffect::AllProperties& properties) override;
100 Return<void> getAllProperties(getAllProperties_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700101
Kevin Rocard22505e62017-12-14 18:50:12 -0800102 private:
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700103 sp<Effect> mEffect;
104
105 virtual ~AutomaticGainControlEffect();
106
Kevin Rocard22505e62017-12-14 18:50:12 -0800107 void propertiesFromHal(const t_agc_settings& halProperties,
108 IAutomaticGainControlEffect::AllProperties* properties);
109 void propertiesToHal(const IAutomaticGainControlEffect::AllProperties& properties,
110 t_agc_settings* halProperties);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700111};
112
113} // namespace implementation
114} // namespace V2_0
115} // namespace effect
116} // namespace audio
117} // namespace hardware
118} // namespace android
119
Steven Morelandd6e4f032016-11-28 18:37:07 -0800120#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H