1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.effect@2.0;
import android.hardware.audio.common@2.0;
import IEffectBufferProviderCallback;
interface IEffect {
/*
* Initialize effect engine--all configurations return to default.
*
* @return retval operation completion status.
*/
@entry
@callflow(next={"*"})
init() generates (Result retval);
/*
* Apply new audio parameters configurations for input and output buffers.
* The provider callbacks may be empty, but in this case the buffer
* must be provided in the EffectConfig structure.
*
* @param config configuration descriptor.
* @param inputBufferProvider optional buffer provider reference.
* @param outputBufferProvider optional buffer provider reference.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setConfig(EffectConfig config,
IEffectBufferProviderCallback inputBufferProvider,
IEffectBufferProviderCallback outputBufferProvider)
generates (Result retval);
/*
* Reset the effect engine. Keep configuration but resets state and buffer
* content.
*
* @return retval operation completion status.
*/
@callflow(next={"*"})
reset() generates (Result retval);
/*
* Enable processing.
*
* @return retval operation completion status.
*/
@callflow(next={"process"})
enable() generates (Result retval);
/*
* Disable processing.
*
* @return retval operation completion status.
*/
@exit
disable() generates (Result retval);
/*
* Set the rendering device the audio output path is connected to. The
* effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its
* descriptor to receive this command when the device changes.
*
* @param device output device specification.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setDevice(AudioDevice device) generates (Result retval);
/*
* Set and get volume. Used by audio framework to delegate volume control to
* effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_IND
* or EFFECT_FLAG_VOLUME_CTRL flag in its descriptor to receive this command
* before every call to 'process' function If EFFECT_FLAG_VOLUME_CTRL flag
* is set in the effect descriptor, the effect engine must return the volume
* that should be applied before the effect is processed. The overall volume
* (the volume actually applied by the effect engine multiplied by the
* returned value) should match the value indicated in the command.
*
* @param volumes vector containing volume for each channel defined in
* EffectConfig for output buffer expressed in 8.24 fixed
* point format.
* @return result updated volume values. It is OK to receive an empty vector
* as a result in which case the effect framework has
* delegated volume control to another effect.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setAndGetVolume(vec<uint32_t> volumes)
generates (Result retval, vec<uint32_t> result);
/*
* Set the audio mode. The effect implementation must set
* EFFECT_FLAG_AUDIO_MODE_IND flag in its descriptor to receive this command
* when the audio mode changes.
*
* @param mode desired audio mode.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setAudioMode(AudioMode mode) generates (Result retval);
/*
* Apply new audio parameters configurations for input and output buffers of
* reverse stream. An example of reverse stream is the echo reference
* supplied to an Acoustic Echo Canceler.
*
* @param config configuration descriptor.
* @param inputBufferProvider optional buffer provider reference.
* @param outputBufferProvider optional buffer provider reference.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setConfigReverse(EffectConfig config,
IEffectBufferProviderCallback inputBufferProvider,
IEffectBufferProviderCallback outputBufferProvider)
generates (Result retval);
/*
* Set the capture device the audio input path is connected to. The effect
* implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to
* receive this command when the device changes.
*
* @param device input device specification.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setInputDevice(AudioDevice device) generates (Result retval);
/*
* Read audio parameters configurations for input and output buffers.
*
* @return retval operation completion status.
* @return config configuration descriptor.
*/
@callflow(next={"*"})
getConfig() generates (Result retval, EffectConfig config);
/*
* Read audio parameters configurations for input and output buffers of
* reverse stream.
*
* @return retval operation completion status.
* @return config configuration descriptor.
*/
@callflow(next={"*"})
getConfigReverse() generates (Result retval, EffectConfig config);
/*
* Queries for supported combinations of main and auxiliary channels
* (e.g. for a multi-microphone noise suppressor).
*
* @param maxConfigs maximum number of the combinations to return.
* @return retval absence of the feature support is indicated using
* NOT_SUPPORTED code. RESULT_TOO_BIG is returned if
* the number of supported combinations exceeds 'maxConfigs'.
* @return result list of configuration descriptors.
*/
@callflow(next={"*"})
getSupportedAuxChannelsConfigs(uint32_t maxConfigs)
generates (Result retval, vec<EffectAuxChannelsConfig> result);
/*
* Retrieves the current configuration of main and auxiliary channels.
*
* @return retval absence of the feature support is indicated using
* NOT_SUPPORTED code.
* @return result configuration descriptor.
*/
@callflow(next={"*"})
getAuxChannelsConfig()
generates (Result retval, EffectAuxChannelsConfig result);
/*
* Sets the current configuration of main and auxiliary channels.
*
* @return retval operation completion status; absence of the feature
* support is indicated using NOT_SUPPORTED code.
*/
@callflow(next={"*"})
setAuxChannelsConfig(EffectAuxChannelsConfig config)
generates (Result retval);
/*
* Set the audio source the capture path is configured for (Camcorder, voice
* recognition...).
*
* @param source source descriptor.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setAudioSource(AudioSource source) generates (Result retval);
/*
* This command indicates if the playback thread the effect is attached to
* is offloaded or not, and updates the I/O handle of the playback thread
* the effect is attached to.
*
* @param param effect offload descriptor.
* @return retval operation completion status.
*/
@callflow(next={"*"})
offload(EffectOffloadParameter param) generates (Result retval);
/*
* Returns the effect descriptor.
*
* @return retval operation completion status.
* @return descriptor effect descriptor.
*/
@callflow(next={"*"})
getDescriptor() generates (Result retval, EffectDescriptor descriptor);
/*
* Set up required transports for passing audio buffers to the effect.
*
* The transport consists of shared memory and a message queue for reporting
* effect processing operation status. The shared memory is set up
* separately using 'setProcessBuffers' method.
*
* Processing is requested by setting 'REQUEST_PROCESS' or
* 'REQUEST_PROCESS_REVERSE' EventFlags associated with the status message
* queue. The result of processing may be one of the following:
* OK if there were no errors during processing;
* INVALID_ARGUMENTS if audio buffers are invalid;
* INVALID_STATE if the engine has finished the disable phase;
* NOT_INITIALIZED if the audio buffers were not set;
* NOT_SUPPORTED if the requested processing type is not supported by
* the effect.
*
* @return retval OK if both message queues were created successfully.
* INVALID_STATE if the method was already called.
* INVALID_ARGUMENTS if there was a problem setting up
* the queue.
* @return statusMQ a message queue used for passing status from the effect.
*/
prepareForProcessing() generates (Result retval, fmq_sync<Result> statusMQ);
/*
* Set up input and output buffers for processing audio data. The effect
* may modify both the input and the output buffer during the operation.
* Buffers may be set multiple times during effect lifetime.
*
* The input and the output buffer may be reused between different effects,
* and the input buffer may be used as an output buffer. Buffers are
* distinguished using 'AudioBuffer.id' field.
*
* @param inBuffer input audio buffer.
* @param outBuffer output audio buffer.
* @return retval OK if both buffers were mapped successfully.
* INVALID_ARGUMENTS if there was a problem with mapping
* any of the buffers.
*/
setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer) generates (
Result retval);
/*
* Execute a vendor specific command on the effect. The command code
* and data, as well as result data are not interpreted by Android
* Framework and are passed as-is between the application and the effect.
*
* The effect must use standard POSIX.1-2001 error codes for the operation
* completion status.
*
* Use this method only if the effect is provided by a third party, and
* there is no interface defined for it. This method only works for effects
* implemented in software.
*
* @param commandId the ID of the command.
* @param data command data.
* @param resultMaxSize maximum size in bytes of the result; can be 0.
* @return status command completion status.
* @return result result data.
*/
command(uint32_t commandId, vec<uint8_t> data, uint32_t resultMaxSize)
generates (int32_t status, vec<uint8_t> result);
/*
* Set a vendor-specific parameter and apply it immediately. The parameter
* code and data are not interpreted by Android Framework and are passed
* as-is between the application and the effect.
*
* The effect must use INVALID_ARGUMENTS return code if the parameter ID is
* unknown or if provided parameter data is invalid. If the effect does not
* support setting vendor-specific parameters, it must return NOT_SUPPORTED.
*
* Use this method only if the effect is provided by a third party, and
* there is no interface defined for it. This method only works for effects
* implemented in software.
*
* @param parameter identifying data of the parameter.
* @param value the value of the parameter.
* @return retval operation completion status.
*/
@callflow(next={"*"})
setParameter(vec<uint8_t> parameter, vec<uint8_t> value)
generates (Result retval);
/*
* Get a vendor-specific parameter value. The parameter code and returned
* data are not interpreted by Android Framework and are passed as-is
* between the application and the effect.
*
* The effect must use INVALID_ARGUMENTS return code if the parameter ID is
* unknown. If the effect does not support setting vendor-specific
* parameters, it must return NOT_SUPPORTED.
*
* Use this method only if the effect is provided by a third party, and
* there is no interface defined for it. This method only works for effects
* implemented in software.
*
* @param parameter identifying data of the parameter.
* @param valueMaxSize maximum size in bytes of the value.
* @return retval operation completion status.
* @return result the value of the parameter.
*/
@callflow(next={"*"})
getParameter(vec<uint8_t> parameter, uint32_t valueMaxSize)
generates (Result retval, vec<uint8_t> value);
/*
* Get supported configs for a vendor-specific feature. The configs returned
* are not interpreted by Android Framework and are passed as-is between the
* application and the effect.
*
* The effect must use INVALID_ARGUMENTS return code if the feature ID is
* unknown. If the effect does not support getting vendor-specific feature
* configs, it must return NOT_SUPPORTED. If the feature is supported but
* the total number of supported configurations exceeds the maximum number
* indicated by the caller, the method must return RESULT_TOO_BIG.
*
* Use this method only if the effect is provided by a third party, and
* there is no interface defined for it. This method only works for effects
* implemented in software.
*
* @param featureId feature identifier.
* @param maxConfigs maximum number of configs to return.
* @param configSize size of each config in bytes.
* @return retval operation completion status.
* @return configsCount number of configs returned.
* @return configsData data for all the configs returned.
*/
@callflow(next={"*"})
getSupportedConfigsForFeature(
uint32_t featureId,
uint32_t maxConfigs,
uint32_t configSize) generates (
Result retval,
uint32_t configsCount,
vec<uint8_t> configsData);
/*
* Get the current config for a vendor-specific feature. The config returned
* is not interpreted by Android Framework and is passed as-is between the
* application and the effect.
*
* The effect must use INVALID_ARGUMENTS return code if the feature ID is
* unknown. If the effect does not support getting vendor-specific
* feature configs, it must return NOT_SUPPORTED.
*
* Use this method only if the effect is provided by a third party, and
* there is no interface defined for it. This method only works for effects
* implemented in software.
*
* @param featureId feature identifier.
* @param configSize size of the config in bytes.
* @return retval operation completion status.
* @return configData config data.
*/
@callflow(next={"*"})
getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize)
generates (Result retval, vec<uint8_t> configData);
/*
* Set the current config for a vendor-specific feature. The config data
* is not interpreted by Android Framework and is passed as-is between the
* application and the effect.
*
* The effect must use INVALID_ARGUMENTS return code if the feature ID is
* unknown. If the effect does not support getting vendor-specific
* feature configs, it must return NOT_SUPPORTED.
*
* Use this method only if the effect is provided by a third party, and
* there is no interface defined for it. This method only works for effects
* implemented in software.
*
* @param featureId feature identifier.
* @param configData config data.
* @return retval operation completion status.
*/
setCurrentConfigForFeature(uint32_t featureId, vec<uint8_t> configData)
generates (Result retval);
/*
* Called by the framework to deinitialize the effect and free up
* all the currently allocated resources. It is recommended to close
* the effect on the client side as soon as it is becomes unused.
*
* @return retval OK in case the success.
* INVALID_STATE if the effect was already closed.
*/
close() generates (Result retval);
};
|