blob: f1cc79506dfe22ee61edf839caa837e7273d838f [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.
51 */
52 @callflow(next={"*"})
53 reset();
54
55 /*
56 * Enable processing.
57 *
58 * @return retval operation completion status.
59 */
60 @callflow(next={"process"})
61 enable() generates (Result retval);
62
63 /*
64 * Disable processing.
65 *
66 * @return retval operation completion status.
67 */
68 @exit
69 disable() generates (Result retval);
70
71 /*
72 * Set the rendering device the audio output path is connected to. The
73 * effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its
74 * descriptor to receive this command when the device changes.
75 *
76 * @param device output device specification.
77 */
78 @callflow(next={"*"})
79 setDevice(AudioDevice device);
80
81 /*
82 * Set and get volume. Used by audio framework to delegate volume control to
83 * effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_IND
84 * or EFFECT_FLAG_VOLUME_CTRL flag in its descriptor to receive this command
85 * before every call to 'process' function If EFFECT_FLAG_VOLUME_CTRL flag
86 * is set in the effect descriptor, the effect engine must return the volume
87 * that should be applied before the effect is processed. The overall volume
88 * (the volume actually applied by the effect engine multiplied by the
89 * returned value) should match the value indicated in the command.
90 *
91 * @param volumes vector containing volume for each channel defined in
92 * EffectConfig for output buffer expressed in 8.24 fixed
93 * point format.
94 * @return result updated volume values. It is OK to receive an empty vector
95 * as a result in which case the effect framework has
96 * delegated volume control to another effect.
97 */
98 @callflow(next={"*"})
99 setAndGetVolume(vec<int32_t> volumes) generates (vec<int32_t> result);
100
101 /*
102 * Set the audio mode. The effect implementation must set
103 * EFFECT_FLAG_AUDIO_MODE_IND flag in its descriptor to receive this command
104 * when the audio mode changes.
105 *
106 * @param mode desired audio mode.
107 */
108 @callflow(next={"*"})
109 setAudioMode(AudioMode mode);
110
111 /*
112 * Apply new audio parameters configurations for input and output buffers of
113 * reverse stream. An example of reverse stream is the echo reference
114 * supplied to an Acoustic Echo Canceler.
115 *
116 * @param config configuration descriptor.
117 * @param inputBufferProvider optional buffer provider reference.
118 * @param outputBufferProvider optional buffer provider reference.
119 * @return retval operation completion status.
120 */
121 @callflow(next={"*"})
122 setConfigReverse(EffectConfig config,
123 IEffectBufferProviderCallback inputBufferProvider,
124 IEffectBufferProviderCallback outputBufferProvider)
125 generates (Result retval);
126
127 /*
128 * Set the capture device the audio input path is connected to. The effect
129 * implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to
130 * receive this command when the device changes.
131 *
132 * @param device input device specification.
133 */
134 @callflow(next={"*"})
135 setInputDevice(AudioDevice device);
136
137 /*
138 * Read audio parameters configurations for input and output buffers.
139 *
140 * @return config configuration descriptor.
141 */
142 @callflow(next={"*"})
143 getConfig() generates (EffectConfig config);
144
145 /*
146 * Read audio parameters configurations for input and output buffers of
147 * reverse stream.
148 *
149 * @return config configuration descriptor.
150 */
151 @callflow(next={"*"})
152 getConfigReverse() generates (EffectConfig config);
153
154 /*
155 * Queries for supported configurations for a particular feature (e.g. get
156 * the supported combinations of main and auxiliary channels for a noise
157 * suppressor). The command parameter is a list of the feature identifiers.
158 *
159 * @return retval absence of the feature support is indicated using
160 * NOT_SUPPORTED code.
161 * @return result list of configuration descriptors.
162 */
163 @callflow(next={"*"})
164 getFeatureSupportedConfigs(vec<EffectFeature> features)
165 generates (Result retval, vec<EffectFeatureConfig> result);
166
167 /*
168 * Retrieves current configuration for a given feature.
169 *
170 * @return retval absence of the feature support is indicated using
171 * NOT_SUPPORTED code.
172 * @return result configuration descriptor.
173 */
174 @callflow(next={"*"})
175 getFeatureConfig(EffectFeature feature)
176 generates (Result retval, EffectFeatureConfig result);
177
178 /*
179 * Sets current configuration for a given feature.
180 *
181 * @return retval operation completion status.
182 */
183 @callflow(next={"*"})
184 setFeatureConfig(EffectFeatureConfig featureConfig)
185 generates (Result retval);
186
187 /*
188 * Set the audio source the capture path is configured for (Camcorder, voice
189 * recognition...).
190 *
191 * @param source source descriptor.
192 */
193 @callflow(next={"*"})
194 setAudioSource(AudioSource source);
195
196 /*
197 * This command indicates if the playback thread the effect is attached to
198 * is offloaded or not, and updates the I/O handle of the playback thread
199 * the effect is attached to.
200 *
201 * @param param effect offload descriptor.
202 * @return retval operation completion status.
203 */
204 @callflow(next={"*"})
205 offload(EffectOffloadParameter param) generates (Result retval);
206
207 /*
208 * Returns the effect descriptor.
209 *
210 * @return descriptor effect descriptor.
211 */
212 @callflow(next={"*"})
213 getDescriptor() generates (EffectDescriptor descriptor);
214
215 /*
216 * Effect process function. Takes input samples as specified (count and
217 * location) in input buffer and returns processed samples as specified in
218 * output buffer. If the buffer descriptor is empty the function must use
219 * either the buffer or the buffer provider callback installed by the
220 * setConfig command. The effect framework must call the 'process' function
221 * after the 'enable' command is received and until the 'disable' is
222 * received. When the engine receives the 'disable' command it should turn
223 * off the effect gracefully and when done indicate that it is OK to stop
224 * calling the 'process' function by returning the INVALID_STATE status.
225 *
226 * @param inBuffer input audio buffer.
227 * @return retval operation completion status.
228 * @return outBuffer output audio buffer.
229 */
230 // TODO(mnaganov): replace with FMQ version.
231 @callflow(next={"*"})
232 process(AudioBuffer inBuffer)
233 generates (Result retval, AudioBuffer outBuffer);
234
235 /*
236 * Process reverse stream function. This function is used to pass a
237 * reference stream to the effect engine. If the engine does not need a
238 * reference stream, this function MUST return NOT_SUPPORTED. For example,
239 * this function would typically implemented by an Echo Canceler.
240 *
241 * @param inBuffer input audio buffer.
242 * @return retval operation completion status.
243 * @return outBuffer output audio buffer.
244 */
245 // TODO(mnaganov): replace with FMQ version.
246 @callflow(next={"*"})
247 processReverse(AudioBuffer inBuffer)
248 generates (Result retval, AudioBuffer outBuffer);
249
250 /*
251 * Execute a vendor specific command on the effect. The command code
252 * and data, as well as result data are not interpreted by Android
253 * Framework and are passed as-is between the application and the effect.
254 *
255 * The effect must use standard POSIX.1-2001 error codes for the operation
256 * completion status.
257 *
258 * Use this method only if the effect is provided by a third party, and
259 * there is no interface defined for it. This method only works for effects
260 * implemented in software.
261 *
262 * @param commandId the ID of the command.
263 * @param data command data.
264 * @return status command completion status.
265 * @return result result data.
266 */
267 command(uint32_t commandId, vec<uint8_t> data)
268 generates (int32_t status, vec<uint8_t> result);
269
270 /*
271 * Set a vendor-specific parameter and apply it immediately. The parameter
272 * code and data are not interpreted by Android Framework and are passed
273 * as-is between the application and the effect.
274 *
275 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
276 * unknown or if provided parameter data is invalid. If the effect does not
277 * support setting vendor-specific parameters, it must return NOT_SUPPORTED.
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 parameter identifying data of the parameter.
284 * @param value the value of the parameter.
285 * @return retval operation completion status.
286 */
287 @callflow(next={"*"})
288 setParameter(vec<uint8_t> parameter, vec<uint8_t> value)
289 generates (Result retval);
290
291 /*
292 * Get a vendor-specific parameter value. The parameter code and returned
293 * data are not interpreted by Android Framework and are passed as-is
294 * between the application and the effect.
295 *
296 * The effect must use INVALID_ARGUMENTS return code if the parameter ID is
297 * unknown. If the effect does not support setting vendor-specific
298 * parameters, it must return NOT_SUPPORTED.
299 *
300 * Use this method only if the effect is provided by a third party, and
301 * there is no interface defined for it. This method only works for effects
302 * implemented in software.
303 *
304 * @param parameter identifying data of the parameter.
305 * @return retval operation completion status.
306 * @return result the value of the parameter.
307 */
308 @callflow(next={"*"})
309 getParameter(vec<uint8_t> parameter)
310 generates (Result retval, vec<uint8_t> value);
311};