audio_effect.h 51 KB

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