blob: 854f0c158955cd624e8a128f7b05000219cdaab4 [file] [log] [blame]
Eric Laurentfcc446f2011-05-17 19:24:26 -07001/*
2 * Copyright (C) 2011 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
17
18#ifndef ANDROID_AUDIO_EFFECT_H
19#define ANDROID_AUDIO_EFFECT_H
20
21#include <errno.h>
22#include <stdint.h>
23#include <strings.h>
24#include <sys/cdefs.h>
25#include <sys/types.h>
26
27#include <cutils/bitops.h>
28
29#include <system/audio.h>
30
31
32__BEGIN_DECLS
33
34
35/////////////////////////////////////////////////
36// Common Definitions
37/////////////////////////////////////////////////
38
39//
40//--- Effect descriptor structure effect_descriptor_t
41//
42
43// Unique effect ID (can be generated from the following site:
44// http://www.itu.int/ITU-T/asn1/uuid.html)
45// This format is used for both "type" and "uuid" fields of the effect descriptor structure.
46// - When used for effect type and the engine is implementing and effect corresponding to a standard
47// OpenSL ES interface, this ID must be the one defined in OpenSLES_IID.h for that interface.
48// - When used as uuid, it should be a unique UUID for this particular implementation.
49typedef struct effect_uuid_s {
50 uint32_t timeLow;
51 uint16_t timeMid;
52 uint16_t timeHiAndVersion;
53 uint16_t clockSeq;
54 uint8_t node[6];
55} effect_uuid_t;
56
57// Maximum length of character strings in structures defines by this API.
58#define EFFECT_STRING_LEN_MAX 64
59
60// NULL UUID definition (matches SL_IID_NULL_)
61#define EFFECT_UUID_INITIALIZER { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, \
62 { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } }
63static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER;
Eric Laurent099e6152013-02-07 11:31:48 -080064static const effect_uuid_t * const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_;
65static const char * const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210";
66
Eric Laurentfcc446f2011-05-17 19:24:26 -070067
68// The effect descriptor contains necessary information to facilitate the enumeration of the effect
69// engines present in a library.
70typedef struct effect_descriptor_s {
71 effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect
72 effect_uuid_t uuid; // UUID for this particular implementation
73 uint32_t apiVersion; // Version of the effect control API implemented
74 uint32_t flags; // effect engine capabilities/requirements flags (see below)
75 uint16_t cpuLoad; // CPU load indication (see below)
76 uint16_t memoryUsage; // Data Memory usage (see below)
77 char name[EFFECT_STRING_LEN_MAX]; // human readable effect name
78 char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name
79} effect_descriptor_t;
80
81// CPU load and memory usage indication: each effect implementation must provide an indication of
82// its CPU and memory usage for the audio effect framework to limit the number of effects
83// instantiated at a given time on a given platform.
84// The CPU load is expressed in 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS.
85// The memory usage is expressed in KB and includes only dynamically allocated memory
86
87// Definitions for flags field of effect descriptor.
88// +---------------------------+-----------+-----------------------------------
89// | description | bits | values
90// +---------------------------+-----------+-----------------------------------
Eric Laurentf3008aa2011-06-17 16:53:12 -070091// | connection mode | 0..2 | 0 insert: after track process
Eric Laurentfcc446f2011-05-17 19:24:26 -070092// | | | 1 auxiliary: connect to track auxiliary
93// | | | output and use send level
94// | | | 2 replace: replaces track process function;
95// | | | must implement SRC, volume and mono to stereo.
Eric Laurentf3008aa2011-06-17 16:53:12 -070096// | | | 3 pre processing: applied below audio HAL on input
97// | | | 4 post processing: applied below audio HAL on output
98// | | | 5 - 7 reserved
Eric Laurentfcc446f2011-05-17 19:24:26 -070099// +---------------------------+-----------+-----------------------------------
Eric Laurentf3008aa2011-06-17 16:53:12 -0700100// | insertion preference | 3..5 | 0 none
Eric Laurentfcc446f2011-05-17 19:24:26 -0700101// | | | 1 first of the chain
102// | | | 2 last of the chain
103// | | | 3 exclusive (only effect in the insert chain)
104// | | | 4..7 reserved
105// +---------------------------+-----------+-----------------------------------
Eric Laurentf3008aa2011-06-17 16:53:12 -0700106// | Volume management | 6..8 | 0 none
Eric Laurentfcc446f2011-05-17 19:24:26 -0700107// | | | 1 implements volume control
108// | | | 2 requires volume indication
Eric Laurentf3008aa2011-06-17 16:53:12 -0700109// | | | 4 reserved
Eric Laurentfcc446f2011-05-17 19:24:26 -0700110// +---------------------------+-----------+-----------------------------------
Eric Laurentf3008aa2011-06-17 16:53:12 -0700111// | Device indication | 9..11 | 0 none
Eric Laurentfcc446f2011-05-17 19:24:26 -0700112// | | | 1 requires device updates
Eric Laurentf3008aa2011-06-17 16:53:12 -0700113// | | | 2, 4 reserved
Eric Laurentfcc446f2011-05-17 19:24:26 -0700114// +---------------------------+-----------+-----------------------------------
Eric Laurent922f9e62011-12-19 10:13:28 -0800115// | Sample input mode | 12..13 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG
Eric Laurentfcc446f2011-05-17 19:24:26 -0700116// | | | command must specify a buffer descriptor
Eric Laurentf3008aa2011-06-17 16:53:12 -0700117// | | | 2 provider: process() function uses the
Eric Laurentfcc446f2011-05-17 19:24:26 -0700118// | | | bufferProvider indicated by the
Eric Laurent922f9e62011-12-19 10:13:28 -0800119// | | | EFFECT_CMD_SET_CONFIG command to request input.
Eric Laurentfcc446f2011-05-17 19:24:26 -0700120// | | | buffers.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700121// | | | 3 both: both input modes are supported
Eric Laurentfcc446f2011-05-17 19:24:26 -0700122// +---------------------------+-----------+-----------------------------------
Eric Laurent922f9e62011-12-19 10:13:28 -0800123// | Sample output mode | 14..15 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG
Eric Laurentfcc446f2011-05-17 19:24:26 -0700124// | | | command must specify a buffer descriptor
Eric Laurentf3008aa2011-06-17 16:53:12 -0700125// | | | 2 provider: process() function uses the
Eric Laurentfcc446f2011-05-17 19:24:26 -0700126// | | | bufferProvider indicated by the
Eric Laurent922f9e62011-12-19 10:13:28 -0800127// | | | EFFECT_CMD_SET_CONFIG command to request output
Eric Laurentfcc446f2011-05-17 19:24:26 -0700128// | | | buffers.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700129// | | | 3 both: both output modes are supported
Eric Laurentfcc446f2011-05-17 19:24:26 -0700130// +---------------------------+-----------+-----------------------------------
Eric Laurentf3008aa2011-06-17 16:53:12 -0700131// | Hardware acceleration | 16..17 | 0 No hardware acceleration
Eric Laurentfcc446f2011-05-17 19:24:26 -0700132// | | | 1 non tunneled hw acceleration: the process() function
133// | | | reads the samples, send them to HW accelerated
134// | | | effect processor, reads back the processed samples
135// | | | and returns them to the output buffer.
136// | | | 2 tunneled hw acceleration: the process() function is
137// | | | transparent. The effect interface is only used to
138// | | | control the effect engine. This mode is relevant for
139// | | | global effects actually applied by the audio
140// | | | hardware on the output stream.
141// +---------------------------+-----------+-----------------------------------
Eric Laurentf3008aa2011-06-17 16:53:12 -0700142// | Audio Mode indication | 18..19 | 0 none
Eric Laurentfcc446f2011-05-17 19:24:26 -0700143// | | | 1 requires audio mode updates
144// | | | 2..3 reserved
145// +---------------------------+-----------+-----------------------------------
Eric Laurenta07ef692012-08-31 18:42:35 -0700146// | Audio source indication | 20..21 | 0 none
147// | | | 1 requires audio source updates
148// | | | 2..3 reserved
149// +---------------------------+-----------+-----------------------------------
jpadmana935799d2013-06-25 14:48:49 +0530150// | Effect offload supported | 22 | 0 The effect cannot be offloaded to an audio DSP
151// | | | 1 The effect can be offloaded to an audio DSP
152// +---------------------------+-----------+-----------------------------------
Eric Laurentfcc446f2011-05-17 19:24:26 -0700153
154// Insert mode
Eric Laurentf3008aa2011-06-17 16:53:12 -0700155#define EFFECT_FLAG_TYPE_SHIFT 0
156#define EFFECT_FLAG_TYPE_SIZE 3
157#define EFFECT_FLAG_TYPE_MASK (((1 << EFFECT_FLAG_TYPE_SIZE) -1) \
158 << EFFECT_FLAG_TYPE_SHIFT)
159#define EFFECT_FLAG_TYPE_INSERT (0 << EFFECT_FLAG_TYPE_SHIFT)
160#define EFFECT_FLAG_TYPE_AUXILIARY (1 << EFFECT_FLAG_TYPE_SHIFT)
161#define EFFECT_FLAG_TYPE_REPLACE (2 << EFFECT_FLAG_TYPE_SHIFT)
162#define EFFECT_FLAG_TYPE_PRE_PROC (3 << EFFECT_FLAG_TYPE_SHIFT)
163#define EFFECT_FLAG_TYPE_POST_PROC (4 << EFFECT_FLAG_TYPE_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700164
165// Insert preference
Eric Laurentf3008aa2011-06-17 16:53:12 -0700166#define EFFECT_FLAG_INSERT_SHIFT (EFFECT_FLAG_TYPE_SHIFT + EFFECT_FLAG_TYPE_SIZE)
167#define EFFECT_FLAG_INSERT_SIZE 3
168#define EFFECT_FLAG_INSERT_MASK (((1 << EFFECT_FLAG_INSERT_SIZE) -1) \
169 << EFFECT_FLAG_INSERT_SHIFT)
170#define EFFECT_FLAG_INSERT_ANY (0 << EFFECT_FLAG_INSERT_SHIFT)
171#define EFFECT_FLAG_INSERT_FIRST (1 << EFFECT_FLAG_INSERT_SHIFT)
172#define EFFECT_FLAG_INSERT_LAST (2 << EFFECT_FLAG_INSERT_SHIFT)
173#define EFFECT_FLAG_INSERT_EXCLUSIVE (3 << EFFECT_FLAG_INSERT_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700174
175
176// Volume control
Eric Laurentf3008aa2011-06-17 16:53:12 -0700177#define EFFECT_FLAG_VOLUME_SHIFT (EFFECT_FLAG_INSERT_SHIFT + EFFECT_FLAG_INSERT_SIZE)
178#define EFFECT_FLAG_VOLUME_SIZE 3
179#define EFFECT_FLAG_VOLUME_MASK (((1 << EFFECT_FLAG_VOLUME_SIZE) -1) \
180 << EFFECT_FLAG_VOLUME_SHIFT)
181#define EFFECT_FLAG_VOLUME_CTRL (1 << EFFECT_FLAG_VOLUME_SHIFT)
182#define EFFECT_FLAG_VOLUME_IND (2 << EFFECT_FLAG_VOLUME_SHIFT)
183#define EFFECT_FLAG_VOLUME_NONE (0 << EFFECT_FLAG_VOLUME_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700184
185// Device indication
Eric Laurentf3008aa2011-06-17 16:53:12 -0700186#define EFFECT_FLAG_DEVICE_SHIFT (EFFECT_FLAG_VOLUME_SHIFT + EFFECT_FLAG_VOLUME_SIZE)
187#define EFFECT_FLAG_DEVICE_SIZE 3
188#define EFFECT_FLAG_DEVICE_MASK (((1 << EFFECT_FLAG_DEVICE_SIZE) -1) \
189 << EFFECT_FLAG_DEVICE_SHIFT)
190#define EFFECT_FLAG_DEVICE_IND (1 << EFFECT_FLAG_DEVICE_SHIFT)
191#define EFFECT_FLAG_DEVICE_NONE (0 << EFFECT_FLAG_DEVICE_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700192
193// Sample input modes
Eric Laurentf3008aa2011-06-17 16:53:12 -0700194#define EFFECT_FLAG_INPUT_SHIFT (EFFECT_FLAG_DEVICE_SHIFT + EFFECT_FLAG_DEVICE_SIZE)
195#define EFFECT_FLAG_INPUT_SIZE 2
196#define EFFECT_FLAG_INPUT_MASK (((1 << EFFECT_FLAG_INPUT_SIZE) -1) \
197 << EFFECT_FLAG_INPUT_SHIFT)
198#define EFFECT_FLAG_INPUT_DIRECT (1 << EFFECT_FLAG_INPUT_SHIFT)
199#define EFFECT_FLAG_INPUT_PROVIDER (2 << EFFECT_FLAG_INPUT_SHIFT)
200#define EFFECT_FLAG_INPUT_BOTH (3 << EFFECT_FLAG_INPUT_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700201
202// Sample output modes
Eric Laurentf3008aa2011-06-17 16:53:12 -0700203#define EFFECT_FLAG_OUTPUT_SHIFT (EFFECT_FLAG_INPUT_SHIFT + EFFECT_FLAG_INPUT_SIZE)
204#define EFFECT_FLAG_OUTPUT_SIZE 2
205#define EFFECT_FLAG_OUTPUT_MASK (((1 << EFFECT_FLAG_OUTPUT_SIZE) -1) \
206 << EFFECT_FLAG_OUTPUT_SHIFT)
207#define EFFECT_FLAG_OUTPUT_DIRECT (1 << EFFECT_FLAG_OUTPUT_SHIFT)
208#define EFFECT_FLAG_OUTPUT_PROVIDER (2 << EFFECT_FLAG_OUTPUT_SHIFT)
209#define EFFECT_FLAG_OUTPUT_BOTH (3 << EFFECT_FLAG_OUTPUT_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700210
211// Hardware acceleration mode
Eric Laurentf3008aa2011-06-17 16:53:12 -0700212#define EFFECT_FLAG_HW_ACC_SHIFT (EFFECT_FLAG_OUTPUT_SHIFT + EFFECT_FLAG_OUTPUT_SIZE)
213#define EFFECT_FLAG_HW_ACC_SIZE 2
214#define EFFECT_FLAG_HW_ACC_MASK (((1 << EFFECT_FLAG_HW_ACC_SIZE) -1) \
215 << EFFECT_FLAG_HW_ACC_SHIFT)
216#define EFFECT_FLAG_HW_ACC_SIMPLE (1 << EFFECT_FLAG_HW_ACC_SHIFT)
217#define EFFECT_FLAG_HW_ACC_TUNNEL (2 << EFFECT_FLAG_HW_ACC_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700218
219// Audio mode indication
Eric Laurentf3008aa2011-06-17 16:53:12 -0700220#define EFFECT_FLAG_AUDIO_MODE_SHIFT (EFFECT_FLAG_HW_ACC_SHIFT + EFFECT_FLAG_HW_ACC_SIZE)
221#define EFFECT_FLAG_AUDIO_MODE_SIZE 2
222#define EFFECT_FLAG_AUDIO_MODE_MASK (((1 << EFFECT_FLAG_AUDIO_MODE_SIZE) -1) \
223 << EFFECT_FLAG_AUDIO_MODE_SHIFT)
224#define EFFECT_FLAG_AUDIO_MODE_IND (1 << EFFECT_FLAG_AUDIO_MODE_SHIFT)
225#define EFFECT_FLAG_AUDIO_MODE_NONE (0 << EFFECT_FLAG_AUDIO_MODE_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700226
Eric Laurenta07ef692012-08-31 18:42:35 -0700227// Audio source indication
228#define EFFECT_FLAG_AUDIO_SOURCE_SHIFT (EFFECT_FLAG_AUDIO_MODE_SHIFT + EFFECT_FLAG_AUDIO_MODE_SIZE)
229#define EFFECT_FLAG_AUDIO_SOURCE_SIZE 2
230#define EFFECT_FLAG_AUDIO_SOURCE_MASK (((1 << EFFECT_FLAG_AUDIO_SOURCE_SIZE) -1) \
231 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT)
232#define EFFECT_FLAG_AUDIO_SOURCE_IND (1 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT)
233#define EFFECT_FLAG_AUDIO_SOURCE_NONE (0 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700234
jpadmana935799d2013-06-25 14:48:49 +0530235// Effect offload indication
236#define EFFECT_FLAG_OFFLOAD_SHIFT (EFFECT_FLAG_AUDIO_SOURCE_SHIFT + \
237 EFFECT_FLAG_AUDIO_SOURCE_SIZE)
238#define EFFECT_FLAG_OFFLOAD_SIZE 1
239#define EFFECT_FLAG_OFFLOAD_MASK (((1 << EFFECT_FLAG_OFFLOAD_SIZE) -1) \
240 << EFFECT_FLAG_OFFLOAD_SHIFT)
241#define EFFECT_FLAG_OFFLOAD_SUPPORTED (1 << EFFECT_FLAG_OFFLOAD_SHIFT)
242
Eric Laurentfcc446f2011-05-17 19:24:26 -0700243#define EFFECT_MAKE_API_VERSION(M, m) (((M)<<16) | ((m) & 0xFFFF))
244#define EFFECT_API_VERSION_MAJOR(v) ((v)>>16)
245#define EFFECT_API_VERSION_MINOR(v) ((m) & 0xFFFF)
246
247
248
249/////////////////////////////////////////////////
250// Effect control interface
251/////////////////////////////////////////////////
252
253// Effect control interface version 2.0
254#define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0)
255
Eric Laurentf3008aa2011-06-17 16:53:12 -0700256// Effect control interface structure: effect_interface_s
Eric Laurentfcc446f2011-05-17 19:24:26 -0700257// The effect control interface is exposed by each effect engine implementation. It consists of
258// a set of functions controlling the configuration, activation and process of the engine.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700259// The functions are grouped in a structure of type effect_interface_s.
260//
261// Effect control interface handle: effect_handle_t
Eric Laurentfcc446f2011-05-17 19:24:26 -0700262// The effect_handle_t serves two purposes regarding the implementation of the effect engine:
263// - 1 it is the address of a pointer to an effect_interface_s structure where the functions
264// of the effect control API for a particular effect are located.
265// - 2 it is the address of the context of a particular effect instance.
266// A typical implementation in the effect library would define a structure as follows:
267// struct effect_module_s {
268// const struct effect_interface_s *itfe;
269// effect_config_t config;
270// effect_context_t context;
271// }
272// The implementation of EffectCreate() function would then allocate a structure of this
273// type and return its address as effect_handle_t
274typedef struct effect_interface_s **effect_handle_t;
275
276
277// Forward definition of type audio_buffer_t
278typedef struct audio_buffer_s audio_buffer_t;
279
Eric Laurentfcc446f2011-05-17 19:24:26 -0700280
281
Eric Laurentf3008aa2011-06-17 16:53:12 -0700282
283
Eric Laurentfcc446f2011-05-17 19:24:26 -0700284
285// Effect control interface definition
286struct effect_interface_s {
Eric Laurentf3008aa2011-06-17 16:53:12 -0700287 ////////////////////////////////////////////////////////////////////////////////
288 //
289 // Function: process
290 //
291 // Description: Effect process function. Takes input samples as specified
292 // (count and location) in input buffer descriptor and output processed
293 // samples as specified in output buffer descriptor. If the buffer descriptor
294 // is not specified the function must use either the buffer or the
Eric Laurent922f9e62011-12-19 10:13:28 -0800295 // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700296 // The effect framework will call the process() function after the EFFECT_CMD_ENABLE
297 // command is received and until the EFFECT_CMD_DISABLE is received. When the engine
298 // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully
299 // and when done indicate that it is OK to stop calling the process() function by
300 // returning the -ENODATA status.
301 //
302 // NOTE: the process() function implementation should be "real-time safe" that is
303 // it should not perform blocking calls: malloc/free, sleep, read/write/open/close,
304 // pthread_cond_wait/pthread_mutex_lock...
305 //
306 // Input:
307 // self: handle to the effect interface this function
308 // is called on.
309 // inBuffer: buffer descriptor indicating where to read samples to process.
Eric Laurent922f9e62011-12-19 10:13:28 -0800310 // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700311 //
312 // outBuffer: buffer descriptor indicating where to write processed samples.
Eric Laurent922f9e62011-12-19 10:13:28 -0800313 // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700314 //
315 // Output:
316 // returned value: 0 successful operation
317 // -ENODATA the engine has finished the disable phase and the framework
318 // can stop calling process()
319 // -EINVAL invalid interface handle or
320 // invalid input/output buffer description
321 ////////////////////////////////////////////////////////////////////////////////
322 int32_t (*process)(effect_handle_t self,
323 audio_buffer_t *inBuffer,
324 audio_buffer_t *outBuffer);
325 ////////////////////////////////////////////////////////////////////////////////
326 //
327 // Function: command
328 //
329 // Description: Send a command and receive a response to/from effect engine.
330 //
331 // Input:
332 // self: handle to the effect interface this function
333 // is called on.
334 // cmdCode: command code: the command can be a standardized command defined in
335 // effect_command_e (see below) or a proprietary command.
336 // cmdSize: size of command in bytes
337 // pCmdData: pointer to command data
338 // pReplyData: pointer to reply data
339 //
340 // Input/Output:
341 // replySize: maximum size of reply data as input
342 // actual size of reply data as output
343 //
344 // Output:
345 // returned value: 0 successful operation
346 // -EINVAL invalid interface handle or
Glenn Kasten6b6f19d2014-12-30 08:32:04 -0800347 // invalid command/reply size or format according to
348 // command code
349 // The return code should be restricted to indicate problems related to this API
350 // specification. Status related to the execution of a particular command should be
Eric Laurentf3008aa2011-06-17 16:53:12 -0700351 // indicated as part of the reply field.
352 //
353 // *pReplyData updated with command response
354 //
355 ////////////////////////////////////////////////////////////////////////////////
356 int32_t (*command)(effect_handle_t self,
357 uint32_t cmdCode,
358 uint32_t cmdSize,
359 void *pCmdData,
360 uint32_t *replySize,
361 void *pReplyData);
362 ////////////////////////////////////////////////////////////////////////////////
363 //
364 // Function: get_descriptor
365 //
366 // Description: Returns the effect descriptor
367 //
368 // Input:
369 // self: handle to the effect interface this function
370 // is called on.
371 //
372 // Input/Output:
373 // pDescriptor: address where to return the effect descriptor.
374 //
375 // Output:
376 // returned value: 0 successful operation.
377 // -EINVAL invalid interface handle or invalid pDescriptor
378 // *pDescriptor: updated with the effect descriptor.
379 //
380 ////////////////////////////////////////////////////////////////////////////////
381 int32_t (*get_descriptor)(effect_handle_t self,
382 effect_descriptor_t *pDescriptor);
383 ////////////////////////////////////////////////////////////////////////////////
384 //
385 // Function: process_reverse
386 //
387 // Description: Process reverse stream function. This function is used to pass
388 // a reference stream to the effect engine. If the engine does not need a reference
389 // stream, this function pointer can be set to NULL.
390 // This function would typically implemented by an Echo Canceler.
391 //
392 // Input:
393 // self: handle to the effect interface this function
394 // is called on.
395 // inBuffer: buffer descriptor indicating where to read samples to process.
Eric Laurent922f9e62011-12-19 10:13:28 -0800396 // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700397 //
398 // outBuffer: buffer descriptor indicating where to write processed samples.
Eric Laurent922f9e62011-12-19 10:13:28 -0800399 // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700400 // If the buffer and buffer provider in the configuration received by
Eric Laurent922f9e62011-12-19 10:13:28 -0800401 // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse
Eric Laurentf3008aa2011-06-17 16:53:12 -0700402 // stream data
403 //
404 // Output:
405 // returned value: 0 successful operation
406 // -ENODATA the engine has finished the disable phase and the framework
407 // can stop calling process_reverse()
408 // -EINVAL invalid interface handle or
409 // invalid input/output buffer description
410 ////////////////////////////////////////////////////////////////////////////////
411 int32_t (*process_reverse)(effect_handle_t self,
412 audio_buffer_t *inBuffer,
413 audio_buffer_t *outBuffer);
Eric Laurentfcc446f2011-05-17 19:24:26 -0700414};
415
416
417//
418//--- Standardized command codes for command() function
419//
420enum effect_command_e {
421 EFFECT_CMD_INIT, // initialize effect engine
Eric Laurent922f9e62011-12-19 10:13:28 -0800422 EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700423 EFFECT_CMD_RESET, // reset effect engine
424 EFFECT_CMD_ENABLE, // enable effect process
425 EFFECT_CMD_DISABLE, // disable effect process
426 EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t)
427 EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred
428 EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred
429 EFFECT_CMD_GET_PARAM, // get parameter
430 EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t)
431 EFFECT_CMD_SET_VOLUME, // set volume
432 EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...)
Eric Laurent922f9e62011-12-19 10:13:28 -0800433 EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t)
Eric Laurentf3008aa2011-06-17 16:53:12 -0700434 EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t)
Eric Laurent922f9e62011-12-19 10:13:28 -0800435 EFFECT_CMD_GET_CONFIG, // read effect engine configuration
436 EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration
Eric Laurent66861e32011-12-20 17:40:51 -0800437 EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,// get all supported configurations for a feature.
438 EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration
439 EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration
Eric Laurenta07ef692012-08-31 18:42:35 -0700440 EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t)
jpadmana935799d2013-06-25 14:48:49 +0530441 EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one,
442 // send the ioHandle of the effect thread
Eric Laurentfcc446f2011-05-17 19:24:26 -0700443 EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code
444};
445
446//==================================================================================================
447// command: EFFECT_CMD_INIT
448//--------------------------------------------------------------------------------------------------
449// description:
450// Initialize effect engine: All configurations return to default
451//--------------------------------------------------------------------------------------------------
452// command format:
453// size: 0
454// data: N/A
455//--------------------------------------------------------------------------------------------------
456// reply format:
457// size: sizeof(int)
458// data: status
459//==================================================================================================
Eric Laurent922f9e62011-12-19 10:13:28 -0800460// command: EFFECT_CMD_SET_CONFIG
Eric Laurentfcc446f2011-05-17 19:24:26 -0700461//--------------------------------------------------------------------------------------------------
462// description:
463// Apply new audio parameters configurations for input and output buffers
464//--------------------------------------------------------------------------------------------------
465// command format:
466// size: sizeof(effect_config_t)
467// data: effect_config_t
468//--------------------------------------------------------------------------------------------------
469// reply format:
470// size: sizeof(int)
471// data: status
472//==================================================================================================
473// command: EFFECT_CMD_RESET
474//--------------------------------------------------------------------------------------------------
475// description:
476// Reset the effect engine. Keep configuration but resets state and buffer content
477//--------------------------------------------------------------------------------------------------
478// command format:
479// size: 0
480// data: N/A
481//--------------------------------------------------------------------------------------------------
482// reply format:
483// size: 0
484// data: N/A
485//==================================================================================================
486// command: EFFECT_CMD_ENABLE
487//--------------------------------------------------------------------------------------------------
488// description:
489// Enable the process. Called by the framework before the first call to process()
490//--------------------------------------------------------------------------------------------------
491// command format:
492// size: 0
493// data: N/A
494//--------------------------------------------------------------------------------------------------
495// reply format:
496// size: sizeof(int)
497// data: status
498//==================================================================================================
499// command: EFFECT_CMD_DISABLE
500//--------------------------------------------------------------------------------------------------
501// description:
502// Disable the process. Called by the framework after the last call to process()
503//--------------------------------------------------------------------------------------------------
504// command format:
505// size: 0
506// data: N/A
507//--------------------------------------------------------------------------------------------------
508// reply format:
509// size: sizeof(int)
510// data: status
511//==================================================================================================
512// command: EFFECT_CMD_SET_PARAM
513//--------------------------------------------------------------------------------------------------
514// description:
515// Set a parameter and apply it immediately
516//--------------------------------------------------------------------------------------------------
517// command format:
518// size: sizeof(effect_param_t) + size of param and value
519// data: effect_param_t + param + value. See effect_param_t definition below for value offset
520//--------------------------------------------------------------------------------------------------
521// reply format:
522// size: sizeof(int)
523// data: status
524//==================================================================================================
525// command: EFFECT_CMD_SET_PARAM_DEFERRED
526//--------------------------------------------------------------------------------------------------
527// description:
528// Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command
529//--------------------------------------------------------------------------------------------------
530// command format:
531// size: sizeof(effect_param_t) + size of param and value
532// data: effect_param_t + param + value. See effect_param_t definition below for value offset
533//--------------------------------------------------------------------------------------------------
534// reply format:
535// size: 0
536// data: N/A
537//==================================================================================================
538// command: EFFECT_CMD_SET_PARAM_COMMIT
539//--------------------------------------------------------------------------------------------------
540// description:
541// Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands
542//--------------------------------------------------------------------------------------------------
543// command format:
544// size: 0
545// data: N/A
546//--------------------------------------------------------------------------------------------------
547// reply format:
548// size: sizeof(int)
549// data: status
550//==================================================================================================
551// command: EFFECT_CMD_GET_PARAM
552//--------------------------------------------------------------------------------------------------
553// description:
554// Get a parameter value
555//--------------------------------------------------------------------------------------------------
556// command format:
557// size: sizeof(effect_param_t) + size of param
558// data: effect_param_t + param
559//--------------------------------------------------------------------------------------------------
560// reply format:
561// size: sizeof(effect_param_t) + size of param and value
562// data: effect_param_t + param + value. See effect_param_t definition below for value offset
563//==================================================================================================
564// command: EFFECT_CMD_SET_DEVICE
565//--------------------------------------------------------------------------------------------------
566// description:
567// Set the rendering device the audio output path is connected to. See audio.h, audio_devices_t
568// for device values.
569// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this
570// command when the device changes
571//--------------------------------------------------------------------------------------------------
572// command format:
573// size: sizeof(uint32_t)
574// data: uint32_t
575//--------------------------------------------------------------------------------------------------
576// reply format:
577// size: 0
578// data: N/A
579//==================================================================================================
580// command: EFFECT_CMD_SET_VOLUME
581//--------------------------------------------------------------------------------------------------
582// description:
583// Set and get volume. Used by audio framework to delegate volume control to effect engine.
584// The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in
585// its descriptor to receive this command before every call to process() function
586// If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return
587// the volume that should be applied before the effect is processed. The overall volume (the volume
588// actually applied by the effect engine multiplied by the returned value) should match the value
589// indicated in the command.
590//--------------------------------------------------------------------------------------------------
591// command format:
592// size: n * sizeof(uint32_t)
593// data: volume for each channel defined in effect_config_t for output buffer expressed in
594// 8.24 fixed point format
595//--------------------------------------------------------------------------------------------------
596// reply format:
597// size: n * sizeof(uint32_t) / 0
598// data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor:
599// volume for each channel defined in effect_config_t for output buffer expressed in
600// 8.24 fixed point format
601// - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor:
602// N/A
603// It is legal to receive a null pointer as pReplyData in which case the effect framework has
604// delegated volume control to another effect
605//==================================================================================================
606// command: EFFECT_CMD_SET_AUDIO_MODE
607//--------------------------------------------------------------------------------------------------
608// description:
609// Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its
610// descriptor to receive this command when the audio mode changes.
611//--------------------------------------------------------------------------------------------------
612// command format:
613// size: sizeof(uint32_t)
Eric Laurent66861e32011-12-20 17:40:51 -0800614// data: audio_mode_t
Eric Laurentfcc446f2011-05-17 19:24:26 -0700615//--------------------------------------------------------------------------------------------------
616// reply format:
617// size: 0
618// data: N/A
619//==================================================================================================
Eric Laurent922f9e62011-12-19 10:13:28 -0800620// command: EFFECT_CMD_SET_CONFIG_REVERSE
Eric Laurentf3008aa2011-06-17 16:53:12 -0700621//--------------------------------------------------------------------------------------------------
622// description:
Eric Laurent922f9e62011-12-19 10:13:28 -0800623// Apply new audio parameters configurations for input and output buffers of reverse stream.
624// An example of reverse stream is the echo reference supplied to an Acoustic Echo Canceler.
Eric Laurentf3008aa2011-06-17 16:53:12 -0700625//--------------------------------------------------------------------------------------------------
626// command format:
627// size: sizeof(effect_config_t)
628// data: effect_config_t
629//--------------------------------------------------------------------------------------------------
630// reply format:
631// size: sizeof(int)
632// data: status
633//==================================================================================================
634// command: EFFECT_CMD_SET_INPUT_DEVICE
635//--------------------------------------------------------------------------------------------------
636// description:
637// Set the capture device the audio input path is connected to. See audio.h, audio_devices_t
638// for device values.
639// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this
640// command when the device changes
641//--------------------------------------------------------------------------------------------------
642// command format:
643// size: sizeof(uint32_t)
644// data: uint32_t
645//--------------------------------------------------------------------------------------------------
646// reply format:
647// size: 0
648// data: N/A
649//==================================================================================================
Eric Laurent922f9e62011-12-19 10:13:28 -0800650// command: EFFECT_CMD_GET_CONFIG
651//--------------------------------------------------------------------------------------------------
652// description:
653// Read audio parameters configurations for input and output buffers
654//--------------------------------------------------------------------------------------------------
655// command format:
656// size: 0
657// data: N/A
658//--------------------------------------------------------------------------------------------------
659// reply format:
660// size: sizeof(effect_config_t)
661// data: effect_config_t
662//==================================================================================================
663// command: EFFECT_CMD_GET_CONFIG_REVERSE
664//--------------------------------------------------------------------------------------------------
665// description:
666// Read audio parameters configurations for input and output buffers of reverse stream
667//--------------------------------------------------------------------------------------------------
668// command format:
669// size: 0
670// data: N/A
671//--------------------------------------------------------------------------------------------------
672// reply format:
673// size: sizeof(effect_config_t)
674// data: effect_config_t
675//==================================================================================================
Eric Laurent66861e32011-12-20 17:40:51 -0800676// command: EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS
677//--------------------------------------------------------------------------------------------------
678// description:
679// Queries for supported configurations for a particular feature (e.g. get the supported
680// combinations of main and auxiliary channels for a noise suppressor).
681// The command parameter is the feature identifier (See effect_feature_e for a list of defined
682// features) followed by the maximum number of configuration descriptor to return.
683// The reply is composed of:
684// - status (uint32_t):
685// - 0 if feature is supported
686// - -ENOSYS if the feature is not supported,
687// - -ENOMEM if the feature is supported but the total number of supported configurations
688// exceeds the maximum number indicated by the caller.
689// - total number of supported configurations (uint32_t)
690// - an array of configuration descriptors.
691// The actual number of descriptors returned must not exceed the maximum number indicated by
692// the caller.
693//--------------------------------------------------------------------------------------------------
694// command format:
695// size: 2 x sizeof(uint32_t)
696// data: effect_feature_e + maximum number of configurations to return
697//--------------------------------------------------------------------------------------------------
698// reply format:
699// size: 2 x sizeof(uint32_t) + n x sizeof (<config descriptor>)
700// data: status + total number of configurations supported + array of n config descriptors
701//==================================================================================================
702// command: EFFECT_CMD_GET_FEATURE_CONFIG
703//--------------------------------------------------------------------------------------------------
704// description:
705// Retrieves current configuration for a given feature.
706// The reply status is:
707// - 0 if feature is supported
708// - -ENOSYS if the feature is not supported,
709//--------------------------------------------------------------------------------------------------
710// command format:
711// size: sizeof(uint32_t)
712// data: effect_feature_e
713//--------------------------------------------------------------------------------------------------
714// reply format:
715// size: sizeof(uint32_t) + sizeof (<config descriptor>)
716// data: status + config descriptor
717//==================================================================================================
718// command: EFFECT_CMD_SET_FEATURE_CONFIG
719//--------------------------------------------------------------------------------------------------
720// description:
721// Sets current configuration for a given feature.
722// The reply status is:
723// - 0 if feature is supported
724// - -ENOSYS if the feature is not supported,
725// - -EINVAL if the configuration is invalid
726//--------------------------------------------------------------------------------------------------
727// command format:
728// size: sizeof(uint32_t) + sizeof (<config descriptor>)
729// data: effect_feature_e + config descriptor
730//--------------------------------------------------------------------------------------------------
731// reply format:
732// size: sizeof(uint32_t)
733// data: status
734//==================================================================================================
Eric Laurenta07ef692012-08-31 18:42:35 -0700735// command: EFFECT_CMD_SET_AUDIO_SOURCE
736//--------------------------------------------------------------------------------------------------
737// description:
738// Set the audio source the capture path is configured for (Camcorder, voice recognition...).
739// See audio.h, audio_source_t for values.
740//--------------------------------------------------------------------------------------------------
741// command format:
742// size: sizeof(uint32_t)
743// data: uint32_t
744//--------------------------------------------------------------------------------------------------
745// reply format:
746// size: 0
747// data: N/A
748//==================================================================================================
jpadmana935799d2013-06-25 14:48:49 +0530749// command: EFFECT_CMD_OFFLOAD
750//--------------------------------------------------------------------------------------------------
751// description:
752// 1.indicate if the playback thread the effect is attached to is offloaded or not
753// 2.update the io handle of the playback thread the effect is attached to
754//--------------------------------------------------------------------------------------------------
755// command format:
756// size: sizeof(effect_offload_param_t)
757// data: effect_offload_param_t
758//--------------------------------------------------------------------------------------------------
759// reply format:
760// size: sizeof(uint32_t)
761// data: uint32_t
762//--------------------------------------------------------------------------------------------------
Eric Laurentfcc446f2011-05-17 19:24:26 -0700763// command: EFFECT_CMD_FIRST_PROPRIETARY
764//--------------------------------------------------------------------------------------------------
765// description:
766// All proprietary effect commands must use command codes above this value. The size and format of
767// command and response fields is free in this case
768//==================================================================================================
769
770
771// Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t
772// structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with
Jean-Michel Trivia9a5f5d2012-03-05 11:44:30 -0800773// regard to the channel mask definition in audio.h, audio_channel_mask_t e.g :
Eric Laurentfcc446f2011-05-17 19:24:26 -0700774// Stereo: left, right
775// 5 point 1: front left, front right, front center, low frequency, back left, back right
776// The buffer size is expressed in frame count, a frame being composed of samples for all
777// channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by
778// definition
779struct audio_buffer_s {
780 size_t frameCount; // number of frames in buffer
781 union {
782 void* raw; // raw pointer to start of buffer
783 int32_t* s32; // pointer to signed 32 bit data at start of buffer
784 int16_t* s16; // pointer to signed 16 bit data at start of buffer
785 uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer
786 };
787};
788
789// The buffer_provider_s structure contains functions that can be used
790// by the effect engine process() function to query and release input
791// or output audio buffer.
792// The getBuffer() function is called to retrieve a buffer where data
793// should read from or written to by process() function.
794// The releaseBuffer() function MUST be called when the buffer retrieved
795// with getBuffer() is not needed anymore.
796// The process function should use the buffer provider mechanism to retrieve
797// input or output buffer if the inBuffer or outBuffer passed as argument is NULL
Eric Laurent922f9e62011-12-19 10:13:28 -0800798// and the buffer configuration (buffer_config_t) given by the EFFECT_CMD_SET_CONFIG
Eric Laurentfcc446f2011-05-17 19:24:26 -0700799// command did not specify an audio buffer.
800
801typedef int32_t (* buffer_function_t)(void *cookie, audio_buffer_t *buffer);
802
803typedef struct buffer_provider_s {
804 buffer_function_t getBuffer; // retrieve next buffer
805 buffer_function_t releaseBuffer; // release used buffer
806 void *cookie; // for use by client of buffer provider functions
807} buffer_provider_t;
808
809
810// The buffer_config_s structure specifies the input or output audio format
811// to be used by the effect engine. It is part of the effect_config_t
812// structure that defines both input and output buffer configurations and is
Eric Laurent922f9e62011-12-19 10:13:28 -0800813// passed by the EFFECT_CMD_SET_CONFIG or EFFECT_CMD_SET_CONFIG_REVERSE command.
Eric Laurentfcc446f2011-05-17 19:24:26 -0700814typedef struct buffer_config_s {
815 audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly
816 uint32_t samplingRate; // sampling rate
Jean-Michel Trivia9a5f5d2012-03-05 11:44:30 -0800817 uint32_t channels; // channel mask (see audio_channel_mask_t in audio.h)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700818 buffer_provider_t bufferProvider; // buffer provider
Glenn Kasten6367c2c2013-07-30 10:06:38 -0700819 uint8_t format; // Audio format (see audio_format_t in audio.h)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700820 uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e)
821 uint16_t mask; // indicates which of the above fields is valid
822} buffer_config_t;
823
824// Values for "accessMode" field of buffer_config_t:
825// overwrite, read only, accumulate (read/modify/write)
826enum effect_buffer_access_e {
827 EFFECT_BUFFER_ACCESS_WRITE,
828 EFFECT_BUFFER_ACCESS_READ,
829 EFFECT_BUFFER_ACCESS_ACCUMULATE
830
831};
832
Eric Laurent66861e32011-12-20 17:40:51 -0800833// feature identifiers for EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS command
834enum effect_feature_e {
835 EFFECT_FEATURE_AUX_CHANNELS, // supports auxiliary channels (e.g. dual mic noise suppressor)
836 EFFECT_FEATURE_CNT
837};
838
839// EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combination
840// of main and auxiliary channels supported
841typedef struct channel_config_s {
Glenn Kastena6354492012-06-19 12:16:04 -0700842 audio_channel_mask_t main_channels; // channel mask for main channels
843 audio_channel_mask_t aux_channels; // channel mask for auxiliary channels
Eric Laurent66861e32011-12-20 17:40:51 -0800844} channel_config_t;
845
846
Eric Laurentfcc446f2011-05-17 19:24:26 -0700847// Values for bit field "mask" in buffer_config_t. If a bit is set, the corresponding field
Eric Laurent922f9e62011-12-19 10:13:28 -0800848// in buffer_config_t must be taken into account when executing the EFFECT_CMD_SET_CONFIG command
Eric Laurentfcc446f2011-05-17 19:24:26 -0700849#define EFFECT_CONFIG_BUFFER 0x0001 // buffer field must be taken into account
850#define EFFECT_CONFIG_SMP_RATE 0x0002 // samplingRate field must be taken into account
851#define EFFECT_CONFIG_CHANNELS 0x0004 // channels field must be taken into account
852#define EFFECT_CONFIG_FORMAT 0x0008 // format field must be taken into account
853#define EFFECT_CONFIG_ACC_MODE 0x0010 // accessMode field must be taken into account
854#define EFFECT_CONFIG_PROVIDER 0x0020 // bufferProvider field must be taken into account
855#define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | EFFECT_CONFIG_SMP_RATE | \
856 EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT | \
857 EFFECT_CONFIG_ACC_MODE | EFFECT_CONFIG_PROVIDER)
858
859
Eric Laurent922f9e62011-12-19 10:13:28 -0800860// effect_config_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_CONFIG
Eric Laurentfcc446f2011-05-17 19:24:26 -0700861// command to configure audio parameters and buffers for effect engine input and output.
862typedef struct effect_config_s {
863 buffer_config_t inputCfg;
Eric Laurentf3008aa2011-06-17 16:53:12 -0700864 buffer_config_t outputCfg;
Eric Laurentfcc446f2011-05-17 19:24:26 -0700865} effect_config_t;
866
867
868// effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM
869// command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command.
870// psize and vsize represent the actual size of parameter and value.
871//
872// NOTE: the start of value field inside the data field is always on a 32 bit boundary:
873//
874// +-----------+
875// | status | sizeof(int)
876// +-----------+
877// | psize | sizeof(int)
878// +-----------+
879// | vsize | sizeof(int)
880// +-----------+
881// | | | |
882// ~ parameter ~ > psize |
883// | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int)
884// +-----------+ |
885// | padding | |
886// +-----------+
887// | | |
888// ~ value ~ > vsize
889// | | |
890// +-----------+
891
892typedef struct effect_param_s {
893 int32_t status; // Transaction status (unused for command, used for reply)
894 uint32_t psize; // Parameter size
895 uint32_t vsize; // Value size
896 char data[]; // Start of Parameter + Value data
897} effect_param_t;
898
rago8e9ddf62016-11-29 10:29:39 -0800899// Maximum effect_param_t size
900#define EFFECT_PARAM_SIZE_MAX 65536
901
jpadmana935799d2013-06-25 14:48:49 +0530902// structure used by EFFECT_CMD_OFFLOAD command
903typedef struct effect_offload_param_s {
904 bool isOffload; // true if the playback thread the effect is attached to is offloaded
905 int ioHandle; // io handle of the playback thread the effect is attached to
906} effect_offload_param_t;
Eric Laurentfcc446f2011-05-17 19:24:26 -0700907
908
909/////////////////////////////////////////////////
910// Effect library interface
911/////////////////////////////////////////////////
912
Marco Nelissenb0acad32012-10-25 11:03:22 -0700913// Effect library interface version 3.0
914// Note that EffectsFactory.c only checks the major version component, so changes to the minor
915// number can only be used for fully backwards compatible changes
916#define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0)
Eric Laurentfcc446f2011-05-17 19:24:26 -0700917
918#define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T'))
919
920// Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM
921// and the fields of this data structure must begin with audio_effect_library_t
922
923typedef struct audio_effect_library_s {
924 // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG
925 uint32_t tag;
926 // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor
927 uint32_t version;
928 // Name of this library
929 const char *name;
930 // Author/owner/implementor of the library
931 const char *implementor;
932
933 ////////////////////////////////////////////////////////////////////////////////
934 //
Eric Laurentfcc446f2011-05-17 19:24:26 -0700935 // Function: create_effect
936 //
937 // Description: Creates an effect engine of the specified implementation uuid and
938 // returns an effect control interface on this engine. The function will allocate the
939 // resources for an instance of the requested effect engine and return
940 // a handle on the effect control interface.
941 //
942 // Input:
943 // uuid: pointer to the effect uuid.
Glenn Kasten6b6f19d2014-12-30 08:32:04 -0800944 // sessionId: audio session to which this effect instance will be attached.
945 // All effects created with the same session ID are connected in series and process
946 // the same signal stream. Knowing that two effects are part of the same effect
947 // chain can help the library implement some kind of optimizations.
948 // ioId: identifies the output or input stream this effect is directed to in
949 // audio HAL.
Eric Laurentfcc446f2011-05-17 19:24:26 -0700950 // For future use especially with tunneled HW accelerated effects
951 //
952 // Input/Output:
953 // pHandle: address where to return the effect interface handle.
954 //
955 // Output:
956 // returned value: 0 successful operation.
957 // -ENODEV library failed to initialize
958 // -EINVAL invalid pEffectUuid or pHandle
959 // -ENOENT no effect with this uuid found
960 // *pHandle: updated with the effect interface handle.
961 //
962 ////////////////////////////////////////////////////////////////////////////////
Glenn Kasten75a8b8f2012-01-30 11:26:28 -0800963 int32_t (*create_effect)(const effect_uuid_t *uuid,
Eric Laurentfcc446f2011-05-17 19:24:26 -0700964 int32_t sessionId,
965 int32_t ioId,
966 effect_handle_t *pHandle);
967
968 ////////////////////////////////////////////////////////////////////////////////
969 //
970 // Function: release_effect
971 //
972 // Description: Releases the effect engine whose handle is given as argument.
973 // All resources allocated to this particular instance of the effect are
974 // released.
975 //
976 // Input:
977 // handle: handle on the effect interface to be released.
978 //
979 // Output:
980 // returned value: 0 successful operation.
981 // -ENODEV library failed to initialize
982 // -EINVAL invalid interface handle
983 //
984 ////////////////////////////////////////////////////////////////////////////////
985 int32_t (*release_effect)(effect_handle_t handle);
986
987 ////////////////////////////////////////////////////////////////////////////////
988 //
989 // Function: get_descriptor
990 //
991 // Description: Returns the descriptor of the effect engine which implementation UUID is
992 // given as argument.
993 //
994 // Input/Output:
995 // uuid: pointer to the effect uuid.
996 // pDescriptor: address where to return the effect descriptor.
997 //
998 // Output:
999 // returned value: 0 successful operation.
1000 // -ENODEV library failed to initialize
1001 // -EINVAL invalid pDescriptor or uuid
1002 // *pDescriptor: updated with the effect descriptor.
1003 //
1004 ////////////////////////////////////////////////////////////////////////////////
Glenn Kasten75a8b8f2012-01-30 11:26:28 -08001005 int32_t (*get_descriptor)(const effect_uuid_t *uuid,
Eric Laurentfcc446f2011-05-17 19:24:26 -07001006 effect_descriptor_t *pDescriptor);
1007} audio_effect_library_t;
1008
1009// Name of the hal_module_info
1010#define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI
1011
1012// Name of the hal_module_info as a string
1013#define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI"
1014
1015__END_DECLS
1016
1017#endif // ANDROID_AUDIO_EFFECT_H