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