blob: 9027c68d6189991d029c989373d245977331649f [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 /*
Mikhail Naganova331de12017-01-04 16:33:55 -0800229 * Set up required transports for passing audio buffers to the effect.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700230 *
Mikhail Naganova331de12017-01-04 16:33:55 -0800231 * The transport consists of shared memory and a message queue for reporting
232 * effect processing operation status. The shared memory is set up
233 * separately using 'setProcessBuffers' method.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700234 *
Mikhail Naganova331de12017-01-04 16:33:55 -0800235 * Processing is requested by setting 'REQUEST_PROCESS' or
236 * 'REQUEST_PROCESS_REVERSE' EventFlags associated with the status message
237 * queue. The result of processing may be one of the following:
238 * OK if there were no errors during processing;
239 * INVALID_ARGUMENTS if audio buffers are invalid;
240 * INVALID_STATE if the engine has finished the disable phase;
241 * NOT_INITIALIZED if the audio buffers were not set;
242 * NOT_SUPPORTED if the requested processing type is not supported by
243 * the effect.
244 *
245 * @return retval OK if both message queues were created successfully.
246 * INVALID_STATE if the method was already called.
247 * INVALID_ARGUMENTS if there was a problem setting up
248 * the queue.
249 * @return statusMQ a message queue used for passing status from the effect.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700250 */
Mikhail Naganova331de12017-01-04 16:33:55 -0800251 prepareForProcessing() generates (Result retval, fmq_sync<Result> statusMQ);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700252
253 /*
Mikhail Naganova331de12017-01-04 16:33:55 -0800254 * Set up input and output buffers for processing audio data. The effect
255 * may modify both the input and the output buffer during the operation.
256 * Buffers may be set multiple times during effect lifetime.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700257 *
Mikhail Naganova331de12017-01-04 16:33:55 -0800258 * The input and the output buffer may be reused between different effects,
259 * and the input buffer may be used as an output buffer. Buffers are
260 * distinguished using 'AudioBuffer.id' field.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700261 *
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700262 * @param inBuffer input audio buffer.
Mikhail Naganova331de12017-01-04 16:33:55 -0800263 * @param outBuffer output audio buffer.
264 * @return retval OK if both buffers were mapped successfully.
265 * INVALID_ARGUMENTS if there was a problem with mapping
266 * any of the buffers.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700267 */
Mikhail Naganova331de12017-01-04 16:33:55 -0800268 setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer) generates (
269 Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700270
271 /*
272 * Execute a vendor specific command on the effect. The command code
273 * and data, as well as result data are not interpreted by Android
274 * Framework and are passed as-is between the application and the effect.
275 *
276 * The effect must use standard POSIX.1-2001 error codes for the operation
277 * completion status.
278 *
279 * Use this method only if the effect is provided by a third party, and
280 * there is no interface defined for it. This method only works for effects
281 * implemented in software.
282 *
283 * @param commandId the ID of the command.
284 * @param data command data.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700285 * @param resultMaxSize maximum size in bytes of the result; can be 0.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700286 * @return status command completion status.
287 * @return result result data.
288 */
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700289 command(uint32_t commandId, vec<uint8_t> data, uint32_t resultMaxSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700290 generates (int32_t status, vec<uint8_t> result);
291
292 /*
293 * Set a vendor-specific parameter and apply it immediately. The parameter
294 * code and data are not interpreted by Android Framework and are passed
295 * as-is between the application and the effect.
296 *
297 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
298 * unknown or if provided parameter data is invalid. If the effect does not
299 * support setting vendor-specific parameters, it must return NOT_SUPPORTED.
300 *
301 * Use this method only if the effect is provided by a third party, and
302 * there is no interface defined for it. This method only works for effects
303 * implemented in software.
304 *
305 * @param parameter identifying data of the parameter.
306 * @param value the value of the parameter.
307 * @return retval operation completion status.
308 */
309 @callflow(next={"*"})
310 setParameter(vec<uint8_t> parameter, vec<uint8_t> value)
311 generates (Result retval);
312
313 /*
314 * Get a vendor-specific parameter value. The parameter code and returned
315 * data are not interpreted by Android Framework and are passed as-is
316 * between the application and the effect.
317 *
318 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
319 * unknown. If the effect does not support setting vendor-specific
320 * parameters, it must return NOT_SUPPORTED.
321 *
322 * Use this method only if the effect is provided by a third party, and
323 * there is no interface defined for it. This method only works for effects
324 * implemented in software.
325 *
326 * @param parameter identifying data of the parameter.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700327 * @param valueMaxSize maximum size in bytes of the value.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700328 * @return retval operation completion status.
329 * @return result the value of the parameter.
330 */
331 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700332 getParameter(vec<uint8_t> parameter, uint32_t valueMaxSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700333 generates (Result retval, vec<uint8_t> value);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700334
335 /*
336 * Get supported configs for a vendor-specific feature. The configs returned
337 * are not interpreted by Android Framework and are passed as-is between the
338 * application and the effect.
339 *
340 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
341 * unknown. If the effect does not support getting vendor-specific feature
342 * configs, it must return NOT_SUPPORTED. If the feature is supported but
343 * the total number of supported configurations exceeds the maximum number
344 * indicated by the caller, the method must return RESULT_TOO_BIG.
345 *
346 * Use this method only if the effect is provided by a third party, and
347 * there is no interface defined for it. This method only works for effects
348 * implemented in software.
349 *
350 * @param featureId feature identifier.
351 * @param maxConfigs maximum number of configs to return.
352 * @param configSize size of each config in bytes.
353 * @return retval operation completion status.
354 * @return configsCount number of configs returned.
355 * @return configsData data for all the configs returned.
356 */
357 @callflow(next={"*"})
358 getSupportedConfigsForFeature(
359 uint32_t featureId,
360 uint32_t maxConfigs,
361 uint32_t configSize) generates (
362 Result retval,
363 uint32_t configsCount,
364 vec<uint8_t> configsData);
365
366 /*
367 * Get the current config for a vendor-specific feature. The config returned
368 * is not interpreted by Android Framework and is passed as-is between the
369 * application and the effect.
370 *
371 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
372 * unknown. If the effect does not support getting vendor-specific
373 * feature configs, it must return NOT_SUPPORTED.
374 *
375 * Use this method only if the effect is provided by a third party, and
376 * there is no interface defined for it. This method only works for effects
377 * implemented in software.
378 *
379 * @param featureId feature identifier.
380 * @param configSize size of the config in bytes.
381 * @return retval operation completion status.
382 * @return configData config data.
383 */
384 @callflow(next={"*"})
385 getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize)
386 generates (Result retval, vec<uint8_t> configData);
387
388 /*
389 * Set the current config for a vendor-specific feature. The config data
390 * is not interpreted by Android Framework and is passed as-is between the
391 * application and the effect.
392 *
393 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
394 * unknown. If the effect does not support getting vendor-specific
395 * feature configs, it must return NOT_SUPPORTED.
396 *
397 * Use this method only if the effect is provided by a third party, and
398 * there is no interface defined for it. This method only works for effects
399 * implemented in software.
400 *
401 * @param featureId feature identifier.
402 * @param configData config data.
403 * @return retval operation completion status.
404 */
405 setCurrentConfigForFeature(uint32_t featureId, vec<uint8_t> configData)
406 generates (Result retval);
Mikhail Naganova331de12017-01-04 16:33:55 -0800407
408 /*
409 * Called by the framework to deinitialize the effect and free up
410 * all the currently allocated resources. It is recommended to close
411 * the effect on the client side as soon as it is becomes unused.
412 *
413 * @return retval OK in case the success.
414 * INVALID_STATE if the effect was already closed.
415 */
416 close() generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700417};