• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_EQUALIZEREFFECT_H
18 #define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H
19 
20 #include <vector>
21 
22 #include <system/audio_effects/effect_equalizer.h>
23 
24 #include <android/hardware/audio/effect/2.0/IEqualizerEffect.h>
25 #include <hidl/Status.h>
26 
27 #include <hidl/MQDescriptor.h>
28 
29 #include "Effect.h"
30 
31 namespace android {
32 namespace hardware {
33 namespace audio {
34 namespace effect {
35 namespace V2_0 {
36 namespace implementation {
37 
38 using ::android::hardware::audio::common::V2_0::AudioDevice;
39 using ::android::hardware::audio::common::V2_0::AudioMode;
40 using ::android::hardware::audio::common::V2_0::AudioSource;
41 using ::android::hardware::audio::effect::V2_0::AudioBuffer;
42 using ::android::hardware::audio::effect::V2_0::EffectAuxChannelsConfig;
43 using ::android::hardware::audio::effect::V2_0::EffectConfig;
44 using ::android::hardware::audio::effect::V2_0::EffectDescriptor;
45 using ::android::hardware::audio::effect::V2_0::EffectOffloadParameter;
46 using ::android::hardware::audio::effect::V2_0::IEffect;
47 using ::android::hardware::audio::effect::V2_0::IEffectBufferProviderCallback;
48 using ::android::hardware::audio::effect::V2_0::IEqualizerEffect;
49 using ::android::hardware::audio::effect::V2_0::Result;
50 using ::android::hardware::Return;
51 using ::android::hardware::Void;
52 using ::android::hardware::hidl_vec;
53 using ::android::hardware::hidl_string;
54 using ::android::sp;
55 
56 struct EqualizerEffect : public IEqualizerEffect {
57     explicit EqualizerEffect(effect_handle_t handle);
58 
59     // Methods from ::android::hardware::audio::effect::V2_0::IEffect follow.
60     Return<Result> init()  override;
61     Return<Result> setConfig(
62             const EffectConfig& config,
63             const sp<IEffectBufferProviderCallback>& inputBufferProvider,
64             const sp<IEffectBufferProviderCallback>& outputBufferProvider)  override;
65     Return<Result> reset()  override;
66     Return<Result> enable()  override;
67     Return<Result> disable()  override;
68     Return<Result> setDevice(AudioDevice device)  override;
69     Return<void> setAndGetVolume(
70             const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb)  override;
71     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes)  override;
72     Return<Result> setAudioMode(AudioMode mode)  override;
73     Return<Result> setConfigReverse(
74             const EffectConfig& config,
75             const sp<IEffectBufferProviderCallback>& inputBufferProvider,
76             const sp<IEffectBufferProviderCallback>& outputBufferProvider)  override;
77     Return<Result> setInputDevice(AudioDevice device)  override;
78     Return<void> getConfig(getConfig_cb _hidl_cb)  override;
79     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb)  override;
80     Return<void> getSupportedAuxChannelsConfigs(
81             uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb)  override;
82     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb)  override;
83     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config)  override;
84     Return<Result> setAudioSource(AudioSource source)  override;
85     Return<Result> offload(const EffectOffloadParameter& param)  override;
86     Return<void> getDescriptor(getDescriptor_cb _hidl_cb)  override;
87     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb)  override;
88     Return<Result> setProcessBuffers(
89             const AudioBuffer& inBuffer, const AudioBuffer& outBuffer)  override;
90     Return<void> command(
91             uint32_t commandId,
92             const hidl_vec<uint8_t>& data,
93             uint32_t resultMaxSize,
94             command_cb _hidl_cb)  override;
95     Return<Result> setParameter(
96             const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value)  override;
97     Return<void> getParameter(
98             const hidl_vec<uint8_t>& parameter,
99             uint32_t valueMaxSize,
100             getParameter_cb _hidl_cb)  override;
101     Return<void> getSupportedConfigsForFeature(
102             uint32_t featureId,
103             uint32_t maxConfigs,
104             uint32_t configSize,
105             getSupportedConfigsForFeature_cb _hidl_cb)  override;
106     Return<void> getCurrentConfigForFeature(
107             uint32_t featureId,
108             uint32_t configSize,
109             getCurrentConfigForFeature_cb _hidl_cb)  override;
110     Return<Result> setCurrentConfigForFeature(
111             uint32_t featureId, const hidl_vec<uint8_t>& configData)  override;
112     Return<Result> close()  override;
113 
114     // Methods from ::android::hardware::audio::effect::V2_0::IEqualizerEffect follow.
115     Return<void> getNumBands(getNumBands_cb _hidl_cb)  override;
116     Return<void> getLevelRange(getLevelRange_cb _hidl_cb)  override;
117     Return<Result> setBandLevel(uint16_t band, int16_t level)  override;
118     Return<void> getBandLevel(uint16_t band, getBandLevel_cb _hidl_cb)  override;
119     Return<void> getBandCenterFrequency(
120             uint16_t band, getBandCenterFrequency_cb _hidl_cb)  override;
121     Return<void> getBandFrequencyRange(uint16_t band, getBandFrequencyRange_cb _hidl_cb)  override;
122     Return<void> getBandForFrequency(uint32_t freq, getBandForFrequency_cb _hidl_cb)  override;
123     Return<void> getPresetNames(getPresetNames_cb _hidl_cb)  override;
124     Return<Result> setCurrentPreset(uint16_t preset)  override;
125     Return<void> getCurrentPreset(getCurrentPreset_cb _hidl_cb)  override;
126     Return<Result> setAllProperties(const IEqualizerEffect::AllProperties& properties)  override;
127     Return<void> getAllProperties(getAllProperties_cb _hidl_cb)  override;
128 
129   private:
130     sp<Effect> mEffect;
131 
132     virtual ~EqualizerEffect();
133 
134     void propertiesFromHal(
135             const t_equalizer_settings& halProperties,
136             IEqualizerEffect::AllProperties* properties);
137     std::vector<uint8_t> propertiesToHal(
138             const IEqualizerEffect::AllProperties& properties,
139             t_equalizer_settings** halProperties);
140 };
141 
142 }  // namespace implementation
143 }  // namespace V2_0
144 }  // namespace effect
145 }  // namespace audio
146 }  // namespace hardware
147 }  // namespace android
148 
149 #endif  // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H
150