blob: 9694b5d8c14a80eee244fa1e2bdcc75e1b4daf87 [file] [log] [blame]
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07001/*
Kevin Rocard96d2cd92018-11-14 16:22:07 -08002 * Copyright (C) 2018 The Android Open Source Project
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -07003 *
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
Kevin Rocard96d2cd92018-11-14 16:22:07 -080017#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H
18#define ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H
19
20#include <system/audio_effects/effect_environmentalreverb.h>
21
22#include PATH(android/hardware/audio/effect/FILE_VERSION/IEnvironmentalReverbEffect.h)
23
24#include "Effect.h"
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070025
26#include <system/audio_effects/effect_environmentalreverb.h>
27
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070028#include <hidl/Status.h>
29
30#include <hidl/MQDescriptor.h>
31
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080032#include "VersionUtils.h"
33
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070034namespace android {
35namespace hardware {
36namespace audio {
37namespace effect {
Kevin Rocard96d2cd92018-11-14 16:22:07 -080038namespace CPP_VERSION {
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070039namespace implementation {
40
Kevin Rocard55b10612018-11-12 12:33:16 -080041using ::android::sp;
42using ::android::hardware::hidl_string;
43using ::android::hardware::hidl_vec;
44using ::android::hardware::Return;
45using ::android::hardware::Void;
Mikhail Naganov3907f762018-12-13 09:42:17 -080046using namespace ::android::hardware::audio::common::CPP_VERSION;
47using namespace ::android::hardware::audio::effect::CPP_VERSION;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070048
49struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
50 explicit EnvironmentalReverbEffect(effect_handle_t handle);
51
Kevin Rocard96d2cd92018-11-14 16:22:07 -080052 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Kevin Rocard22505e62017-12-14 18:50:12 -080053 Return<Result> init() override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070054 Return<Result> setConfig(
Kevin Rocard22505e62017-12-14 18:50:12 -080055 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;
Mikhail Naganovf363ed42020-12-10 18:47:51 -080060#if MAJOR_VERSION <= 6
61 Return<Result> setAudioSource(AudioSource source) override;
Kevin Rocard30a7fcc2018-03-01 15:08:07 -080062 Return<Result> setDevice(AudioDeviceBitfield device) override;
Mikhail Naganovf363ed42020-12-10 18:47:51 -080063 Return<Result> setInputDevice(AudioDeviceBitfield device) override;
64#else
65 Return<Result> setAudioSource(const AudioSource& source) override;
66 Return<Result> setDevice(const DeviceAddress& device) override;
67 Return<Result> setInputDevice(const DeviceAddress& device) override;
68#endif
Kevin Rocard22505e62017-12-14 18:50:12 -080069 Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
70 setAndGetVolume_cb _hidl_cb) override;
71 Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
72 Return<Result> setAudioMode(AudioMode mode) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070073 Return<Result> setConfigReverse(
Kevin Rocard22505e62017-12-14 18:50:12 -080074 const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
75 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Kevin Rocard22505e62017-12-14 18:50:12 -080076 Return<void> getConfig(getConfig_cb _hidl_cb) override;
77 Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070078 Return<void> getSupportedAuxChannelsConfigs(
Kevin Rocard22505e62017-12-14 18:50:12 -080079 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
80 Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
81 Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Kevin Rocard22505e62017-12-14 18:50:12 -080082 Return<Result> offload(const EffectOffloadParameter& param) override;
83 Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
84 Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
85 Return<Result> setProcessBuffers(const AudioBuffer& inBuffer,
86 const AudioBuffer& outBuffer) override;
87 Return<void> command(uint32_t commandId, const hidl_vec<uint8_t>& data, uint32_t resultMaxSize,
88 command_cb _hidl_cb) override;
89 Return<Result> setParameter(const hidl_vec<uint8_t>& parameter,
90 const hidl_vec<uint8_t>& value) override;
91 Return<void> getParameter(const hidl_vec<uint8_t>& parameter, uint32_t valueMaxSize,
92 getParameter_cb _hidl_cb) override;
93 Return<void> getSupportedConfigsForFeature(uint32_t featureId, uint32_t maxConfigs,
94 uint32_t configSize,
95 getSupportedConfigsForFeature_cb _hidl_cb) override;
96 Return<void> getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize,
97 getCurrentConfigForFeature_cb _hidl_cb) override;
98 Return<Result> setCurrentConfigForFeature(uint32_t featureId,
99 const hidl_vec<uint8_t>& configData) override;
100 Return<Result> close() override;
Mikhail Naganovfa021442019-02-22 14:28:26 -0800101 Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700102
Kevin Rocard62588b62017-12-20 11:07:12 -0800103 // Methods from
Kevin Rocard96d2cd92018-11-14 16:22:07 -0800104 // ::android::hardware::audio::effect::CPP_VERSION::IEnvironmentalReverbEffect follow.
Kevin Rocard22505e62017-12-14 18:50:12 -0800105 Return<Result> setBypass(bool bypass) override;
106 Return<void> getBypass(getBypass_cb _hidl_cb) override;
107 Return<Result> setRoomLevel(int16_t roomLevel) override;
108 Return<void> getRoomLevel(getRoomLevel_cb _hidl_cb) override;
109 Return<Result> setRoomHfLevel(int16_t roomHfLevel) override;
110 Return<void> getRoomHfLevel(getRoomHfLevel_cb _hidl_cb) override;
111 Return<Result> setDecayTime(uint32_t decayTime) override;
112 Return<void> getDecayTime(getDecayTime_cb _hidl_cb) override;
113 Return<Result> setDecayHfRatio(int16_t decayHfRatio) override;
114 Return<void> getDecayHfRatio(getDecayHfRatio_cb _hidl_cb) override;
115 Return<Result> setReflectionsLevel(int16_t reflectionsLevel) override;
116 Return<void> getReflectionsLevel(getReflectionsLevel_cb _hidl_cb) override;
117 Return<Result> setReflectionsDelay(uint32_t reflectionsDelay) override;
118 Return<void> getReflectionsDelay(getReflectionsDelay_cb _hidl_cb) override;
119 Return<Result> setReverbLevel(int16_t reverbLevel) override;
120 Return<void> getReverbLevel(getReverbLevel_cb _hidl_cb) override;
121 Return<Result> setReverbDelay(uint32_t reverbDelay) override;
122 Return<void> getReverbDelay(getReverbDelay_cb _hidl_cb) override;
123 Return<Result> setDiffusion(int16_t diffusion) override;
124 Return<void> getDiffusion(getDiffusion_cb _hidl_cb) override;
125 Return<Result> setDensity(int16_t density) override;
126 Return<void> getDensity(getDensity_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700127 Return<Result> setAllProperties(
Kevin Rocard22505e62017-12-14 18:50:12 -0800128 const IEnvironmentalReverbEffect::AllProperties& properties) override;
129 Return<void> getAllProperties(getAllProperties_cb _hidl_cb) override;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700130
Kevin Rocard22505e62017-12-14 18:50:12 -0800131 private:
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700132 sp<Effect> mEffect;
133
Mikhail Naganovf363ed42020-12-10 18:47:51 -0800134 virtual ~EnvironmentalReverbEffect() = default;
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700135
Kevin Rocard22505e62017-12-14 18:50:12 -0800136 void propertiesFromHal(const t_reverb_settings& halProperties,
137 IEnvironmentalReverbEffect::AllProperties* properties);
138 void propertiesToHal(const IEnvironmentalReverbEffect::AllProperties& properties,
139 t_reverb_settings* halProperties);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700140};
141
142} // namespace implementation
Kevin Rocard96d2cd92018-11-14 16:22:07 -0800143} // namespace CPP_VERSION
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700144} // namespace effect
145} // namespace audio
146} // namespace hardware
147} // namespace android
Kevin Rocard96d2cd92018-11-14 16:22:07 -0800148
149#endif // ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H