1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.common@7.0;
import android.hidl.safe_union@1.0;
/**
* Handle type for identifying audio resources. Handles are allocated by the framework.
*/
typedef int32_t AudioIoHandle;
/**
* Each port has a unique ID or handle allocated by policy manager.
*/
typedef int32_t AudioPortHandle;
/**
* Each patch is identified by a handle allocated by the HAL.
*/
typedef int32_t AudioPatchHandle;
/**
* A HW synchronization source returned by the audio HAL.
*/
typedef uint32_t AudioHwSync;
/**
* Commonly used structure for passing unique identifieds (UUID).
* For the definition of UUID, refer to ITU-T X.667 spec.
*/
struct Uuid {
uint32_t timeLow;
uint16_t timeMid;
uint16_t versionAndTimeHigh;
uint16_t variantAndClockSeqHigh;
uint8_t[6] node;
};
/*
*
* Audio streams
*
*/
/**
* Audio stream type describing the intended use case of a stream.
* See 'audioStreamType' in audio_policy_configuration.xsd for the
* list of allowed values.
*
* An empty string is used to specify the "default" stream type.
*/
typedef string AudioStreamType;
/**
* An audio source defines the intended use case for the sound being recorded.
* See 'audioSource' in audio_policy_configuration.xsd for the
* list of allowed values.
*/
typedef string AudioSource;
/**
* An audio session identifier is used to designate the particular
* playback or recording session (e.g. playback performed by a certain
* application).
*/
typedef int32_t AudioSession;
@export(name="", value_prefix="HAL_AUDIO_SESSION_")
enum AudioSessionConsts : int32_t {
/**
* Session for effects attached to a particular sink or source audio device
* (e.g an effect only applied to a speaker)
*/
DEVICE = -2,
/**
* Session for effects attached to a particular output stream
* (value must be less than 0)
*/
OUTPUT_STAGE = -1,
/**
* Session for effects applied to output mix. These effects can
* be moved by audio policy manager to another output stream
* (value must be 0)
*/
OUTPUT_MIX = 0,
};
/**
* Audio format indicates audio codec type.
* See 'audioFormat' in audio_policy_configuration.xsd for the
* list of allowed values.
*/
typedef string AudioFormat;
/**
* Audio channel mask indicates presence of particular channels.
* Note that every value is already a mask comprised of individual
* channels.
* See 'audioChannelMask' in audio_policy_configuration.xsd for the
* list of allowed values.
*/
typedef string AudioChannelMask;
/**
* Base configuration attributes applicable to any stream of audio.
*/
struct AudioConfigBase {
AudioFormat format;
uint32_t sampleRateHz;
AudioChannelMask channelMask;
};
/**
* Base configuration attributes applicable to any stream of audio.
* Any attribute may be left unspecified.
*/
struct AudioConfigBaseOptional {
safe_union Format {
Monostate unspecified;
AudioFormat value;
} format;
safe_union SampleRate {
Monostate unspecified;
uint32_t value;
} sampleRateHz;
safe_union ChannelMask {
Monostate unspecified;
AudioChannelMask value;
} channelMask;
};
/**
* Audio encapsulation type indicates the encapsulation type that is required
* for playback/capture.
* See 'audioEncapsulationType' in audio_policy_configuration.xsd for the list
* of allowed values.
*/
typedef string AudioEncapsulationType;
/**
* Configurations supported for a certain audio format.
*/
struct AudioProfile {
AudioFormat format;
/** List of the sample rates (in Hz) supported by the profile. */
vec<uint32_t> sampleRates;
/** List of channel masks supported by the profile. */
vec<AudioChannelMask> channelMasks;
};
/**
* AudioTransport struct describes the capability of an audio port. The
* capability is described via AudioProfile or raw hardware descriptors for
* for formats that are not supported by the platform.
*/
struct AudioTransport {
safe_union AudioCapability {
/**
* A certain audio format that is known by the platform and its
* corresponding configuration.
*/
AudioProfile profile;
/**
* The audio descriptor that is reported from EDID. See HDMI
* specification 1.4b section 7 and CEA-861-G section 7.5.2 for more
* information. When this value is set, it indicates the standard is
* AUDIO_STANDARD_EDID.
*/
vec<uint8_t> edid;
} audioCapability;
/**
* The encapsulation type that is required when the framework is using this
* format when playing or capturing to/from a stream or device exposing this
* audio transport.
*/
AudioEncapsulationType encapsulationType;
};
/**
* Major modes for a mobile device. The current mode setting affects audio
* routing.
*/
@export(name="", value_prefix="HAL_AUDIO_MODE_")
enum AudioMode : int32_t {
NORMAL = 0,
RINGTONE = 1,
/** Calls handled by the telephony stack (Eg: PSTN). */
IN_CALL = 2,
/** Calls handled by apps (Eg: Hangout). */
IN_COMMUNICATION = 3,
/** Call screening in progress. */
CALL_SCREEN = 4,
};
/**
* Audio device specifies type (or category) of audio I/O device
* (e.g. speaker or headphones).
* See 'audioDevice' in audio_policy_configuration.xsd for the
* list of allowed values.
*/
typedef string AudioDevice;
/**
* Specifies a device address in case when several devices of the same type
* can be connected (e.g. BT A2DP, USB).
*/
struct DeviceAddress {
/** The type of the device. */
AudioDevice deviceType;
safe_union Address {
/**
* String uniquely identifying the device among other devices
* of the same type. Can be empty in case there is only one device
* of this type.
*
* Depending on the device type, its id may be assigned by the framework
* (this is done for REMOTE_SUBMIX), or specified in the audio policy
* configuration file (typically done for BUS devices), or assigned
* by the HAL service. In any case, both framework and HAL must
* never attempt to parse the value of the id. If the address must
* be parsed, one of the members below must be used instead of 'id'.
*/
string id;
/** IEEE 802 MAC address. Set for Bluetooth devices. */
uint8_t[6] mac;
/** IPv4 Address. Set for IPv4 devices. */
uint8_t[4] ipv4;
/** IPv6 Address. Set for IPv6 devices. */
uint16_t[8] ipv6;
/** PCI bus Address. Set for USB devices. */
struct Alsa {
int32_t card;
int32_t device;
} alsa;
} address;
};
/**
* Audio usage specifies the intended use case for the sound being played.
* See 'audioUsage' in audio_policy_configuration.xsd for the
* list of allowed values.
*/
typedef string AudioUsage;
/**
* Audio content type expresses the general category of the content.
* See 'audioContentType' in audio_policy_configuration.xsd for the
* list of allowed values.
*/
typedef string AudioContentType;
/** Encapsulation mode used for sending audio compressed data. */
@export(name="audio_encapsulation_mode_t", value_prefix="AUDIO_ENCAPSULATION_MODE_")
enum AudioEncapsulationMode : int32_t {
// Do not change these values without updating their counterparts
// in frameworks/base/media/java/android/media/AudioTrack.java
/**
* No encapsulation mode for metadata.
*/
NONE = 0,
/**
* Elementary stream payload with metadata
*/
ELEMENTARY_STREAM = 1,
/**
* Handle-based payload with metadata
*/
HANDLE = 2,
};
/**
* Enumeration of metadata types permitted for use by
* encapsulation mode audio streams.
*/
@export(name="audio_encapsulation_metadata_type_t", value_prefix="AUDIO_ENCAPSULATION_METADATA_TYPE_")
enum AudioEncapsulationMetadataType : int32_t {
/**
* No metadata.
*/
NONE = 0,
/**
* Encapsulation metadata type for framework tuner information.
*/
FRAMEWORK_TUNER = 1,
/**
* Encapsulation metadata type for DVB AD descriptor.
* This metadata is formatted per ETSI TS 101 154 Table E.1: AD_descriptor.
*/
DVB_AD_DESCRIPTOR = 2,
};
/**
* Additional information about the stream passed to hardware decoders.
*/
struct AudioOffloadInfo {
AudioConfigBase base;
AudioStreamType streamType;
uint32_t bitRatePerSecond;
int64_t durationMicroseconds; // -1 if unknown
bool hasVideo;
bool isStreaming;
uint32_t bitWidth;
uint32_t bufferSize;
AudioUsage usage;
AudioEncapsulationMode encapsulationMode;
int32_t contentId;
int32_t syncId;
};
/**
* Commonly used audio stream configuration parameters.
*/
struct AudioConfig {
AudioConfigBase base;
safe_union OffloadInfo {
Monostate unspecified;
AudioOffloadInfo info;
} offloadInfo;
uint64_t frameCount;
};
/**
* AudioTag is an additional use case qualifier complementing
* AudioUsage and AudioContentType. Tags are set by vendor specific applications
* and must be prefixed by "VX_". Vendor must namespace their tag
* names to avoid conflicts. See 'vendorExtension' in audio_policy_configuration.xsd
* for a formal definition.
*/
typedef string AudioTag;
/** Metadata of a playback track for a StreamOut. */
struct PlaybackTrackMetadata {
AudioUsage usage;
AudioContentType contentType;
/**
* Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
* 2 means double amplification...
* Must not be negative.
*/
float gain;
AudioChannelMask channelMask;
/** Tags from AudioTrack audio atttributes */
vec<AudioTag> tags;
};
/** Metadatas of the source of a StreamOut. */
struct SourceMetadata {
vec<PlaybackTrackMetadata> tracks;
};
/** Metadata of a record track for a StreamIn. */
struct RecordTrackMetadata {
AudioSource source;
/**
* Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
* 2 means double amplification...
* Must not be negative.
*/
float gain;
/**
* Indicates the destination of an input stream, can be left unspecified.
*/
safe_union Destination {
Monostate unspecified;
DeviceAddress device;
} destination;
AudioChannelMask channelMask;
/** Tags from AudioRecord audio atttributes */
vec<AudioTag> tags;
};
/** Metadatas of the sink of a StreamIn. */
struct SinkMetadata {
vec<RecordTrackMetadata> tracks;
};
/*
*
* Volume control
*
*/
/**
* Type of gain control exposed by an audio port.
* See 'audioGainMode' in audio_policy_configuration.xsd for the
* list of allowed values.
*/
typedef string AudioGainMode;
/**
* An audio_gain struct is a representation of a gain stage.
* A gain stage is always attached to an audio port.
*/
struct AudioGain {
/** Modes of operation. */
vec<AudioGainMode> mode;
/** Channels which gain can be controlled. */
AudioChannelMask channelMask;
/** Minimum gain value in millibels. */
int32_t minValue;
/** Maximum gain value in millibels. */
int32_t maxValue;
/** Default gain value in millibels. */
int32_t defaultValue;
/** Gain step in millibels. */
uint32_t stepValue;
/** Ramp duration in ms. */
uint32_t minRampMs;
/** Maximum ramp duration in ms. */
uint32_t maxRampMs;
};
/**
* The gain configuration structure is used to get or set the gain values of a
* given port.
*/
struct AudioGainConfig {
/** Index of the corresponding AudioGain in AudioPort.gains. */
int32_t index;
/** Modes of operation. */
vec<AudioGainMode> mode;
/** Channels which gain value follows. */
AudioChannelMask channelMask;
/**
* Gain values in millibels for each channel ordered from LSb to MSb in
* channel mask. The number of values is 1 in joint mode or
* the number of channels in the channel mask.
*/
vec<int32_t> values;
/** Ramp duration in ms. */
uint32_t rampDurationMs;
};
/*
*
* Routing control
*
*/
/*
* Types defined here are used to describe an audio source or sink at internal
* framework interfaces (audio policy, patch panel) or at the audio HAL.
* Sink and sources are grouped in a concept of “audio port” representing an
* audio end point at the edge of the system managed by the module exposing
* the interface.
*/
/**
* A helper aggregate structure providing parameters that depend on the
* port role.
*/
safe_union AudioPortExtendedInfo {
/** Set when no information is provided. */
Monostate unspecified;
/** Set when the audio port is an audio device. */
DeviceAddress device;
/** Set when the audio port is a mix. The handle is of a stream. */
struct AudioPortMixExt {
/** I/O handle of the input/output stream. */
AudioIoHandle ioHandle;
safe_union UseCase {
/** Specified when the port is in the SOURCE role. */
AudioStreamType stream;
/** Specified when the port is in the SINK role. */
AudioSource source;
} useCase;
} mix;
/** Set when the audio port is an audio session. */
AudioSession session;
};
/**
* Audio port configuration structure used to specify a particular configuration
* of an audio port.
*/
struct AudioPortConfig {
/**
* The 'id' field is set when it is needed to select the port and
* apply new configuration for it.
*/
AudioPortHandle id;
/**
* Basic parameters: sampling rate, format, channel mask.
*/
AudioConfigBaseOptional base;
/** Associated gain control. */
safe_union OptionalGain {
Monostate unspecified;
AudioGainConfig config;
} gain;
/** Parameters that depend on the actual port role. */
AudioPortExtendedInfo ext;
};
/**
* Audio port structure describes the capabilities of an audio port
* as well as its current configuration.
*/
struct AudioPort {
/**
* Unique identifier of the port within this HAL service. When calling
* from the client side functions like IDevice.getAudioPort is it allowed
* to only specify the 'id' and leave the other fields unspecified.
*/
AudioPortHandle id;
/**
* Human-readable name describing the function of the port.
* E.g. "telephony_tx" or "fm_tuner".
*/
string name;
/**
* List of audio transports supported by the audio port. This includes
* supported formats and raw hardware descriptors for formats not supported
* by the platform.
*/
vec<AudioTransport> transports;
/** List of gain controls attached to the port. */
vec<AudioGain> gains;
/** Parameters that depend on the actual port role. */
AudioPortExtendedInfo ext;
/**
* Current configuration of the audio port, may have all the fields left
* unspecified.
*/
AudioPortConfig activeConfig;
};
|