blob: 9e101173ca1b6038e23d9af4abaa040a78dbf507 [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
Mikhail Naganovf4f2ff32017-01-19 12:38:39 -080086 * effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_CTRL
87 * flag in its descriptor to receive this command. The effect engine must
88 * return the volume that should be applied before the effect is
89 * processed. The overall volume (the volume actually applied by the effect
90 * engine multiplied by the returned value) should match the value indicated
91 * in the command.
Mikhail Naganov40be06c2016-09-27 17:01:34 -070092 *
93 * @param volumes vector containing volume for each channel defined in
94 * EffectConfig for output buffer expressed in 8.24 fixed
95 * point format.
Mikhail Naganovf4f2ff32017-01-19 12:38:39 -080096 * @return result updated volume values.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -070097 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -070098 */
99 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700100 setAndGetVolume(vec<uint32_t> volumes)
101 generates (Result retval, vec<uint32_t> result);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700102
103 /*
Mikhail Naganovf4f2ff32017-01-19 12:38:39 -0800104 * Notify the effect of the volume change. The effect implementation must
105 * set EFFECT_FLAG_VOLUME_IND flag in its descriptor to receive this
106 * command.
107 *
108 * @param volumes vector containing volume for each channel defined in
109 * EffectConfig for output buffer expressed in 8.24 fixed
110 * point format.
111 * @return retval operation completion status.
112 */
113 volumeChangeNotification(vec<uint32_t> volumes)
114 generates (Result retval);
115
116 /*
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700117 * Set the audio mode. The effect implementation must set
118 * EFFECT_FLAG_AUDIO_MODE_IND flag in its descriptor to receive this command
119 * when the audio mode changes.
120 *
121 * @param mode desired audio mode.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700122 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700123 */
124 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700125 setAudioMode(AudioMode mode) generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700126
127 /*
128 * Apply new audio parameters configurations for input and output buffers of
129 * reverse stream. An example of reverse stream is the echo reference
130 * supplied to an Acoustic Echo Canceler.
131 *
132 * @param config configuration descriptor.
133 * @param inputBufferProvider optional buffer provider reference.
134 * @param outputBufferProvider optional buffer provider reference.
135 * @return retval operation completion status.
136 */
137 @callflow(next={"*"})
138 setConfigReverse(EffectConfig config,
139 IEffectBufferProviderCallback inputBufferProvider,
140 IEffectBufferProviderCallback outputBufferProvider)
141 generates (Result retval);
142
143 /*
144 * Set the capture device the audio input path is connected to. The effect
145 * implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to
146 * receive this command when the device changes.
147 *
148 * @param device input device specification.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700149 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700150 */
151 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700152 setInputDevice(AudioDevice device) generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700153
154 /*
155 * Read audio parameters configurations for input and output buffers.
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 getConfig() generates (Result retval, EffectConfig config);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700162
163 /*
164 * Read audio parameters configurations for input and output buffers of
165 * reverse stream.
166 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700167 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700168 * @return config configuration descriptor.
169 */
170 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700171 getConfigReverse() generates (Result retval, EffectConfig config);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700172
173 /*
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700174 * Queries for supported combinations of main and auxiliary channels
175 * (e.g. for a multi-microphone noise suppressor).
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700176 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700177 * @param maxConfigs maximum number of the combinations to return.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700178 * @return retval absence of the feature support is indicated using
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700179 * NOT_SUPPORTED code. RESULT_TOO_BIG is returned if
180 * the number of supported combinations exceeds 'maxConfigs'.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700181 * @return result list of configuration descriptors.
182 */
183 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700184 getSupportedAuxChannelsConfigs(uint32_t maxConfigs)
185 generates (Result retval, vec<EffectAuxChannelsConfig> result);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700186
187 /*
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700188 * Retrieves the current configuration of main and auxiliary channels.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700189 *
190 * @return retval absence of the feature support is indicated using
191 * NOT_SUPPORTED code.
192 * @return result configuration descriptor.
193 */
194 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700195 getAuxChannelsConfig()
196 generates (Result retval, EffectAuxChannelsConfig result);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700197
198 /*
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700199 * Sets the current configuration of main and auxiliary channels.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700200 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700201 * @return retval operation completion status; absence of the feature
202 * support is indicated using NOT_SUPPORTED code.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700203 */
204 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700205 setAuxChannelsConfig(EffectAuxChannelsConfig config)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700206 generates (Result retval);
207
208 /*
209 * Set the audio source the capture path is configured for (Camcorder, voice
210 * recognition...).
211 *
212 * @param source source descriptor.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700213 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700214 */
215 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700216 setAudioSource(AudioSource source) generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700217
218 /*
219 * This command indicates if the playback thread the effect is attached to
220 * is offloaded or not, and updates the I/O handle of the playback thread
221 * the effect is attached to.
222 *
223 * @param param effect offload descriptor.
224 * @return retval operation completion status.
225 */
226 @callflow(next={"*"})
227 offload(EffectOffloadParameter param) generates (Result retval);
228
229 /*
230 * Returns the effect descriptor.
231 *
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700232 * @return retval operation completion status.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700233 * @return descriptor effect descriptor.
234 */
235 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700236 getDescriptor() generates (Result retval, EffectDescriptor descriptor);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700237
238 /*
Mikhail Naganova331de12017-01-04 16:33:55 -0800239 * Set up required transports for passing audio buffers to the effect.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700240 *
Mikhail Naganova331de12017-01-04 16:33:55 -0800241 * The transport consists of shared memory and a message queue for reporting
242 * effect processing operation status. The shared memory is set up
243 * separately using 'setProcessBuffers' method.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700244 *
Mikhail Naganova331de12017-01-04 16:33:55 -0800245 * Processing is requested by setting 'REQUEST_PROCESS' or
246 * 'REQUEST_PROCESS_REVERSE' EventFlags associated with the status message
247 * queue. The result of processing may be one of the following:
248 * OK if there were no errors during processing;
249 * INVALID_ARGUMENTS if audio buffers are invalid;
250 * INVALID_STATE if the engine has finished the disable phase;
251 * NOT_INITIALIZED if the audio buffers were not set;
252 * NOT_SUPPORTED if the requested processing type is not supported by
253 * the effect.
254 *
255 * @return retval OK if both message queues were created successfully.
256 * INVALID_STATE if the method was already called.
257 * INVALID_ARGUMENTS if there was a problem setting up
258 * the queue.
259 * @return statusMQ a message queue used for passing status from the effect.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700260 */
Mikhail Naganova331de12017-01-04 16:33:55 -0800261 prepareForProcessing() generates (Result retval, fmq_sync<Result> statusMQ);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700262
263 /*
Mikhail Naganova331de12017-01-04 16:33:55 -0800264 * Set up input and output buffers for processing audio data. The effect
265 * may modify both the input and the output buffer during the operation.
266 * Buffers may be set multiple times during effect lifetime.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700267 *
Mikhail Naganova331de12017-01-04 16:33:55 -0800268 * The input and the output buffer may be reused between different effects,
269 * and the input buffer may be used as an output buffer. Buffers are
270 * distinguished using 'AudioBuffer.id' field.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700271 *
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700272 * @param inBuffer input audio buffer.
Mikhail Naganova331de12017-01-04 16:33:55 -0800273 * @param outBuffer output audio buffer.
274 * @return retval OK if both buffers were mapped successfully.
275 * INVALID_ARGUMENTS if there was a problem with mapping
276 * any of the buffers.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700277 */
Mikhail Naganova331de12017-01-04 16:33:55 -0800278 setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer) generates (
279 Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700280
281 /*
282 * Execute a vendor specific command on the effect. The command code
283 * and data, as well as result data are not interpreted by Android
284 * Framework and are passed as-is between the application and the effect.
285 *
286 * The effect must use standard POSIX.1-2001 error codes for the operation
287 * completion status.
288 *
289 * Use this method only if the effect is provided by a third party, and
290 * there is no interface defined for it. This method only works for effects
291 * implemented in software.
292 *
293 * @param commandId the ID of the command.
294 * @param data command data.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700295 * @param resultMaxSize maximum size in bytes of the result; can be 0.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700296 * @return status command completion status.
297 * @return result result data.
298 */
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700299 command(uint32_t commandId, vec<uint8_t> data, uint32_t resultMaxSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700300 generates (int32_t status, vec<uint8_t> result);
301
302 /*
303 * Set a vendor-specific parameter and apply it immediately. The parameter
304 * code and data are not interpreted by Android Framework and are passed
305 * as-is between the application and the effect.
306 *
307 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
308 * unknown or if provided parameter data is invalid. If the effect does not
309 * support setting vendor-specific parameters, it must return NOT_SUPPORTED.
310 *
311 * Use this method only if the effect is provided by a third party, and
312 * there is no interface defined for it. This method only works for effects
313 * implemented in software.
314 *
315 * @param parameter identifying data of the parameter.
316 * @param value the value of the parameter.
317 * @return retval operation completion status.
318 */
319 @callflow(next={"*"})
320 setParameter(vec<uint8_t> parameter, vec<uint8_t> value)
321 generates (Result retval);
322
323 /*
324 * Get a vendor-specific parameter value. The parameter code and returned
325 * data are not interpreted by Android Framework and are passed as-is
326 * between the application and the effect.
327 *
328 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
329 * unknown. If the effect does not support setting vendor-specific
330 * parameters, it must return NOT_SUPPORTED.
331 *
332 * Use this method only if the effect is provided by a third party, and
333 * there is no interface defined for it. This method only works for effects
334 * implemented in software.
335 *
336 * @param parameter identifying data of the parameter.
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700337 * @param valueMaxSize maximum size in bytes of the value.
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700338 * @return retval operation completion status.
339 * @return result the value of the parameter.
340 */
341 @callflow(next={"*"})
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700342 getParameter(vec<uint8_t> parameter, uint32_t valueMaxSize)
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700343 generates (Result retval, vec<uint8_t> value);
Mikhail Naganov7cbf2f12016-10-27 20:05:35 -0700344
345 /*
346 * Get supported configs for a vendor-specific feature. The configs returned
347 * are not interpreted by Android Framework and are passed as-is between the
348 * application and the effect.
349 *
350 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
351 * unknown. If the effect does not support getting vendor-specific feature
352 * configs, it must return NOT_SUPPORTED. If the feature is supported but
353 * the total number of supported configurations exceeds the maximum number
354 * indicated by the caller, the method must return RESULT_TOO_BIG.
355 *
356 * Use this method only if the effect is provided by a third party, and
357 * there is no interface defined for it. This method only works for effects
358 * implemented in software.
359 *
360 * @param featureId feature identifier.
361 * @param maxConfigs maximum number of configs to return.
362 * @param configSize size of each config in bytes.
363 * @return retval operation completion status.
364 * @return configsCount number of configs returned.
365 * @return configsData data for all the configs returned.
366 */
367 @callflow(next={"*"})
368 getSupportedConfigsForFeature(
369 uint32_t featureId,
370 uint32_t maxConfigs,
371 uint32_t configSize) generates (
372 Result retval,
373 uint32_t configsCount,
374 vec<uint8_t> configsData);
375
376 /*
377 * Get the current config for a vendor-specific feature. The config returned
378 * is not interpreted by Android Framework and is passed as-is between the
379 * application and the effect.
380 *
381 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
382 * unknown. If the effect does not support getting vendor-specific
383 * feature configs, it must return NOT_SUPPORTED.
384 *
385 * Use this method only if the effect is provided by a third party, and
386 * there is no interface defined for it. This method only works for effects
387 * implemented in software.
388 *
389 * @param featureId feature identifier.
390 * @param configSize size of the config in bytes.
391 * @return retval operation completion status.
392 * @return configData config data.
393 */
394 @callflow(next={"*"})
395 getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize)
396 generates (Result retval, vec<uint8_t> configData);
397
398 /*
399 * Set the current config for a vendor-specific feature. The config data
400 * is not interpreted by Android Framework and is passed as-is between the
401 * application and the effect.
402 *
403 * The effect must use INVALID_ARGUMENTS return code if the feature ID is
404 * unknown. If the effect does not support getting vendor-specific
405 * feature configs, it must return NOT_SUPPORTED.
406 *
407 * Use this method only if the effect is provided by a third party, and
408 * there is no interface defined for it. This method only works for effects
409 * implemented in software.
410 *
411 * @param featureId feature identifier.
412 * @param configData config data.
413 * @return retval operation completion status.
414 */
415 setCurrentConfigForFeature(uint32_t featureId, vec<uint8_t> configData)
416 generates (Result retval);
Mikhail Naganova331de12017-01-04 16:33:55 -0800417
418 /*
419 * Called by the framework to deinitialize the effect and free up
420 * all the currently allocated resources. It is recommended to close
421 * the effect on the client side as soon as it is becomes unused.
422 *
423 * @return retval OK in case the success.
424 * INVALID_STATE if the effect was already closed.
425 */
426 close() generates (Result retval);
Mikhail Naganov40be06c2016-09-27 17:01:34 -0700427};