blob: 615a460eb8cfea742e82d0e0d770fa646fb57a19 [file] [log] [blame]
Mikhail Naganov40be06c2016-09-27 17:01:34 -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
17package android.hardware.audio.effect@2.0;
18
19import android.hardware.audio.common@2.0;
20import IEffectBufferProviderCallback;
21
22interface IEffect {
23 /*
24 * Initialize effect engine--all configurations return to default.
25 *
26 * @return retval operation completion status.
27 */
28 @entry
29 @callflow(next={"*"})
30 init() generates (Result retval);
31
32 /*
33 * Apply new audio parameters configurations for input and output buffers.
34 * The provider callbacks may be empty, but in this case the buffer
35 * must be provided in the EffectConfig structure.
36 *
37 * @param config configuration descriptor.
38 * @param inputBufferProvider optional buffer provider reference.
39 * @param outputBufferProvider optional buffer provider reference.
40 * @return retval operation completion status.
41 */
42 @callflow(next={"*"})
43 setConfig(EffectConfig config,
44 IEffectBufferProviderCallback inputBufferProvider,
45 IEffectBufferProviderCallback outputBufferProvider)
46 generates (Result retval);
47
48 /*
49 * Reset the effect engine. Keep configuration but resets state and buffer
50 * content.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070051 *
52 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -070053 */
54 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070055 reset() generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -070056
57 /*
58 * Enable processing.
59 *
60 * @return retval operation completion status.
61 */
62 @callflow(next={"process"})
63 enable() generates (Result retval);
64
65 /*
66 * Disable processing.
67 *
68 * @return retval operation completion status.
69 */
70 @exit
71 disable() generates (Result retval);
72
73 /*
74 * Set the rendering device the audio output path is connected to. The
75 * effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its
76 * descriptor to receive this command when the device changes.
77 *
78 * @param device output device specification.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070079 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -070080 */
81 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070082 setDevice(AudioDevice device) generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -070083
84 /*
85 * Set and get volume. Used by audio framework to delegate volume control to
86 * effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_IND
87 * or EFFECT_FLAG_VOLUME_CTRL flag in its descriptor to receive this command
88 * before every call to 'process' function If EFFECT_FLAG_VOLUME_CTRL flag
89 * is set in the effect descriptor, the effect engine must return the volume
90 * that should be applied before the effect is processed. The overall volume
91 * (the volume actually applied by the effect engine multiplied by the
92 * returned value) should match the value indicated in the command.
93 *
94 * @param volumes vector containing volume for each channel defined in
95 * EffectConfig for output buffer expressed in 8.24 fixed
96 * point format.
97 * @return result updated volume values. It is OK to receive an empty vector
98 * as a result in which case the effect framework has
99 * delegated volume control to another effect.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700100 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700101 */
102 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700103 setAndGetVolume(vec<uint32_t> volumes)
104 generates (Result retval, vec<uint32_t> result);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700105
106 /*
107 * Set the audio mode. The effect implementation must set
108 * EFFECT_FLAG_AUDIO_MODE_IND flag in its descriptor to receive this command
109 * when the audio mode changes.
110 *
111 * @param mode desired audio mode.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700112 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700113 */
114 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700115 setAudioMode(AudioMode mode) generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700116
117 /*
118 * Apply new audio parameters configurations for input and output buffers of
119 * reverse stream. An example of reverse stream is the echo reference
120 * supplied to an Acoustic Echo Canceler.
121 *
122 * @param config configuration descriptor.
123 * @param inputBufferProvider optional buffer provider reference.
124 * @param outputBufferProvider optional buffer provider reference.
125 * @return retval operation completion status.
126 */
127 @callflow(next={"*"})
128 setConfigReverse(EffectConfig config,
129 IEffectBufferProviderCallback inputBufferProvider,
130 IEffectBufferProviderCallback outputBufferProvider)
131 generates (Result retval);
132
133 /*
134 * Set the capture device the audio input path is connected to. The effect
135 * implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to
136 * receive this command when the device changes.
137 *
138 * @param device input device specification.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700139 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700140 */
141 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700142 setInputDevice(AudioDevice device) generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700143
144 /*
145 * Read audio parameters configurations for input and output buffers.
146 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700147 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700148 * @return config configuration descriptor.
149 */
150 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700151 getConfig() generates (Result retval, EffectConfig config);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700152
153 /*
154 * Read audio parameters configurations for input and output buffers of
155 * reverse stream.
156 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700157 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700158 * @return config configuration descriptor.
159 */
160 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700161 getConfigReverse() generates (Result retval, EffectConfig config);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700162
163 /*
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700164 * Queries for supported combinations of main and auxiliary channels
165 * (e.g. for a multi-microphone noise suppressor).
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700166 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700167 * @param maxConfigs maximum number of the combinations to return.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700168 * @return retval absence of the feature support is indicated using
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700169 * NOT_SUPPORTED code. RESULT_TOO_BIG is returned if
170 * the number of supported combinations exceeds 'maxConfigs'.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700171 * @return result list of configuration descriptors.
172 */
173 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700174 getSupportedAuxChannelsConfigs(uint32_t maxConfigs)
175 generates (Result retval, vec<EffectAuxChannelsConfig> result);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700176
177 /*
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700178 * Retrieves the current configuration of main and auxiliary channels.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700179 *
180 * @return retval absence of the feature support is indicated using
181 * NOT_SUPPORTED code.
182 * @return result configuration descriptor.
183 */
184 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700185 getAuxChannelsConfig()
186 generates (Result retval, EffectAuxChannelsConfig result);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700187
188 /*
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700189 * Sets the current configuration of main and auxiliary channels.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700190 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700191 * @return retval operation completion status; absence of the feature
192 * support is indicated using NOT_SUPPORTED code.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700193 */
194 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700195 setAuxChannelsConfig(EffectAuxChannelsConfig config)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700196 generates (Result retval);
197
198 /*
199 * Set the audio source the capture path is configured for (Camcorder, voice
200 * recognition...).
201 *
202 * @param source source descriptor.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700203 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700204 */
205 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700206 setAudioSource(AudioSource source) generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700207
208 /*
209 * This command indicates if the playback thread the effect is attached to
210 * is offloaded or not, and updates the I/O handle of the playback thread
211 * the effect is attached to.
212 *
213 * @param param effect offload descriptor.
214 * @return retval operation completion status.
215 */
216 @callflow(next={"*"})
217 offload(EffectOffloadParameter param) generates (Result retval);
218
219 /*
220 * Returns the effect descriptor.
221 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700222 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700223 * @return descriptor effect descriptor.
224 */
225 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700226 getDescriptor() generates (Result retval, EffectDescriptor descriptor);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700227
228 /*
229 * Effect process function. Takes input samples as specified (count and
230 * location) in input buffer and returns processed samples as specified in
231 * output buffer. If the buffer descriptor is empty the function must use
232 * either the buffer or the buffer provider callback installed by the
233 * setConfig command. The effect framework must call the 'process' function
234 * after the 'enable' command is received and until the 'disable' is
235 * received. When the engine receives the 'disable' command it should turn
236 * off the effect gracefully and when done indicate that it is OK to stop
237 * calling the 'process' function by returning the INVALID_STATE status.
238 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700239 * Output audio buffer must contain no more frames than the input audio
240 * buffer. Since the effect may transform input channels into a different
241 * amount of channels, the caller provides the output frame size.
242 *
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700243 * @param inBuffer input audio buffer.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700244 * @param outFrameSize output frame size in bytes.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700245 * @return retval operation completion status.
246 * @return outBuffer output audio buffer.
247 */
248 // TODO(mnaganov): replace with FMQ version.
249 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700250 process(AudioBuffer inBuffer, uint32_t outFrameSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700251 generates (Result retval, AudioBuffer outBuffer);
252
253 /*
254 * Process reverse stream function. This function is used to pass a
255 * reference stream to the effect engine. If the engine does not need a
256 * reference stream, this function MUST return NOT_SUPPORTED. For example,
257 * this function would typically implemented by an Echo Canceler.
258 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700259 * Output audio buffer must contain no more frames than the input audio
260 * buffer. Since the effect may transform input channels into a different
261 * amount of channels, the caller provides the output frame size.
262 *
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700263 * @param inBuffer input audio buffer.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700264 * @param outFrameSize output frame size in bytes.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700265 * @return retval operation completion status.
266 * @return outBuffer output audio buffer.
267 */
268 // TODO(mnaganov): replace with FMQ version.
269 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700270 processReverse(AudioBuffer inBuffer, uint32_t outFrameSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700271 generates (Result retval, AudioBuffer outBuffer);
272
273 /*
274 * Execute a vendor specific command on the effect. The command code
275 * and data, as well as result data are not interpreted by Android
276 * Framework and are passed as-is between the application and the effect.
277 *
278 * The effect must use standard POSIX.1-2001 error codes for the operation
279 * completion status.
280 *
281 * Use this method only if the effect is provided by a third party, and
282 * there is no interface defined for it. This method only works for effects
283 * implemented in software.
284 *
285 * @param commandId the ID of the command.
286 * @param data command data.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700287 * @param resultMaxSize maximum size in bytes of the result; can be 0.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700288 * @return status command completion status.
289 * @return result result data.
290 */
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700291 command(uint32_t commandId, vec<uint8_t> data, uint32_t resultMaxSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700292 generates (int32_t status, vec<uint8_t> result);
293
294 /*
295 * Set a vendor-specific parameter and apply it immediately. The parameter
296 * code and data are not interpreted by Android Framework and are passed
297 * as-is between the application and the effect.
298 *
299 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
300 * unknown or if provided parameter data is invalid. If the effect does not
301 * support setting vendor-specific parameters, it must return NOT_SUPPORTED.
302 *
303 * Use this method only if the effect is provided by a third party, and
304 * there is no interface defined for it. This method only works for effects
305 * implemented in software.
306 *
307 * @param parameter identifying data of the parameter.
308 * @param value the value of the parameter.
309 * @return retval operation completion status.
310 */
311 @callflow(next={"*"})
312 setParameter(vec<uint8_t> parameter, vec<uint8_t> value)
313 generates (Result retval);
314
315 /*
316 * Get a vendor-specific parameter value. The parameter code and returned
317 * data are not interpreted by Android Framework and are passed as-is
318 * between the application and the effect.
319 *
320 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
321 * unknown. If the effect does not support setting vendor-specific
322 * parameters, it must return NOT_SUPPORTED.
323 *
324 * Use this method only if the effect is provided by a third party, and
325 * there is no interface defined for it. This method only works for effects
326 * implemented in software.
327 *
328 * @param parameter identifying data of the parameter.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700329 * @param valueMaxSize maximum size in bytes of the value.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700330 * @return retval operation completion status.
331 * @return result the value of the parameter.
332 */
333 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700334 getParameter(vec<uint8_t> parameter, uint32_t valueMaxSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700335 generates (Result retval, vec<uint8_t> value);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700336
337 /*
338 * Get supported configs for a vendor-specific feature. The configs returned
339 * are not interpreted by Android Framework and are passed as-is between the
340 * application and the effect.
341 *
342 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
343 * unknown. If the effect does not support getting vendor-specific feature
344 * configs, it must return NOT_SUPPORTED. If the feature is supported but
345 * the total number of supported configurations exceeds the maximum number
346 * indicated by the caller, the method must return RESULT_TOO_BIG.
347 *
348 * Use this method only if the effect is provided by a third party, and
349 * there is no interface defined for it. This method only works for effects
350 * implemented in software.
351 *
352 * @param featureId feature identifier.
353 * @param maxConfigs maximum number of configs to return.
354 * @param configSize size of each config in bytes.
355 * @return retval operation completion status.
356 * @return configsCount number of configs returned.
357 * @return configsData data for all the configs returned.
358 */
359 @callflow(next={"*"})
360 getSupportedConfigsForFeature(
361 uint32_t featureId,
362 uint32_t maxConfigs,
363 uint32_t configSize) generates (
364 Result retval,
365 uint32_t configsCount,
366 vec<uint8_t> configsData);
367
368 /*
369 * Get the current config for a vendor-specific feature. The config returned
370 * is not interpreted by Android Framework and is passed as-is between the
371 * application and the effect.
372 *
373 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
374 * unknown. If the effect does not support getting vendor-specific
375 * feature configs, it must return NOT_SUPPORTED.
376 *
377 * Use this method only if the effect is provided by a third party, and
378 * there is no interface defined for it. This method only works for effects
379 * implemented in software.
380 *
381 * @param featureId feature identifier.
382 * @param configSize size of the config in bytes.
383 * @return retval operation completion status.
384 * @return configData config data.
385 */
386 @callflow(next={"*"})
387 getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize)
388 generates (Result retval, vec<uint8_t> configData);
389
390 /*
391 * Set the current config for a vendor-specific feature. The config data
392 * is not interpreted by Android Framework and is passed as-is between the
393 * application and the effect.
394 *
395 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
396 * unknown. If the effect does not support getting vendor-specific
397 * feature configs, it must return NOT_SUPPORTED.
398 *
399 * Use this method only if the effect is provided by a third party, and
400 * there is no interface defined for it. This method only works for effects
401 * implemented in software.
402 *
403 * @param featureId feature identifier.
404 * @param configData config data.
405 * @return retval operation completion status.
406 */
407 setCurrentConfigForFeature(uint32_t featureId, vec<uint8_t> configData)
408 generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700409};