]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/platform-hardware-interfaces.git/blob - audio/common/4.0/types.hal
[automerger skipped] Camera: Allocate graphics buffers via 'IAllocator' am: f4483700a8
[android/platform-hardware-interfaces.git] / audio / common / 4.0 / types.hal
1 /*
2  * Copyright (C) 2018 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@4.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 intended 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 };
109 @export(name="audio_source_t", value_prefix="AUDIO_SOURCE_")
110 enum AudioSource : int32_t {
111     // These values must kept in sync with
112     //  frameworks/base/media/java/android/media/MediaRecorder.java,
113     //  frameworks/av/services/audiopolicy/AudioPolicyService.cpp,
114     //  system/media/audio_effects/include/audio_effects/audio_effects_conf.h
115     DEFAULT             = 0,
116     MIC                 = 1,
117     VOICE_UPLINK        = 2,
118     VOICE_DOWNLINK      = 3,
119     VOICE_CALL          = 4,
120     CAMCORDER           = 5,
121     VOICE_RECOGNITION   = 6,
122     VOICE_COMMUNICATION = 7,
123     /**
124      * Source for the mix to be presented remotely. An example of remote
125      * presentation is Wifi Display where a dongle attached to a TV can be used
126      * to play the mix captured by this audio source.
127      */
128     REMOTE_SUBMIX       = 8,
129     /**
130      * Source for unprocessed sound. Usage examples include level measurement
131      * and raw signal analysis.
132      */
133     UNPROCESSED         = 9,
135     FM_TUNER            = 1998,
136 };
138 typedef int32_t AudioSession;
139 /**
140  * Special audio session values.
141  */
142 @export(name="audio_session_t", value_prefix="AUDIO_SESSION_")
143 enum AudioSessionConsts : int32_t {
144     /**
145      * Session for effects attached to a particular output stream
146      * (value must be less than 0)
147      */
148     OUTPUT_STAGE = -1,
149     /**
150      * Session for effects applied to output mix. These effects can
151      * be moved by audio policy manager to another output stream
152      * (value must be 0)
153      */
154     OUTPUT_MIX = 0,
155     /**
156      * Application does not specify an explicit session ID to be used, and
157      * requests a new session ID to be allocated. Corresponds to
158      * AudioManager.AUDIO_SESSION_ID_GENERATE and
159      * AudioSystem.AUDIO_SESSION_ALLOCATE.
160      */
161     ALLOCATE = 0,
162     /**
163      * For use with AudioRecord::start(), this indicates no trigger session.
164      * It is also used with output tracks and patch tracks, which never have a
165      * session.
166      */
167     NONE = 0
168 };
170 /**
171  * Audio format  is a 32-bit word that consists of:
172  *   main format field (upper 8 bits)
173  *   sub format field (lower 24 bits).
174  *
175  * The main format indicates the main codec type. The sub format field indicates
176  * options and parameters for each format. The sub format is mainly used for
177  * record to indicate for instance the requested bitrate or profile.  It can
178  * also be used for certain formats to give informations not present in the
179  * encoded audio stream (e.g. octet alignement for AMR).
180  */
181 @export(name="audio_format_t", value_prefix="AUDIO_FORMAT_")
182 enum AudioFormat : uint32_t {
183     INVALID             = 0xFFFFFFFFUL,
184     DEFAULT             = 0,
185     PCM                 = 0x00000000UL,
186     MP3                 = 0x01000000UL,
187     AMR_NB              = 0x02000000UL,
188     AMR_WB              = 0x03000000UL,
189     AAC                 = 0x04000000UL,
190     /** Deprecated, Use AAC_HE_V1 */
191     HE_AAC_V1           = 0x05000000UL,
192     /** Deprecated, Use AAC_HE_V2 */
193     HE_AAC_V2           = 0x06000000UL,
194     VORBIS              = 0x07000000UL,
195     OPUS                = 0x08000000UL,
196     AC3                 = 0x09000000UL,
197     E_AC3               = 0x0A000000UL,
198     DTS                 = 0x0B000000UL,
199     DTS_HD              = 0x0C000000UL,
200     /** IEC61937 is encoded audio wrapped in 16-bit PCM. */
201     IEC61937            = 0x0D000000UL,
202     DOLBY_TRUEHD        = 0x0E000000UL,
203     EVRC                = 0x10000000UL,
204     EVRCB               = 0x11000000UL,
205     EVRCWB              = 0x12000000UL,
206     EVRCNW              = 0x13000000UL,
207     AAC_ADIF            = 0x14000000UL,
208     WMA                 = 0x15000000UL,
209     WMA_PRO             = 0x16000000UL,
210     AMR_WB_PLUS         = 0x17000000UL,
211     MP2                 = 0x18000000UL,
212     QCELP               = 0x19000000UL,
213     DSD                 = 0x1A000000UL,
214     FLAC                = 0x1B000000UL,
215     ALAC                = 0x1C000000UL,
216     APE                 = 0x1D000000UL,
217     AAC_ADTS            = 0x1E000000UL,
218     SBC                 = 0x1F000000UL,
219     APTX                = 0x20000000UL,
220     APTX_HD             = 0x21000000UL,
221     AC4                 = 0x22000000UL,
222     LDAC                = 0x23000000UL,
223     /** Dolby Metadata-enhanced Audio Transmission */
224     MAT                 = 0x24000000UL,
225     /** Deprecated */
226     MAIN_MASK           = 0xFF000000UL,
227     SUB_MASK            = 0x00FFFFFFUL,
229     /* Subformats */
230     PCM_SUB_16_BIT        = 0x1, // PCM signed 16 bits
231     PCM_SUB_8_BIT         = 0x2, // PCM unsigned 8 bits
232     PCM_SUB_32_BIT        = 0x3, // PCM signed .31 fixed point
233     PCM_SUB_8_24_BIT      = 0x4, // PCM signed 8.23 fixed point
234     PCM_SUB_FLOAT         = 0x5, // PCM single-precision float pt
235     PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
237     MP3_SUB_NONE          = 0x0,
239     AMR_SUB_NONE          = 0x0,
241     AAC_SUB_MAIN          = 0x1,
242     AAC_SUB_LC            = 0x2,
243     AAC_SUB_SSR           = 0x4,
244     AAC_SUB_LTP           = 0x8,
245     AAC_SUB_HE_V1         = 0x10,
246     AAC_SUB_SCALABLE      = 0x20,
247     AAC_SUB_ERLC          = 0x40,
248     AAC_SUB_LD            = 0x80,
249     AAC_SUB_HE_V2         = 0x100,
250     AAC_SUB_ELD           = 0x200,
251     AAC_SUB_XHE           = 0x300,
253     VORBIS_SUB_NONE       = 0x0,
255     E_AC3_SUB_JOC         = 0x1,
257     MAT_SUB_1_0           = 0x1,
258     MAT_SUB_2_0           = 0x2,
259     MAT_SUB_2_1           = 0x3,
261     /* Aliases */
262     /** note != AudioFormat.ENCODING_PCM_16BIT */
263     PCM_16_BIT          = (PCM | PCM_SUB_16_BIT),
264     /** note != AudioFormat.ENCODING_PCM_8BIT */
265     PCM_8_BIT           = (PCM | PCM_SUB_8_BIT),
266     PCM_32_BIT          = (PCM | PCM_SUB_32_BIT),
267     PCM_8_24_BIT        = (PCM | PCM_SUB_8_24_BIT),
268     PCM_FLOAT           = (PCM | PCM_SUB_FLOAT),
269     PCM_24_BIT_PACKED   = (PCM | PCM_SUB_24_BIT_PACKED),
270     AAC_MAIN            = (AAC | AAC_SUB_MAIN),
271     AAC_LC              = (AAC | AAC_SUB_LC),
272     AAC_SSR             = (AAC | AAC_SUB_SSR),
273     AAC_LTP             = (AAC | AAC_SUB_LTP),
274     AAC_HE_V1           = (AAC | AAC_SUB_HE_V1),
275     AAC_SCALABLE        = (AAC | AAC_SUB_SCALABLE),
276     AAC_ERLC            = (AAC | AAC_SUB_ERLC),
277     AAC_LD              = (AAC | AAC_SUB_LD),
278     AAC_HE_V2           = (AAC | AAC_SUB_HE_V2),
279     AAC_ELD             = (AAC | AAC_SUB_ELD),
280     AAC_XHE             = (AAC | AAC_SUB_XHE),
281     AAC_ADTS_MAIN       = (AAC_ADTS | AAC_SUB_MAIN),
282     AAC_ADTS_LC         = (AAC_ADTS | AAC_SUB_LC),
283     AAC_ADTS_SSR        = (AAC_ADTS | AAC_SUB_SSR),
284     AAC_ADTS_LTP        = (AAC_ADTS | AAC_SUB_LTP),
285     AAC_ADTS_HE_V1      = (AAC_ADTS | AAC_SUB_HE_V1),
286     AAC_ADTS_SCALABLE   = (AAC_ADTS | AAC_SUB_SCALABLE),
287     AAC_ADTS_ERLC       = (AAC_ADTS | AAC_SUB_ERLC),
288     AAC_ADTS_LD         = (AAC_ADTS | AAC_SUB_LD),
289     AAC_ADTS_HE_V2      = (AAC_ADTS | AAC_SUB_HE_V2),
290     AAC_ADTS_ELD        = (AAC_ADTS | AAC_SUB_ELD),
291     AAC_ADTS_XHE        = (AAC_ADTS | AAC_SUB_XHE),
292     E_AC3_JOC           = (E_AC3 | E_AC3_SUB_JOC),
293     MAT_1_0             = (MAT | MAT_SUB_1_0),
294     MAT_2_0             = (MAT | MAT_SUB_2_0),
295     MAT_2_1             = (MAT | MAT_SUB_2_1),
296 };
298 /**
299  * Usage of these values highlights places in the code that use 2- or 8- channel
300  * assumptions.
301  */
302 @export(name="")
303 enum FixedChannelCount : int32_t {
304     FCC_2 = 2, // This is typically due to legacy implementation of stereo I/O
305     FCC_8 = 8  // This is typically due to audio mixer and resampler limitations
306 };
308 /**
309  * A channel mask per se only defines the presence or absence of a channel, not
310  * the order.  See AUDIO_INTERLEAVE_* for the platform convention of order.
311  *
312  * AudioChannelMask is an opaque type and its internal layout should not be
313  * assumed as it may change in the future.  Instead, always use functions
314  * to examine it.
315  *
316  * These are the current representations:
317  *
318  *   REPRESENTATION_POSITION
319  *     is a channel mask representation for position assignment.  Each low-order
320  *     bit corresponds to the spatial position of a transducer (output), or
321  *     interpretation of channel (input).  The user of a channel mask needs to
322  *     know the context of whether it is for output or input.  The constants
323  *     OUT_* or IN_* apply to the bits portion.  It is not permitted for no bits
324  *     to be set.
325  *
326  *   REPRESENTATION_INDEX
327  *     is a channel mask representation for index assignment.  Each low-order
328  *     bit corresponds to a selected channel.  There is no platform
329  *     interpretation of the various bits.  There is no concept of output or
330  *     input.  It is not permitted for no bits to be set.
331  *
332  * All other representations are reserved for future use.
333  *
334  * Warning: current representation distinguishes between input and output, but
335  * this will not the be case in future revisions of the platform. Wherever there
336  * is an ambiguity between input and output that is currently resolved by
337  * checking the channel mask, the implementer should look for ways to fix it
338  * with additional information outside of the mask.
339  */
340 @export(name="", value_prefix="AUDIO_CHANNEL_")
341 enum AudioChannelMask : uint32_t {
342     /** must be 0 for compatibility */
343     REPRESENTATION_POSITION = 0,
344     /** 1 is reserved for future use */
345     REPRESENTATION_INDEX    = 2,
346     /* 3 is reserved for future use */
348     /** These can be a complete value of AudioChannelMask */
349     NONE                      = 0x0,
350     INVALID                   = 0xC0000000,
352    /*
353     * These can be the bits portion of an AudioChannelMask
354     * with representation REPRESENTATION_POSITION.
355     */
357     /** output channels */
358     OUT_FRONT_LEFT            = 0x1,
359     OUT_FRONT_RIGHT           = 0x2,
360     OUT_FRONT_CENTER          = 0x4,
361     OUT_LOW_FREQUENCY         = 0x8,
362     OUT_BACK_LEFT             = 0x10,
363     OUT_BACK_RIGHT            = 0x20,
364     OUT_FRONT_LEFT_OF_CENTER  = 0x40,
365     OUT_FRONT_RIGHT_OF_CENTER = 0x80,
366     OUT_BACK_CENTER           = 0x100,
367     OUT_SIDE_LEFT             = 0x200,
368     OUT_SIDE_RIGHT            = 0x400,
369     OUT_TOP_CENTER            = 0x800,
370     OUT_TOP_FRONT_LEFT        = 0x1000,
371     OUT_TOP_FRONT_CENTER      = 0x2000,
372     OUT_TOP_FRONT_RIGHT       = 0x4000,
373     OUT_TOP_BACK_LEFT         = 0x8000,
374     OUT_TOP_BACK_CENTER       = 0x10000,
375     OUT_TOP_BACK_RIGHT        = 0x20000,
376     OUT_TOP_SIDE_LEFT         = 0x40000,
377     OUT_TOP_SIDE_RIGHT        = 0x80000,
379     OUT_MONO     = OUT_FRONT_LEFT,
380     OUT_STEREO   = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT),
381     OUT_2POINT1  = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY),
382     OUT_2POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
383                          OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
384     OUT_2POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
385                          OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
386                          OUT_LOW_FREQUENCY),
387     OUT_3POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
388                          OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
389     OUT_3POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT |
390                         OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT |
391                         OUT_LOW_FREQUENCY),
392     OUT_QUAD     = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
393             OUT_BACK_LEFT | OUT_BACK_RIGHT),
394     OUT_QUAD_BACK = OUT_QUAD,
395     /** like OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
396     OUT_QUAD_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
397             OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
398     OUT_SURROUND = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
399             OUT_FRONT_CENTER | OUT_BACK_CENTER),
400     OUT_PENTA = (OUT_QUAD | OUT_FRONT_CENTER),
401     OUT_5POINT1   = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
402             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
403             OUT_BACK_LEFT | OUT_BACK_RIGHT),
404     OUT_5POINT1_BACK = OUT_5POINT1,
405     /** like OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
406     OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
407             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
408             OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
409     OUT_5POINT1POINT2  = (OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
410     OUT_5POINT1POINT4  = (OUT_5POINT1 |
411             OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
412             OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
413     OUT_6POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
414             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
415             OUT_BACK_LEFT | OUT_BACK_RIGHT |
416             OUT_BACK_CENTER),
417     /** matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND */
418     OUT_7POINT1  = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
419             OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
420             OUT_BACK_LEFT | OUT_BACK_RIGHT |
421             OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
422     OUT_7POINT1POINT2  = (OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT),
423     OUT_7POINT1POINT4  = (OUT_7POINT1 |
424             OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT |
425             OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT),
426     // Note that the 2.0 OUT_ALL* have been moved to helper functions
428     /* These are bits only, not complete values */
430     /** input channels */
431     IN_LEFT            = 0x4,
432     IN_RIGHT           = 0x8,
433     IN_FRONT           = 0x10,
434     IN_BACK            = 0x20,
435     IN_LEFT_PROCESSED  = 0x40,
436     IN_RIGHT_PROCESSED = 0x80,
437     IN_FRONT_PROCESSED = 0x100,
438     IN_BACK_PROCESSED  = 0x200,
439     IN_PRESSURE        = 0x400,
440     IN_X_AXIS          = 0x800,
441     IN_Y_AXIS          = 0x1000,
442     IN_Z_AXIS          = 0x2000,
443     IN_BACK_LEFT       = 0x10000,
444     IN_BACK_RIGHT      = 0x20000,
445     IN_CENTER          = 0x40000,
446     IN_LOW_FREQUENCY   = 0x100000,
447     IN_TOP_LEFT        = 0x200000,
448     IN_TOP_RIGHT       = 0x400000,
450     IN_VOICE_UPLINK    = 0x4000,
451     IN_VOICE_DNLINK    = 0x8000,
453     IN_MONO   = IN_FRONT,
454     IN_STEREO = (IN_LEFT | IN_RIGHT),
455     IN_FRONT_BACK = (IN_FRONT | IN_BACK),
456     IN_6 = (IN_LEFT | IN_RIGHT |
457             IN_FRONT | IN_BACK |
458             IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED),
459     IN_2POINT0POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT),
460     IN_2POINT1POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT |
461             IN_LOW_FREQUENCY),
462     IN_3POINT0POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT),
463     IN_3POINT1POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT |
464             IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY),
465     IN_5POINT1 = (IN_LEFT | IN_CENTER | IN_RIGHT |
466                   IN_BACK_LEFT | IN_BACK_RIGHT | IN_LOW_FREQUENCY),
467     IN_VOICE_UPLINK_MONO = (IN_VOICE_UPLINK | IN_MONO),
468     IN_VOICE_DNLINK_MONO = (IN_VOICE_DNLINK | IN_MONO),
469     IN_VOICE_CALL_MONO   = (IN_VOICE_UPLINK_MONO |
470             IN_VOICE_DNLINK_MONO),
471     // Note that the 2.0 IN_ALL* have been moved to helper functions
473     COUNT_MAX    = 30,
474     INDEX_HDR    = REPRESENTATION_INDEX << COUNT_MAX,
475     INDEX_MASK_1 = INDEX_HDR | ((1 << 1) - 1),
476     INDEX_MASK_2 = INDEX_HDR | ((1 << 2) - 1),
477     INDEX_MASK_3 = INDEX_HDR | ((1 << 3) - 1),
478     INDEX_MASK_4 = INDEX_HDR | ((1 << 4) - 1),
479     INDEX_MASK_5 = INDEX_HDR | ((1 << 5) - 1),
480     INDEX_MASK_6 = INDEX_HDR | ((1 << 6) - 1),
481     INDEX_MASK_7 = INDEX_HDR | ((1 << 7) - 1),
482     INDEX_MASK_8 = INDEX_HDR | ((1 << 8) - 1)
483 };
485 /**
486  * Major modes for a mobile device. The current mode setting affects audio
487  * routing.
488  */
489 @export(name="audio_mode_t", value_prefix="AUDIO_MODE_")
490 enum AudioMode : int32_t {
491     NORMAL           = 0,
492     RINGTONE         = 1,
493     /** Calls handled by the telephony stack (Eg: PSTN). */
494     IN_CALL          = 2,
495     /** Calls handled by apps (Eg: Hangout). */
496     IN_COMMUNICATION = 3,
497 };
499 @export(name="", value_prefix="AUDIO_DEVICE_")
500 enum AudioDevice : uint32_t {
501     NONE                          = 0x0,
502     /** reserved bits */
503     BIT_IN                        = 0x80000000,
504     BIT_DEFAULT                   = 0x40000000,
505     /** output devices */
506     OUT_EARPIECE                  = 0x1,
507     OUT_SPEAKER                   = 0x2,
508     OUT_WIRED_HEADSET             = 0x4,
509     OUT_WIRED_HEADPHONE           = 0x8,
510     OUT_BLUETOOTH_SCO             = 0x10,
511     OUT_BLUETOOTH_SCO_HEADSET     = 0x20,
512     OUT_BLUETOOTH_SCO_CARKIT      = 0x40,
513     OUT_BLUETOOTH_A2DP            = 0x80,
514     OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
515     OUT_BLUETOOTH_A2DP_SPEAKER    = 0x200,
516     OUT_AUX_DIGITAL               = 0x400,
517     OUT_HDMI                      = OUT_AUX_DIGITAL,
518     /** uses an analog connection (multiplexed over the USB pins for instance) */
519     OUT_ANLG_DOCK_HEADSET         = 0x800,
520     OUT_DGTL_DOCK_HEADSET         = 0x1000,
521     /** USB accessory mode: Android device is USB device and dock is USB host */
522     OUT_USB_ACCESSORY             = 0x2000,
523     /** USB host mode: Android device is USB host and dock is USB device */
524     OUT_USB_DEVICE                = 0x4000,
525     OUT_REMOTE_SUBMIX             = 0x8000,
526     /** Telephony voice TX path */
527     OUT_TELEPHONY_TX              = 0x10000,
528     /** Analog jack with line impedance detected */
529     OUT_LINE                      = 0x20000,
530     /** HDMI Audio Return Channel */
531     OUT_HDMI_ARC                  = 0x40000,
532     /** S/PDIF out */
533     OUT_SPDIF                     = 0x80000,
534     /** FM transmitter out */
535     OUT_FM                        = 0x100000,
536     /** Line out for av devices */
537     OUT_AUX_LINE                  = 0x200000,
538     /** limited-output speaker device for acoustic safety */
539     OUT_SPEAKER_SAFE              = 0x400000,
540     OUT_IP                        = 0x800000,
541     /** audio bus implemented by the audio system (e.g an MOST stereo channel) */
542     OUT_BUS                       = 0x1000000,
543     OUT_PROXY                     = 0x2000000,
544     OUT_USB_HEADSET               = 0x4000000,
545     OUT_HEARING_AID               = 0x8000000,
546     OUT_ECHO_CANCELLER            = 0x10000000,
547     OUT_DEFAULT                   = BIT_DEFAULT,
548     // Note that the 2.0 OUT_ALL* have been moved to helper functions
550     /** input devices */
551     IN_COMMUNICATION         = BIT_IN | 0x1,
552     IN_AMBIENT               = BIT_IN | 0x2,
553     IN_BUILTIN_MIC           = BIT_IN | 0x4,
554     IN_BLUETOOTH_SCO_HEADSET = BIT_IN | 0x8,
555     IN_WIRED_HEADSET         = BIT_IN | 0x10,
556     IN_AUX_DIGITAL           = BIT_IN | 0x20,
557     IN_HDMI                  = IN_AUX_DIGITAL,
558     /** Telephony voice RX path */
559     IN_VOICE_CALL            = BIT_IN | 0x40,
560     IN_TELEPHONY_RX          = IN_VOICE_CALL,
561     IN_BACK_MIC              = BIT_IN | 0x80,
562     IN_REMOTE_SUBMIX         = BIT_IN | 0x100,
563     IN_ANLG_DOCK_HEADSET     = BIT_IN | 0x200,
564     IN_DGTL_DOCK_HEADSET     = BIT_IN | 0x400,
565     IN_USB_ACCESSORY         = BIT_IN | 0x800,
566     IN_USB_DEVICE            = BIT_IN | 0x1000,
567     /** FM tuner input */
568     IN_FM_TUNER              = BIT_IN | 0x2000,
569     /** TV tuner input */
570     IN_TV_TUNER              = BIT_IN | 0x4000,
571     /** Analog jack with line impedance detected */
572     IN_LINE                  = BIT_IN | 0x8000,
573     /** S/PDIF in */
574     IN_SPDIF                 = BIT_IN | 0x10000,
575     IN_BLUETOOTH_A2DP        = BIT_IN | 0x20000,
576     IN_LOOPBACK              = BIT_IN | 0x40000,
577     IN_IP                    = BIT_IN | 0x80000,
578     /** audio bus implemented by the audio system (e.g an MOST stereo channel) */
579     IN_BUS                   = BIT_IN | 0x100000,
580     IN_PROXY                 = BIT_IN | 0x1000000,
581     IN_USB_HEADSET           = BIT_IN | 0x2000000,
582     IN_BLUETOOTH_BLE         = BIT_IN | 0x4000000,
583     IN_DEFAULT               = BIT_IN | BIT_DEFAULT,
585     // Note that the 2.0 IN_ALL* have been moved to helper functions
586 };
588 /**
589  * The audio output flags serve two purposes:
590  *
591  *  - when an AudioTrack is created they indicate a "wish" to be connected to an
592  *    output stream with attributes corresponding to the specified flags;
593  *
594  *  - when present in an output profile descriptor listed for a particular audio
595  *    hardware module, they indicate that an output stream can be opened that
596  *    supports the attributes indicated by the flags.
597  *
598  * The audio policy manager will try to match the flags in the request
599  * (when getOuput() is called) to an available output stream.
600  */
601 @export(name="audio_output_flags_t", value_prefix="AUDIO_OUTPUT_FLAG_")
602 enum AudioOutputFlag : int32_t {
603     NONE    = 0x0, // no attributes
604     DIRECT  = 0x1, // this output directly connects a track
605                    // to one output stream: no software mixer
606     PRIMARY = 0x2, // this output is the primary output of the device. It is
607                    // unique and must be present. It is opened by default and
608                    // receives routing, audio mode and volume controls related
609                    // to voice calls.
610     FAST    = 0x4,    // output supports "fast tracks", defined elsewhere
611     DEEP_BUFFER      = 0x8,   // use deep audio buffers
612     COMPRESS_OFFLOAD = 0x10,  // offload playback of compressed streams to
613                               // hardware codec
614     NON_BLOCKING     = 0x20,  // use non-blocking write
615     HW_AV_SYNC = 0x40,   // output uses a hardware A/V sync
616     TTS        = 0x80,   // output for streams transmitted through speaker at a
617                          // sample rate high enough to accommodate lower-range
618                          // ultrasonic p/b
619     RAW        = 0x100,  // minimize signal processing
620     SYNC       = 0x200,  // synchronize I/O streams
621     IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in SPDIF
622                              // data bursts, not PCM.
623     DIRECT_PCM = 0x2000,     // Audio stream containing PCM data that needs
624                              // to pass through compress path for DSP post proc.
625     MMAP_NOIRQ = 0x4000, // output operates in MMAP no IRQ mode.
626     VOIP_RX = 0x8000,    // preferred output for VoIP calls.
627     /** preferred output for call music */
628     INCALL_MUSIC = 0x10000,
629 };
631 /**
632  * The audio input flags are analogous to audio output flags.
633  * Currently they are used only when an AudioRecord is created,
634  * to indicate a preference to be connected to an input stream with
635  * attributes corresponding to the specified flags.
636  */
637 @export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_")
638 enum AudioInputFlag : int32_t {
639     NONE         = 0x0,  // no attributes
640     FAST         = 0x1,  // prefer an input that supports "fast tracks"
641     HW_HOTWORD   = 0x2,  // prefer an input that captures from hw hotword source
642     RAW          = 0x4,  // minimize signal processing
643     SYNC         = 0x8,  // synchronize I/O streams
644     MMAP_NOIRQ   = 0x10, // input operates in MMAP no IRQ mode.
645     VOIP_TX      = 0x20, // preferred input for VoIP calls.
646     HW_AV_SYNC   = 0x40, // input connected to an output that uses a hardware A/V sync
647 };
649 @export(name="audio_usage_t", value_prefix="AUDIO_USAGE_")
650 enum AudioUsage : int32_t {
651     // These values must kept in sync with
652     //  frameworks/base/media/java/android/media/AudioAttributes.java
653     // Note that not all framework values are exposed
654     UNKNOWN                            = 0,
655     MEDIA                              = 1,
656     VOICE_COMMUNICATION                = 2,
657     VOICE_COMMUNICATION_SIGNALLING     = 3,
658     ALARM                              = 4,
659     NOTIFICATION                       = 5,
660     NOTIFICATION_TELEPHONY_RINGTONE    = 6,
661     ASSISTANCE_ACCESSIBILITY           = 11,
662     ASSISTANCE_NAVIGATION_GUIDANCE     = 12,
663     ASSISTANCE_SONIFICATION            = 13,
664     GAME                               = 14,
665     VIRTUAL_SOURCE                     = 15,
666     ASSISTANT                          = 16,
667 };
669 /** Type of audio generated by an application. */
670 @export(name="audio_content_type_t", value_prefix="AUDIO_CONTENT_TYPE_")
671 enum AudioContentType : uint32_t {
672     // Do not change these values without updating their counterparts
673     // in frameworks/base/media/java/android/media/AudioAttributes.java
674     UNKNOWN      = 0,
675     SPEECH       = 1,
676     MUSIC        = 2,
677     MOVIE        = 3,
678     SONIFICATION = 4,
679 };
681 /**
682  * Additional information about the stream passed to hardware decoders.
683  */
684 struct AudioOffloadInfo {
685     uint32_t sampleRateHz;
686     bitfield<AudioChannelMask> channelMask;
687     AudioFormat format;
688     AudioStreamType streamType;
689     uint32_t bitRatePerSecond;
690     int64_t durationMicroseconds;  // -1 if unknown
691     bool hasVideo;
692     bool isStreaming;
693     uint32_t bitWidth;
694     uint32_t bufferSize;
695     AudioUsage usage;
696 };
698 /**
699  * Commonly used audio stream configuration parameters.
700  */
701 struct AudioConfig {
702     uint32_t sampleRateHz;
703     bitfield<AudioChannelMask> channelMask;
704     AudioFormat format;
705     AudioOffloadInfo offloadInfo;
706     uint64_t frameCount;
707 };
710 /*
711  *
712  *  Volume control
713  *
714  */
716 /**
717  * Type of gain control exposed by an audio port.
718  */
719 @export(name="", value_prefix="AUDIO_GAIN_MODE_")
720 enum AudioGainMode : uint32_t {
721     JOINT = 0x1,    // supports joint channel gain control
722     CHANNELS = 0x2, // supports separate channel gain control
723     RAMP = 0x4      // supports gain ramps
724 };
726 /**
727  * An audio_gain struct is a representation of a gain stage.
728  * A gain stage is always attached to an audio port.
729  */
730 struct AudioGain {
731     bitfield<AudioGainMode> mode;
732     bitfield<AudioChannelMask> channelMask; // channels which gain an be controlled
733     int32_t minValue;     // minimum gain value in millibels
734     int32_t maxValue;     // maximum gain value in millibels
735     int32_t defaultValue; // default gain value in millibels
736     uint32_t stepValue;   // gain step in millibels
737     uint32_t minRampMs;   // minimum ramp duration in ms
738     uint32_t maxRampMs;   // maximum ramp duration in ms
739 };
741 /**
742  * The gain configuration structure is used to get or set the gain values of a
743  * given port.
744  */
745 struct AudioGainConfig {
746     int32_t index;  // index of the corresponding AudioGain in AudioPort.gains
747     AudioGainMode mode;
748     AudioChannelMask channelMask;  // channels which gain value follows
749     /**
750      * 4 = sizeof(AudioChannelMask),
751      * 8 is not "FCC_8", so it won't need to be changed for > 8 channels.
752      * Gain values in millibels for each channel ordered from LSb to MSb in
753      * channel mask. The number of values is 1 in joint mode or
754      * popcount(channel_mask).
755      */
756     int32_t[4 * 8] values;
757     uint32_t rampDurationMs;  // ramp duration in ms
758 };
761 /*
762  *
763  *  Routing control
764  *
765  */
767 /*
768  * Types defined here are used to describe an audio source or sink at internal
769  * framework interfaces (audio policy, patch panel) or at the audio HAL.
770  * Sink and sources are grouped in a concept of “audio port” representing an
771  * audio end point at the edge of the system managed by the module exposing
772  * the interface.
773  */
775 /** Audio port role: either source or sink */
776 @export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_")
777 enum AudioPortRole : int32_t {
778     NONE,
779     SOURCE,
780     SINK,
781 };
783 /**
784  * Audio port type indicates if it is a session (e.g AudioTrack), a mix (e.g
785  * PlaybackThread output) or a physical device (e.g OUT_SPEAKER)
786  */
787 @export(name="audio_port_type_t", value_prefix="AUDIO_PORT_TYPE_")
788 enum AudioPortType : int32_t {
789     NONE,
790     DEVICE,
791     MIX,
792     SESSION,
793 };
795 /**
796  * Extension for audio port configuration structure when the audio port is a
797  * hardware device.
798  */
799 struct AudioPortConfigDeviceExt {
800     AudioModuleHandle hwModule;  // module the device is attached to
801     AudioDevice type;            // device type (e.g OUT_SPEAKER)
802     uint8_t[32] address;         // device address. "" if N/A
803 };
805 /**
806  * Extension for audio port configuration structure when the audio port is an
807  * audio session.
808  */
809 struct AudioPortConfigSessionExt {
810     AudioSession session;
811 };
813 /**
814  * Flags indicating which fields are to be considered in AudioPortConfig.
815  */
816 @export(name="", value_prefix="AUDIO_PORT_CONFIG_")
817 enum AudioPortConfigMask : uint32_t {
818     SAMPLE_RATE = 0x1,
819     CHANNEL_MASK =  0x2,
820     FORMAT = 0x4,
821     GAIN = 0x8,
822 };
824 /**
825  * Audio port configuration structure used to specify a particular configuration
826  * of an audio port.
827  */
828 struct AudioPortConfig {
829     AudioPortHandle id;
830     bitfield<AudioPortConfigMask> configMask;
831     uint32_t sampleRateHz;
832     bitfield<AudioChannelMask> channelMask;
833     AudioFormat format;
834     AudioGainConfig gain;
835     AudioPortType type;  // type is used as a discriminator for Ext union
836     AudioPortRole role;  // role is used as a discriminator for UseCase union
837     union Ext {
838         AudioPortConfigDeviceExt device;
839         struct AudioPortConfigMixExt {
840             AudioModuleHandle hwModule; // module the stream is attached to
841             AudioIoHandle ioHandle;     // I/O handle of the input/output stream
842             union UseCase {
843                 AudioStreamType stream;
844                 AudioSource source;
845             } useCase;
846         } mix;
847         AudioPortConfigSessionExt session;
848     } ext;
849 };
851 /**
852  * Extension for audio port structure when the audio port is a hardware device.
853  */
854 struct AudioPortDeviceExt {
855     AudioModuleHandle hwModule;    // module the device is attached to
856     AudioDevice type;
857     /** 32 byte string identifying the port. */
858     uint8_t[32] address;
859 };
861 /**
862  * Latency class of the audio mix.
863  */
864 @export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_")
865 enum AudioMixLatencyClass : int32_t {
866     LOW,
867     NORMAL
868 };
870 struct AudioPortMixExt {
871     AudioModuleHandle hwModule;     // module the stream is attached to
872     AudioIoHandle ioHandle;         // I/O handle of the stream
873     AudioMixLatencyClass latencyClass;
874 };
876 /**
877  * Extension for audio port structure when the audio port is an audio session.
878  */
879 struct AudioPortSessionExt {
880     AudioSession session;
881 };
883 struct AudioPort {
884     AudioPortHandle id;
885     AudioPortRole role;
886     string name;
887     vec<uint32_t> sampleRates;
888     vec<bitfield<AudioChannelMask>> channelMasks;
889     vec<AudioFormat> formats;
890     vec<AudioGain> gains;
891     AudioPortConfig activeConfig; // current audio port configuration
892     AudioPortType type;  // type is used as a discriminator
893     union Ext {
894         AudioPortDeviceExt device;
895         AudioPortMixExt mix;
896         AudioPortSessionExt session;
897     } ext;
898 };
900 struct ThreadInfo {
901     int64_t pid;
902     int64_t tid;
903 };