1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
17 package android.hardware.audio.common@2.0;
19 /**
20 *
21 * IDs and Handles
22 *
23 */
25 /**
26 * Handle type for identifying audio sources and sinks.
27 */
28 typedef int32_t AudioIoHandle;
30 /**
31 * Audio hw module handle functions or structures referencing a module.
32 */
33 typedef int32_t AudioModuleHandle;
35 /**
36 * Each port has a unique ID or handle allocated by policy manager.
37 */
38 typedef int32_t AudioPortHandle;
40 /**
41 * Each patch is identified by a handle at the interface used to create that
42 * patch. For instance, when a patch is created by the audio HAL, the HAL
43 * allocates and returns a handle. This handle is unique to a given audio HAL
44 * hardware module. But the same patch receives another system wide unique
45 * handle allocated by the framework. This unique handle is used for all
46 * transactions inside the framework.
47 */
48 typedef int32_t AudioPatchHandle;
50 /**
51 * A HW synchronization source returned by the audio HAL.
52 */
53 typedef uint32_t AudioHwSync;
55 /**
56 * Each port has a unique ID or handle allocated by policy manager.
57 */
58 @export(name="")
59 enum AudioHandleConsts : int32_t {
60 AUDIO_IO_HANDLE_NONE = 0,
61 AUDIO_MODULE_HANDLE_NONE = 0,
62 AUDIO_PORT_HANDLE_NONE = 0,
63 AUDIO_PATCH_HANDLE_NONE = 0,
64 };
66 /**
67 * Commonly used structure for passing unique identifieds (UUID).
68 * For the definition of UUID, refer to ITU-T X.667 spec.
69 */
70 struct Uuid {
71 uint32_t timeLow;
72 uint16_t timeMid;
73 uint16_t versionAndTimeHigh;
74 uint16_t variantAndClockSeqHigh;
75 uint8_t[6] node;
76 };
79 /**
80 *
81 * Audio streams
82 *
83 */
85 /**
86 * Audio stream type describing the intented use case of a stream.
87 */
88 @export(name="audio_stream_type_t", value_prefix="AUDIO_STREAM_")
89 enum AudioStreamType : int32_t {
90 // These values must kept in sync with
91 // frameworks/base/media/java/android/media/AudioSystem.java
92 DEFAULT = -1,
93 MIN = 0,
94 VOICE_CALL = 0,
95 SYSTEM = 1,
96 RING = 2,
97 MUSIC = 3,
98 ALARM = 4,
99 NOTIFICATION = 5,
100 BLUETOOTH_SCO = 6,
101 ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be
102 // routed to speaker
103 DTMF = 8,
104 TTS = 9, // Transmitted Through Speaker. Plays over speaker
105 // only, silent on other devices
106 ACCESSIBILITY = 10, // For accessibility talk back prompts
107 REROUTING = 11, // For dynamic policy output mixes
108 PATCH = 12, // For internal audio flinger tracks. Fixed volume
109 PUBLIC_CNT = ACCESSIBILITY + 1,
110 // Number of streams considered by audio policy for volume and routing
111 FOR_POLICY_CNT = PATCH,
112 CNT = PATCH + 1
113 };
115 @export(name="audio_source_t", value_prefix="AUDIO_SOURCE_")
116 enum AudioSource : int32_t {
117 // These values must kept in sync with
118 // frameworks/base/media/java/android/media/MediaRecorder.java,
119 // frameworks/av/services/audiopolicy/AudioPolicyService.cpp,
120 // system/media/audio_effects/include/audio_effects/audio_effects_conf.h
121 DEFAULT = 0,
122 MIC = 1,
123 VOICE_UPLINK = 2,
124 VOICE_DOWNLINK = 3,
125 VOICE_CALL = 4,
126 CAMCORDER = 5,
127 VOICE_RECOGNITION = 6,
128 VOICE_COMMUNICATION = 7,
129 /**
130 * Source for the mix to be presented remotely. An example of remote
131 * presentation is Wifi Display where a dongle attached to a TV can be used
132 * to play the mix captured by this audio source.
133 */
134 REMOTE_SUBMIX = 8,
135 /**
136 * Source for unprocessed sound. Usage examples include level measurement
137 * and raw signal analysis.
138 */
139 UNPROCESSED = 9,
141 CNT,
142 MAX = CNT - 1,
143 FM_TUNER = 1998,
144 /**
145 * A low-priority, preemptible audio source for for background software
146 * hotword detection. Same tuning as VOICE_RECOGNITION. Used only
147 * internally by the framework.
148 */
149 HOTWORD = 1999
150 };
152 typedef int32_t AudioSession;
153 /**
154 * Special audio session values.
155 */
156 @export(name="audio_session_t", value_prefix="AUDIO_SESSION_")
157 enum AudioSessionConsts : int32_t {
158 /**
159 * Session for effects attached to a particular output stream
160 * (value must be less than 0)
161 */
162 OUTPUT_STAGE = -1,
163 /**
164 * Session for effects applied to output mix. These effects can
165 * be moved by audio policy manager to another output stream
166 * (value must be 0)
167 */
168 OUTPUT_MIX = 0,
169 /**
170 * Application does not specify an explicit session ID to be used, and
171 * requests a new session ID to be allocated. Corresponds to
172 * AudioManager.AUDIO_SESSION_ID_GENERATE and
173 * AudioSystem.AUDIO_SESSION_ALLOCATE.
174 */
175 ALLOCATE = 0,
176 /**
177 * For use with AudioRecord::start(), this indicates no trigger session.
178 * It is also used with output tracks and patch tracks, which never have a
179 * session.
180 */
181 NONE = 0
182 };
184 /**
185 * Audio format is a 32-bit word that consists of:
186 * main format field (upper 8 bits)
187 * sub format field (lower 24 bits).
188 *
189 * The main format indicates the main codec type. The sub format field indicates
190 * options and parameters for each format. The sub format is mainly used for
191 * record to indicate for instance the requested bitrate or profile. It can
192 * also be used for certain formats to give informations not present in the
193 * encoded audio stream (e.g. octet alignement for AMR).
194 */
195 @export(name="audio_format_t", value_prefix="AUDIO_FORMAT_")
196 enum AudioFormat : uint32_t {
197 INVALID = 0xFFFFFFFFUL,
198 DEFAULT = 0,
199 PCM = 0x00000000UL, /** DO NOT CHANGE */
200 MP3 = 0x01000000UL,
201 AMR_NB = 0x02000000UL,
202 AMR_WB = 0x03000000UL,
203 AAC = 0x04000000UL,
204 HE_AAC_V1 = 0x05000000UL, /** Deprecated, Use AAC_HE_V1 */
205 HE_AAC_V2 = 0x06000000UL, /** Deprecated, Use AAC_HE_V2 */
206 VORBIS = 0x07000000UL,
207 OPUS = 0x08000000UL,
208 AC3 = 0x09000000UL,
209 E_AC3 = 0x0A000000UL,
210 DTS = 0x0B000000UL,
211 DTS_HD = 0x0C000000UL,
212 // IEC61937 is encoded audio wrapped in 16-bit PCM.
213 IEC61937 = 0x0D000000UL,
214 DOLBY_TRUEHD = 0x0E000000UL,
215 EVRC = 0x10000000UL,
216 EVRCB = 0x11000000UL,
217 EVRCWB = 0x12000000UL,
218 EVRCNW = 0x13000000UL,
219 AAC_ADIF = 0x14000000UL,
220 WMA = 0x15000000UL,
221 WMA_PRO = 0x16000000UL,
222 AMR_WB_PLUS = 0x17000000UL,
223 MP2 = 0x18000000UL,
224 QCELP = 0x19000000UL,
225 DSD = 0x1A000000UL,
226 FLAC = 0x1B000000UL,
227 ALAC = 0x1C000000UL,
228 APE = 0x1D000000UL,
229 AAC_ADTS = 0x1E000000UL,
230 SBC = 0x1F000000UL,
231 APTX = 0x20000000UL,
232 APTX_HD = 0x21000000UL,
233 AC4 = 0x22000000UL,
234 LDAC = 0x23000000UL,
235 MAIN_MASK = 0xFF000000UL, /** Deprecated */
236 SUB_MASK = 0x00FFFFFFUL,
238 /** Subformats */
239 PCM_SUB_16_BIT = 0x1, // PCM signed 16 bits
240 PCM_SUB_8_BIT = 0x2, // PCM unsigned 8 bits
241 PCM_SUB_32_BIT = 0x3, // PCM signed .31 fixed point
242 PCM_SUB_8_24_BIT = 0x4, // PCM signed 8.23 fixed point
243 PCM_SUB_FLOAT = 0x5, // PCM single-precision float pt
244 PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
246 MP3_SUB_NONE = 0x0,
248 AMR_SUB_NONE = 0x0,
250 AAC_SUB_MAIN = 0x1,
251 AAC_SUB_LC = 0x2,
252 AAC_SUB_SSR = 0x4,
253 AAC_SUB_LTP = 0x8,
254 AAC_SUB_HE_V1 = 0x10,
255 AAC_SUB_SCALABLE = 0x20,
256 AAC_SUB_ERLC = 0x40,
257 AAC_SUB_LD = 0x80,
258 AAC_SUB_HE_V2 = 0x100,
259 AAC_SUB_ELD = 0x200,
261 VORBIS_SUB_NONE = 0x0,
263 /** Aliases */
264 /** note != AudioFormat.ENCODING_PCM_16BIT */
265 PCM_16_BIT = (PCM | PCM_SUB_16_BIT),
266 /** note != AudioFormat.ENCODING_PCM_8BIT */
267 PCM_8_BIT = (PCM | PCM_SUB_8_BIT),
268 PCM_32_BIT = (PCM | PCM_SUB_32_BIT),
269 PCM_8_24_BIT = (PCM | PCM_SUB_8_24_BIT),
270 PCM_FLOAT = (PCM | PCM_SUB_FLOAT),
271 PCM_24_BIT_PACKED = (PCM | PCM_SUB_24_BIT_PACKED),
272 AAC_MAIN = (AAC | AAC_SUB_MAIN),
273 AAC_LC = (AAC | AAC_SUB_LC),
274 AAC_SSR = (AAC | AAC_SUB_SSR),
275 AAC_LTP = (AAC | AAC_SUB_LTP),
276 AAC_HE_V1 = (AAC | AAC_SUB_HE_V1),
277 AAC_SCALABLE = (AAC | AAC_SUB_SCALABLE),
278 AAC_ERLC = (AAC | AAC_SUB_ERLC),
279 AAC_LD = (AAC | AAC_SUB_LD),
280 AAC_HE_V2 = (AAC | AAC_SUB_HE_V2),
281 AAC_ELD = (AAC | AAC_SUB_ELD),
282 AAC_ADTS_MAIN = (AAC_ADTS | AAC_SUB_MAIN),
283 AAC_ADTS_LC = (AAC_ADTS | AAC_SUB_LC),
284 AAC_ADTS_SSR = (AAC_ADTS | AAC_SUB_SSR),
285 AAC_ADTS_LTP = (AAC_ADTS | AAC_SUB_LTP),
286 AAC_ADTS_HE_V1 = (AAC_ADTS | AAC_SUB_HE_V1),
287 AAC_ADTS_SCALABLE = (AAC_ADTS | AAC_SUB_SCALABLE),
288 AAC_ADTS_ERLC = (AAC_ADTS | AAC_SUB_ERLC),
289 AAC_ADTS_LD = (AAC_ADTS | AAC_SUB_LD),
290 AAC_ADTS_HE_V2 = (AAC_ADTS | AAC_SUB_HE_V2),
291 AAC_ADTS_ELD = (AAC_ADTS | AAC_SUB_ELD)
292 };
294 /**
295 * Usage of these values highlights places in the code that use 2- or 8- channel
296 * assumptions.
297 */
298 @export(name="")
299 enum FixedChannelCount : int32_t {
300 FCC_2 = 2, // This is typically due to legacy implementation of stereo I/O
301 FCC_8 = 8 // This is typically due to audio mixer and resampler limitations
302 };
304 /**
305 * A channel mask per se only defines the presence or absence of a channel, not
306 * the order. See AUDIO_INTERLEAVE_* for the platform convention of order.
307 *
308 * AudioChannelMask is an opaque type and its internal layout should not be
309 * assumed as it may change in the future. Instead, always use functions
310 * to examine it.
311 *
312 * These are the current representations:
313 *
314 * REPRESENTATION_POSITION
315 * is a channel mask representation for position assignment. Each low-order
316 * bit corresponds to the spatial position of a transducer (output), or
317 * interpretation of channel (input). The user of a channel mask needs to
318 * know the context of whether it is for output or input. The constants
319 * OUT_* or IN_* apply to the bits portion. It is not permitted for no bits
320 * to be set.
321 *
322 * REPRESENTATION_INDEX
323 * is a channel mask representation for index assignment. Each low-order
324 * bit corresponds to a selected channel. There is no platform
325 * interpretation of the various bits. There is no concept of output or
326 * input. It is not permitted for no bits to be set.
327 *
328 * All other representations are reserved for future use.
329 *
330 * Warning: current representation distinguishes between input and output, but
331 * this will not the be case in future revisions of the platform. Wherever there
332 * is an ambiguity between input and output that is currently resolved by
333 * checking the channel mask, the implementer should look for ways to fix it
334 * with additional information outside of the mask.
335 */
336 @export(name="", value_prefix="AUDIO_CHANNEL_")
337 enum AudioChannelMask : uint32_t {
338 REPRESENTATION_POSITION = 0, /** must be 0 for compatibility */
339 /** 1 is reserved for future use */
340 REPRESENTATION_INDEX = 2,
341 /** 3 is reserved for future use */
343 /** These can be a complete value of AudioChannelMask */
344 NONE = 0x0,
345 INVALID = 0xC0000000,
347 /**
348 * These can be the bits portion of an AudioChannelMask
349 * with representation REPRESENTATION_POSITION.
350 */
352 /** output channels */
353 OUT_FRONT_LEFT = 0x1,
354 OUT_FRONT_RIGHT = 0x2,
355 OUT_FRONT_CENTER = 0x4,
356 OUT_LOW_FREQUENCY = 0x8,
357 OUT_BACK_LEFT = 0x10,
358 OUT_BACK_RIGHT = 0x20,
359 OUT_FRONT_LEFT_OF_CENTER = 0x40,
360 OUT_FRONT_RIGHT_OF_CENTER = 0x80,
361 OUT_BACK_CENTER = 0x100,
362 OUT_SIDE_LEFT = 0x200,
363 OUT_SIDE_RIGHT = 0x400,
364 OUT_TOP_CENTER = 0x800,
365 OUT_TOP_FRONT_LEFT = 0x1000,
366 OUT_TOP_FRONT_CENTER = 0x2000,
367 OUT_TOP_FRONT_RIGHT = 0x4000,
368 OUT_TOP_BACK_LEFT = 0x8000,
369 OUT_TOP_BACK_CENTER = 0x10000,
370 OUT_TOP_BACK_RIGHT = 0x20000,
372 OUT_MONO = OUT_FRONT_LEFT,
373 OUT_STEREO = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT),
374 OUT_2POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY),
375 OUT_QUAD = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
376 OUT_BACK_LEFT | OUT_BACK_RIGHT),
377 OUT_QUAD_BACK = OUT_QUAD,
378 /** like OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
379 OUT_QUAD_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
380 OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
381 OUT_SURROUND = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
382 OUT_FRONT_CENTER | OUT_BACK_CENTER),
383 OUT_PENTA = (OUT_QUAD | OUT_FRONT_CENTER),
384 OUT_5POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
385 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
386 OUT_BACK_LEFT | OUT_BACK_RIGHT),
387 OUT_5POINT1_BACK = OUT_5POINT1,
388 /** like OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
389 OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
390 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
391 OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
392 OUT_6POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
393 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
394 OUT_BACK_LEFT | OUT_BACK_RIGHT |
395 OUT_BACK_CENTER),
396 /** matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND */
397 OUT_7POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
398 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
399 OUT_BACK_LEFT | OUT_BACK_RIGHT |
400 OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
401 OUT_ALL = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
402 OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
403 OUT_BACK_LEFT | OUT_BACK_RIGHT |
404 OUT_FRONT_LEFT_OF_CENTER | OUT_FRONT_RIGHT_OF_CENTER |
405 OUT_BACK_CENTER |
406 OUT_SIDE_LEFT | OUT_SIDE_RIGHT |
407 OUT_TOP_CENTER |
408 OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_CENTER | OUT_TOP_FRONT_RIGHT |
409 OUT_TOP_BACK_LEFT | OUT_TOP_BACK_CENTER | OUT_TOP_BACK_RIGHT),
411 /** These are bits only, not complete values */
413 /** input channels */
414 IN_LEFT = 0x4,
415 IN_RIGHT = 0x8,
416 IN_FRONT = 0x10,
417 IN_BACK = 0x20,
418 IN_LEFT_PROCESSED = 0x40,
419 IN_RIGHT_PROCESSED = 0x80,
420 IN_FRONT_PROCESSED = 0x100,
421 IN_BACK_PROCESSED = 0x200,
422 IN_PRESSURE = 0x400,
423 IN_X_AXIS = 0x800,
424 IN_Y_AXIS = 0x1000,
425 IN_Z_AXIS = 0x2000,
426 IN_VOICE_UPLINK = 0x4000,
427 IN_VOICE_DNLINK = 0x8000,
429 IN_MONO = IN_FRONT,
430 IN_STEREO = (IN_LEFT | IN_RIGHT),
431 IN_FRONT_BACK = (IN_FRONT | IN_BACK),
432 IN_6 = (IN_LEFT | IN_RIGHT |
433 IN_FRONT | IN_BACK |
434 IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED),
435 IN_VOICE_UPLINK_MONO = (IN_VOICE_UPLINK | IN_MONO),
436 IN_VOICE_DNLINK_MONO = (IN_VOICE_DNLINK | IN_MONO),
437 IN_VOICE_CALL_MONO = (IN_VOICE_UPLINK_MONO |
438 IN_VOICE_DNLINK_MONO),
439 IN_ALL = (IN_LEFT | IN_RIGHT | IN_FRONT | IN_BACK|
440 IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED |
441 IN_FRONT_PROCESSED | IN_BACK_PROCESSED|
442 IN_PRESSURE |
443 IN_X_AXIS | IN_Y_AXIS | IN_Z_AXIS |
444 IN_VOICE_UPLINK | IN_VOICE_DNLINK),
446 COUNT_MAX = 30,
447 INDEX_HDR = REPRESENTATION_INDEX << COUNT_MAX,
448 INDEX_MASK_1 = INDEX_HDR | ((1 << 1) - 1),
449 INDEX_MASK_2 = INDEX_HDR | ((1 << 2) - 1),
450 INDEX_MASK_3 = INDEX_HDR | ((1 << 3) - 1),
451 INDEX_MASK_4 = INDEX_HDR | ((1 << 4) - 1),
452 INDEX_MASK_5 = INDEX_HDR | ((1 << 5) - 1),
453 INDEX_MASK_6 = INDEX_HDR | ((1 << 6) - 1),
454 INDEX_MASK_7 = INDEX_HDR | ((1 << 7) - 1),
455 INDEX_MASK_8 = INDEX_HDR | ((1 << 8) - 1)
456 };
459 /**
460 * Expresses the convention when stereo audio samples are stored interleaved
461 * in an array. This should improve readability by allowing code to use
462 * symbolic indices instead of hard-coded [0] and [1].
463 *
464 * For multi-channel beyond stereo, the platform convention is that channels
465 * are interleaved in order from least significant channel mask bit to most
466 * significant channel mask bit, with unused bits skipped. Any exceptions
467 * to this convention will be noted at the appropriate API.
468 */
469 @export(name="", value_prefix="AUDIO_INTERLEAVE_")
470 enum AudioInterleave : int32_t {
471 LEFT = 0,
472 RIGHT = 1,
473 };
475 /**
476 * Major modes for a mobile device. The current mode setting affects audio
477 * routing.
478 */
479 @export(name="audio_mode_t", value_prefix="AUDIO_MODE_")
480 enum AudioMode : int32_t {
481 INVALID = -2,
482 CURRENT = -1,
483 NORMAL = 0,
484 RINGTONE = 1,
485 IN_CALL = 2,
486 IN_COMMUNICATION = 3,
488 CNT,
489 MAX = CNT - 1,
490 };
492 @export(name="", value_prefix="AUDIO_DEVICE_")
493 enum AudioDevice : uint32_t {
494 NONE = 0x0,
495 /** reserved bits */
496 BIT_IN = 0x80000000,
497 BIT_DEFAULT = 0x40000000,
498 /** output devices */
499 OUT_EARPIECE = 0x1,
500 OUT_SPEAKER = 0x2,
501 OUT_WIRED_HEADSET = 0x4,
502 OUT_WIRED_HEADPHONE = 0x8,
503 OUT_BLUETOOTH_SCO = 0x10,
504 OUT_BLUETOOTH_SCO_HEADSET = 0x20,
505 OUT_BLUETOOTH_SCO_CARKIT = 0x40,
506 OUT_BLUETOOTH_A2DP = 0x80,
507 OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
508 OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
509 OUT_AUX_DIGITAL = 0x400,
510 OUT_HDMI = OUT_AUX_DIGITAL,
511 /** uses an analog connection (multiplexed over the USB pins for instance) */
512 OUT_ANLG_DOCK_HEADSET = 0x800,
513 OUT_DGTL_DOCK_HEADSET = 0x1000,
514 /** USB accessory mode: Android device is USB device and dock is USB host */
515 OUT_USB_ACCESSORY = 0x2000,
516 /** USB host mode: Android device is USB host and dock is USB device */
517 OUT_USB_DEVICE = 0x4000,
518 OUT_REMOTE_SUBMIX = 0x8000,
519 /** Telephony voice TX path */
520 OUT_TELEPHONY_TX = 0x10000,
521 /** Analog jack with line impedance detected */
522 OUT_LINE = 0x20000,
523 /** HDMI Audio Return Channel */
524 OUT_HDMI_ARC = 0x40000,
525 /** S/PDIF out */
526 OUT_SPDIF = 0x80000,
527 /** FM transmitter out */
528 OUT_FM = 0x100000,
529 /** Line out for av devices */
530 OUT_AUX_LINE = 0x200000,
531 /** limited-output speaker device for acoustic safety */
532 OUT_SPEAKER_SAFE = 0x400000,
533 OUT_IP = 0x800000,
534 /** audio bus implemented by the audio system (e.g an MOST stereo channel) */
535 OUT_BUS = 0x1000000,
536 OUT_PROXY = 0x2000000,
537 OUT_USB_HEADSET = 0x4000000,
538 OUT_DEFAULT = BIT_DEFAULT,
539 OUT_ALL = (OUT_EARPIECE |
540 OUT_SPEAKER |
541 OUT_WIRED_HEADSET |
542 OUT_WIRED_HEADPHONE |
543 OUT_BLUETOOTH_SCO |
544 OUT_BLUETOOTH_SCO_HEADSET |
545 OUT_BLUETOOTH_SCO_CARKIT |
546 OUT_BLUETOOTH_A2DP |
547 OUT_BLUETOOTH_A2DP_HEADPHONES |
548 OUT_BLUETOOTH_A2DP_SPEAKER |
549 OUT_HDMI |
550 OUT_ANLG_DOCK_HEADSET |
551 OUT_DGTL_DOCK_HEADSET |
552 OUT_USB_ACCESSORY |
553 OUT_USB_DEVICE |
554 OUT_REMOTE_SUBMIX |
555 OUT_TELEPHONY_TX |
556 OUT_LINE |
557 OUT_HDMI_ARC |
558 OUT_SPDIF |
559 OUT_FM |
560 OUT_AUX_LINE |
561 OUT_SPEAKER_SAFE |
562 OUT_IP |
563 OUT_BUS |
564 OUT_PROXY |
565 OUT_USB_HEADSET |
566 OUT_DEFAULT),
567 OUT_ALL_A2DP = (OUT_BLUETOOTH_A2DP |
568 OUT_BLUETOOTH_A2DP_HEADPHONES |
569 OUT_BLUETOOTH_A2DP_SPEAKER),
570 OUT_ALL_SCO = (OUT_BLUETOOTH_SCO |
571 OUT_BLUETOOTH_SCO_HEADSET |
572 OUT_BLUETOOTH_SCO_CARKIT),
573 OUT_ALL_USB = (OUT_USB_ACCESSORY | OUT_USB_DEVICE | OUT_USB_HEADSET),
574 /** input devices */
575 IN_COMMUNICATION = BIT_IN | 0x1,
576 IN_AMBIENT = BIT_IN | 0x2,
577 IN_BUILTIN_MIC = BIT_IN | 0x4,
578 IN_BLUETOOTH_SCO_HEADSET = BIT_IN | 0x8,
579 IN_WIRED_HEADSET = BIT_IN | 0x10,
580 IN_AUX_DIGITAL = BIT_IN | 0x20,
581 IN_HDMI = IN_AUX_DIGITAL,
582 /** Telephony voice RX path */
583 IN_VOICE_CALL = BIT_IN | 0x40,
584 IN_TELEPHONY_RX = IN_VOICE_CALL,
585 IN_BACK_MIC = BIT_IN | 0x80,
586 IN_REMOTE_SUBMIX = BIT_IN | 0x100,
587 IN_ANLG_DOCK_HEADSET = BIT_IN | 0x200,
588 IN_DGTL_DOCK_HEADSET = BIT_IN | 0x400,
589 IN_USB_ACCESSORY = BIT_IN | 0x800,
590 IN_USB_DEVICE = BIT_IN | 0x1000,
591 /** FM tuner input */
592 IN_FM_TUNER = BIT_IN | 0x2000,
593 /** TV tuner input */
594 IN_TV_TUNER = BIT_IN | 0x4000,
595 /** Analog jack with line impedance detected */
596 IN_LINE = BIT_IN | 0x8000,
597 /** S/PDIF in */
598 IN_SPDIF = BIT_IN | 0x10000,
599 IN_BLUETOOTH_A2DP = BIT_IN | 0x20000,
600 IN_LOOPBACK = BIT_IN | 0x40000,
601 IN_IP = BIT_IN | 0x80000,
602 /** audio bus implemented by the audio system (e.g an MOST stereo channel) */
603 IN_BUS = BIT_IN | 0x100000,
604 IN_PROXY = BIT_IN | 0x1000000,
605 IN_USB_HEADSET = BIT_IN | 0x2000000,
606 IN_DEFAULT = BIT_IN | BIT_DEFAULT,
608 IN_ALL = (IN_COMMUNICATION |
609 IN_AMBIENT |
610 IN_BUILTIN_MIC |
611 IN_BLUETOOTH_SCO_HEADSET |
612 IN_WIRED_HEADSET |
613 IN_HDMI |
614 IN_TELEPHONY_RX |
615 IN_BACK_MIC |
616 IN_REMOTE_SUBMIX |
617 IN_ANLG_DOCK_HEADSET |
618 IN_DGTL_DOCK_HEADSET |
619 IN_USB_ACCESSORY |
620 IN_USB_DEVICE |
621 IN_FM_TUNER |
622 IN_TV_TUNER |
623 IN_LINE |
624 IN_SPDIF |
625 IN_BLUETOOTH_A2DP |
626 IN_LOOPBACK |
627 IN_IP |
628 IN_BUS |
629 IN_PROXY |
630 IN_USB_HEADSET |
631 IN_DEFAULT),
632 IN_ALL_SCO = IN_BLUETOOTH_SCO_HEADSET,
633 IN_ALL_USB = (IN_USB_ACCESSORY | IN_USB_DEVICE | IN_USB_HEADSET),
634 };
636 /**
637 * The audio output flags serve two purposes:
638 *
639 * - when an AudioTrack is created they indicate a "wish" to be connected to an
640 * output stream with attributes corresponding to the specified flags;
641 *
642 * - when present in an output profile descriptor listed for a particular audio
643 * hardware module, they indicate that an output stream can be opened that
644 * supports the attributes indicated by the flags.
645 *
646 * The audio policy manager will try to match the flags in the request
647 * (when getOuput() is called) to an available output stream.
648 */
649 @export(name="audio_output_flags_t", value_prefix="AUDIO_OUTPUT_FLAG_")
650 enum AudioOutputFlag : int32_t {
651 NONE = 0x0, // no attributes
652 DIRECT = 0x1, // this output directly connects a track
653 // to one output stream: no software mixer
654 PRIMARY = 0x2, // this output is the primary output of the device. It is
655 // unique and must be present. It is opened by default and
656 // receives routing, audio mode and volume controls related
657 // to voice calls.
658 FAST = 0x4, // output supports "fast tracks", defined elsewhere
659 DEEP_BUFFER = 0x8, // use deep audio buffers
660 COMPRESS_OFFLOAD = 0x10, // offload playback of compressed streams to
661 // hardware codec
662 NON_BLOCKING = 0x20, // use non-blocking write
663 HW_AV_SYNC = 0x40, // output uses a hardware A/V sync
664 TTS = 0x80, // output for streams transmitted through speaker at a
665 // sample rate high enough to accommodate lower-range
666 // ultrasonic p/b
667 RAW = 0x100, // minimize signal processing
668 SYNC = 0x200, // synchronize I/O streams
669 IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in SPDIF
670 // data bursts, not PCM.
671 DIRECT_PCM = 0x2000, // Audio stream containing PCM data that needs
672 // to pass through compress path for DSP post proc.
673 MMAP_NOIRQ = 0x4000, // output operates in MMAP no IRQ mode.
674 VOIP_RX = 0x8000, // preferred output for VoIP calls.
675 };
677 /**
678 * The audio input flags are analogous to audio output flags.
679 * Currently they are used only when an AudioRecord is created,
680 * to indicate a preference to be connected to an input stream with
681 * attributes corresponding to the specified flags.
682 */
683 @export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_")
684 enum AudioInputFlag : int32_t {
685 NONE = 0x0, // no attributes
686 FAST = 0x1, // prefer an input that supports "fast tracks"
687 HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source
688 RAW = 0x4, // minimize signal processing
689 SYNC = 0x8, // synchronize I/O streams
690 MMAP_NOIRQ = 0x10, // input operates in MMAP no IRQ mode.
691 VOIP_TX = 0x20, // preferred input for VoIP calls.
692 };
694 @export(name="audio_usage_t", value_prefix="AUDIO_USAGE_")
695 enum AudioUsage : int32_t {
696 // These values must kept in sync with
697 // frameworks/base/media/java/android/media/AudioAttributes.java
698 UNKNOWN = 0,
699 MEDIA = 1,
700 VOICE_COMMUNICATION = 2,
701 VOICE_COMMUNICATION_SIGNALLING = 3,
702 ALARM = 4,
703 NOTIFICATION = 5,
704 NOTIFICATION_TELEPHONY_RINGTONE = 6,
705 NOTIFICATION_COMMUNICATION_REQUEST = 7,
706 NOTIFICATION_COMMUNICATION_INSTANT = 8,
707 NOTIFICATION_COMMUNICATION_DELAYED = 9,
708 NOTIFICATION_EVENT = 10,
709 ASSISTANCE_ACCESSIBILITY = 11,
710 ASSISTANCE_NAVIGATION_GUIDANCE = 12,
711 ASSISTANCE_SONIFICATION = 13,
712 GAME = 14,
713 VIRTUAL_SOURCE = 15,
714 ASSISTANT = 16,
716 CNT,
717 MAX = CNT - 1,
718 };
720 /**
721 * Additional information about the stream passed to hardware decoders.
722 */
723 struct AudioOffloadInfo {
724 uint32_t sampleRateHz;
725 AudioChannelMask channelMask;
726 AudioFormat format;
727 AudioStreamType streamType;
728 uint32_t bitRatePerSecond;
729 int64_t durationMicroseconds; // -1 if unknown
730 bool hasVideo;
731 bool isStreaming;
732 uint32_t bitWidth;
733 uint32_t bufferSize;
734 AudioUsage usage;
735 };
737 /**
738 * Commonly used audio stream configuration parameters.
739 */
740 struct AudioConfig {
741 uint32_t sampleRateHz;
742 AudioChannelMask channelMask;
743 AudioFormat format;
744 AudioOffloadInfo offloadInfo;
745 uint64_t frameCount;
746 };
749 /**
750 *
751 * Volume control
752 *
753 */
755 /**
756 * Type of gain control exposed by an audio port.
757 */
758 @export(name="", value_prefix="AUDIO_GAIN_MODE_")
759 enum AudioGainMode : uint32_t {
760 JOINT = 0x1, // supports joint channel gain control
761 CHANNELS = 0x2, // supports separate channel gain control
762 RAMP = 0x4 // supports gain ramps
763 };
765 /**
766 * An audio_gain struct is a representation of a gain stage.
767 * A gain stage is always attached to an audio port.
768 */
769 struct AudioGain {
770 AudioGainMode mode;
771 AudioChannelMask channelMask; // channels which gain an be controlled
772 int32_t minValue; // minimum gain value in millibels
773 int32_t maxValue; // maximum gain value in millibels
774 int32_t defaultValue; // default gain value in millibels
775 uint32_t stepValue; // gain step in millibels
776 uint32_t minRampMs; // minimum ramp duration in ms
777 uint32_t maxRampMs; // maximum ramp duration in ms
778 };
780 /**
781 * The gain configuration structure is used to get or set the gain values of a
782 * given port.
783 */
784 struct AudioGainConfig {
785 int32_t index; // index of the corresponding AudioGain in AudioPort.gains
786 AudioGainMode mode;
787 AudioChannelMask channelMask; // channels which gain value follows
788 /**
789 * 4 = sizeof(AudioChannelMask),
790 * 8 is not "FCC_8", so it won't need to be changed for > 8 channels.
791 * Gain values in millibels for each channel ordered from LSb to MSb in
792 * channel mask. The number of values is 1 in joint mode or
793 * popcount(channel_mask).
794 */
795 int32_t[4 * 8] values;
796 uint32_t rampDurationMs; // ramp duration in ms
797 };
800 /**
801 *
802 * Routing control
803 *
804 */
806 /**
807 * Types defined here are used to describe an audio source or sink at internal
808 * framework interfaces (audio policy, patch panel) or at the audio HAL.
809 * Sink and sources are grouped in a concept of “audio port” representing an
810 * audio end point at the edge of the system managed by the module exposing
811 * the interface.
812 */
814 /** Audio port role: either source or sink */
815 @export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_")
816 enum AudioPortRole : int32_t {
817 NONE,
818 SOURCE,
819 SINK,
820 };
822 /**
823 * Audio port type indicates if it is a session (e.g AudioTrack), a mix (e.g
824 * PlaybackThread output) or a physical device (e.g OUT_SPEAKER)
825 */
826 @export(name="audio_port_type_t", value_prefix="AUDIO_PORT_TYPE_")
827 enum AudioPortType : int32_t {
828 NONE,
829 DEVICE,
830 MIX,
831 SESSION,
832 };
834 /**
835 * Extension for audio port configuration structure when the audio port is a
836 * hardware device.
837 */
838 struct AudioPortConfigDeviceExt {
839 AudioModuleHandle hwModule; // module the device is attached to
840 AudioDevice type; // device type (e.g OUT_SPEAKER)
841 uint8_t[32] address; // device address. "" if N/A
842 };
844 /**
845 * Extension for audio port configuration structure when the audio port is an
846 * audio session.
847 */
848 struct AudioPortConfigSessionExt {
849 AudioSession session;
850 };
852 /**
853 * Flags indicating which fields are to be considered in AudioPortConfig.
854 */
855 @export(name="", value_prefix="AUDIO_PORT_CONFIG_")
856 enum AudioPortConfigMask : uint32_t {
857 SAMPLE_RATE = 0x1,
858 CHANNEL_MASK = 0x2,
859 FORMAT = 0x4,
860 GAIN = 0x8,
861 ALL = SAMPLE_RATE | CHANNEL_MASK | FORMAT | GAIN
862 };
864 /**
865 * Audio port configuration structure used to specify a particular configuration
866 * of an audio port.
867 */
868 struct AudioPortConfig {
869 AudioPortHandle id;
870 AudioPortConfigMask configMask;
871 uint32_t sampleRateHz;
872 AudioChannelMask channelMask;
873 AudioFormat format;
874 AudioGainConfig gain;
875 AudioPortType type; // type is used as a discriminator for Ext union
876 AudioPortRole role; // role is used as a discriminator for UseCase union
877 union Ext {
878 AudioPortConfigDeviceExt device;
879 struct AudioPortConfigMixExt {
880 AudioModuleHandle hwModule; // module the stream is attached to
881 AudioIoHandle ioHandle; // I/O handle of the input/output stream
882 union UseCase {
883 AudioStreamType stream;
884 AudioSource source;
885 } useCase;
886 } mix;
887 AudioPortConfigSessionExt session;
888 } ext;
889 };
891 /**
892 * Extension for audio port structure when the audio port is a hardware device.
893 */
894 struct AudioPortDeviceExt {
895 AudioModuleHandle hwModule; // module the device is attached to
896 AudioDevice type;
897 uint8_t[32] address;
898 };
900 /**
901 * Latency class of the audio mix.
902 */
903 @export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_")
904 enum AudioMixLatencyClass : int32_t {
905 LOW,
906 NORMAL
907 } ;
909 struct AudioPortMixExt {
910 AudioModuleHandle hwModule; // module the stream is attached to
911 AudioIoHandle ioHandle; // I/O handle of the stream
912 AudioMixLatencyClass latencyClass;
913 };
915 /**
916 * Extension for audio port structure when the audio port is an audio session.
917 */
918 struct AudioPortSessionExt {
919 AudioSession session;
920 };
922 struct AudioPort {
923 AudioPortHandle id;
924 AudioPortRole role;
925 string name;
926 vec<uint32_t> sampleRates;
927 vec<AudioChannelMask> channelMasks;
928 vec<AudioFormat> formats;
929 vec<AudioGain> gains;
930 AudioPortConfig activeConfig; // current audio port configuration
931 AudioPortType type; // type is used as a discriminator
932 union Ext {
933 AudioPortDeviceExt device;
934 AudioPortMixExt mix;
935 AudioPortSessionExt session;
936 } ext;
937 };
939 struct ThreadInfo {
940 int64_t pid;
941 int64_t tid;
942 };