• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 #define LOG_TAG "EffectsFactory7.0"
18 #include <log/log.h>
19 
20 #include <android_audio_policy_configuration_V7_0-enums.h>
21 
22 #include "Effect.h"
23 
24 using ::android::hardware::hidl_string;
25 using ::android::hardware::hidl_vec;
26 using ::android::hardware::Return;
27 using ::android::hardware::Void;
28 using namespace ::android::hardware::audio::common::V7_0;
29 // Make an alias for enumerations generated from the APM config XSD.
30 namespace xsd {
31 using namespace ::android::audio::policy::configuration::V7_0;
32 }
33 
34 namespace android::hardware::audio::effect::V7_0::implementation {
35 
init()36 Return<Result> Effect::init() {
37     return Result::OK;
38 }
39 
setConfig(const EffectConfig & config,const::android::sp<IEffectBufferProviderCallback> & inputBufferProvider,const::android::sp<IEffectBufferProviderCallback> & outputBufferProvider)40 Return<Result> Effect::setConfig(
41         const EffectConfig& config,
42         const ::android::sp<IEffectBufferProviderCallback>& inputBufferProvider,
43         const ::android::sp<IEffectBufferProviderCallback>& outputBufferProvider) {
44     (void)config;
45     (void)inputBufferProvider;
46     (void)outputBufferProvider;
47     return Result::OK;
48 }
49 
reset()50 Return<Result> Effect::reset() {
51     return Result::OK;
52 }
53 
enable()54 Return<Result> Effect::enable() {
55     if (!mEnabled) {
56         mEnabled = true;
57         return Result::OK;
58     } else {
59         return Result::NOT_SUPPORTED;
60     }
61 }
62 
disable()63 Return<Result> Effect::disable() {
64     if (mEnabled) {
65         mEnabled = false;
66         return Result::OK;
67     } else {
68         return Result::NOT_SUPPORTED;
69     }
70 }
71 
setDevice(const DeviceAddress & device)72 Return<Result> Effect::setDevice(const DeviceAddress& device) {
73     (void)device;
74     return Result::OK;
75 }
76 
setAndGetVolume(const hidl_vec<uint32_t> & volumes,setAndGetVolume_cb _hidl_cb)77 Return<void> Effect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
78                                      setAndGetVolume_cb _hidl_cb) {
79     (void)volumes;
80     _hidl_cb(Result::OK, hidl_vec<uint32_t>{});
81     return Void();
82 }
83 
volumeChangeNotification(const hidl_vec<uint32_t> & volumes)84 Return<Result> Effect::volumeChangeNotification(const hidl_vec<uint32_t>& volumes) {
85     (void)volumes;
86     return Result::OK;
87 }
88 
setAudioMode(AudioMode mode)89 Return<Result> Effect::setAudioMode(AudioMode mode) {
90     (void)mode;
91     return Result::OK;
92 }
93 
setConfigReverse(const EffectConfig & config,const::android::sp<IEffectBufferProviderCallback> & inputBufferProvider,const::android::sp<IEffectBufferProviderCallback> & outputBufferProvider)94 Return<Result> Effect::setConfigReverse(
95         const EffectConfig& config,
96         const ::android::sp<IEffectBufferProviderCallback>& inputBufferProvider,
97         const ::android::sp<IEffectBufferProviderCallback>& outputBufferProvider) {
98     (void)config;
99     (void)inputBufferProvider;
100     (void)outputBufferProvider;
101     return Result::OK;
102 }
103 
setInputDevice(const DeviceAddress & device)104 Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
105     (void)device;
106     return Result::OK;
107 }
108 
getConfig(getConfig_cb _hidl_cb)109 Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
110     EffectConfig config;
111     // inputCfg left unspecified.
112     config.outputCfg.base.format.value(toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT));
113     config.outputCfg.base.sampleRateHz.value(48000);
114     config.outputCfg.base.channelMask.value(
115             toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO));
116     config.outputCfg.accessMode.value(EffectBufferAccess::ACCESS_ACCUMULATE);
117     _hidl_cb(Result::OK, config);
118     return Void();
119 }
120 
getConfigReverse(getConfigReverse_cb _hidl_cb)121 Return<void> Effect::getConfigReverse(getConfigReverse_cb _hidl_cb) {
122     _hidl_cb(Result::OK, EffectConfig{});
123     return Void();
124 }
125 
getSupportedAuxChannelsConfigs(uint32_t maxConfigs,getSupportedAuxChannelsConfigs_cb _hidl_cb)126 Return<void> Effect::getSupportedAuxChannelsConfigs(uint32_t maxConfigs,
127                                                     getSupportedAuxChannelsConfigs_cb _hidl_cb) {
128     (void)maxConfigs;
129     _hidl_cb(Result::OK, hidl_vec<EffectAuxChannelsConfig>{});
130     return Void();
131 }
132 
getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb)133 Return<void> Effect::getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) {
134     _hidl_cb(Result::OK, EffectAuxChannelsConfig{});
135     return Void();
136 }
137 
setAuxChannelsConfig(const EffectAuxChannelsConfig & config)138 Return<Result> Effect::setAuxChannelsConfig(const EffectAuxChannelsConfig& config) {
139     (void)config;
140     return Result::OK;
141 }
142 
setAudioSource(const hidl_string & source)143 Return<Result> Effect::setAudioSource(const hidl_string& source) {
144     (void)source;
145     return Result::OK;
146 }
147 
offload(const EffectOffloadParameter & param)148 Return<Result> Effect::offload(const EffectOffloadParameter& param) {
149     (void)param;
150     return Result::OK;
151 }
152 
getDescriptor(getDescriptor_cb _hidl_cb)153 Return<void> Effect::getDescriptor(getDescriptor_cb _hidl_cb) {
154     _hidl_cb(Result::OK, mDescriptor);
155     return Void();
156 }
157 
prepareForProcessing(prepareForProcessing_cb _hidl_cb)158 Return<void> Effect::prepareForProcessing(prepareForProcessing_cb _hidl_cb) {
159     _hidl_cb(Result::OK, MQDescriptor<Result, kSynchronizedReadWrite>{});
160     return Void();
161 }
162 
setProcessBuffers(const AudioBuffer & inBuffer,const AudioBuffer & outBuffer)163 Return<Result> Effect::setProcessBuffers(const AudioBuffer& inBuffer,
164                                          const AudioBuffer& outBuffer) {
165     (void)inBuffer;
166     (void)outBuffer;
167     return Result::OK;
168 }
169 
command(uint32_t commandId,const hidl_vec<uint8_t> & data,uint32_t resultMaxSize,command_cb _hidl_cb)170 Return<void> Effect::command(uint32_t commandId, const hidl_vec<uint8_t>& data,
171                              uint32_t resultMaxSize, command_cb _hidl_cb) {
172     (void)commandId;
173     (void)data;
174     (void)resultMaxSize;
175     _hidl_cb(-EINVAL, hidl_vec<uint8_t>{});
176     return Void();
177 }
178 
setParameter(const hidl_vec<uint8_t> & parameter,const hidl_vec<uint8_t> & value)179 Return<Result> Effect::setParameter(const hidl_vec<uint8_t>& parameter,
180                                     const hidl_vec<uint8_t>& value) {
181     (void)parameter;
182     (void)value;
183     return Result::OK;
184 }
185 
getParameter(const hidl_vec<uint8_t> & parameter,uint32_t valueMaxSize,getParameter_cb _hidl_cb)186 Return<void> Effect::getParameter(const hidl_vec<uint8_t>& parameter, uint32_t valueMaxSize,
187                                   getParameter_cb _hidl_cb) {
188     (void)parameter;
189     (void)valueMaxSize;
190     _hidl_cb(Result::OK, hidl_vec<uint8_t>{});
191     return Void();
192 }
193 
getSupportedConfigsForFeature(uint32_t featureId,uint32_t maxConfigs,uint32_t configSize,getSupportedConfigsForFeature_cb _hidl_cb)194 Return<void> Effect::getSupportedConfigsForFeature(uint32_t featureId, uint32_t maxConfigs,
195                                                    uint32_t configSize,
196                                                    getSupportedConfigsForFeature_cb _hidl_cb) {
197     (void)featureId;
198     (void)maxConfigs;
199     (void)configSize;
200     _hidl_cb(Result::OK, 0, hidl_vec<uint8_t>{});
201     return Void();
202 }
203 
getCurrentConfigForFeature(uint32_t featureId,uint32_t configSize,getCurrentConfigForFeature_cb _hidl_cb)204 Return<void> Effect::getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize,
205                                                 getCurrentConfigForFeature_cb _hidl_cb) {
206     (void)featureId;
207     (void)configSize;
208     _hidl_cb(Result::OK, hidl_vec<uint8_t>{});
209     return Void();
210 }
211 
setCurrentConfigForFeature(uint32_t featureId,const hidl_vec<uint8_t> & configData)212 Return<Result> Effect::setCurrentConfigForFeature(uint32_t featureId,
213                                                   const hidl_vec<uint8_t>& configData) {
214     (void)featureId;
215     (void)configData;
216     return Result::OK;
217 }
218 
close()219 Return<Result> Effect::close() {
220     return Result::OK;
221 }
222 
223 }  // namespace android::hardware::audio::effect::V7_0::implementation
224