OSDN Git Service

f68cd8c160bd66bd5829e51923e1641961f37377
[android-x86/system-media.git] / audio / include / system / audio.h
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef ANDROID_AUDIO_CORE_H
19 #define ANDROID_AUDIO_CORE_H
20
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <stdio.h>
24 #include <sys/cdefs.h>
25 #include <sys/types.h>
26
27 #include <cutils/bitops.h>
28
29 #include "audio-base.h"
30
31 __BEGIN_DECLS
32
33 /* The enums were moved here mostly from
34  * frameworks/base/include/media/AudioSystem.h
35  */
36
37 /* represents an invalid uid for tracks; the calling or client uid is often substituted. */
38 #define AUDIO_UID_INVALID ((uid_t)-1)
39
40 /* device address used to refer to the standard remote submix */
41 #define AUDIO_REMOTE_SUBMIX_DEVICE_ADDRESS "0"
42
43 /* AudioFlinger and AudioPolicy services use I/O handles to identify audio sources and sinks */
44 typedef int audio_io_handle_t;
45
46 /* Do not change these values without updating their counterparts
47  * in frameworks/base/media/java/android/media/AudioAttributes.java
48  */
49 typedef enum {
50     AUDIO_CONTENT_TYPE_UNKNOWN      = 0,
51     AUDIO_CONTENT_TYPE_SPEECH       = 1,
52     AUDIO_CONTENT_TYPE_MUSIC        = 2,
53     AUDIO_CONTENT_TYPE_MOVIE        = 3,
54     AUDIO_CONTENT_TYPE_SONIFICATION = 4,
55
56     AUDIO_CONTENT_TYPE_CNT,
57     AUDIO_CONTENT_TYPE_MAX          = AUDIO_CONTENT_TYPE_CNT - 1,
58 } audio_content_type_t;
59
60 typedef uint32_t audio_flags_mask_t;
61
62 /* Do not change these values without updating their counterparts
63  * in frameworks/base/media/java/android/media/AudioAttributes.java
64  */
65 enum {
66     AUDIO_FLAG_NONE                       = 0x0,
67     AUDIO_FLAG_AUDIBILITY_ENFORCED        = 0x1,
68     AUDIO_FLAG_SECURE                     = 0x2,
69     AUDIO_FLAG_SCO                        = 0x4,
70     AUDIO_FLAG_BEACON                     = 0x8,
71     AUDIO_FLAG_HW_AV_SYNC                 = 0x10,
72     AUDIO_FLAG_HW_HOTWORD                 = 0x20,
73     AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY = 0x40,
74     AUDIO_FLAG_BYPASS_MUTE                = 0x80,
75     AUDIO_FLAG_LOW_LATENCY                = 0x100,
76     AUDIO_FLAG_DEEP_BUFFER                = 0x200,
77 };
78
79 /* Audio attributes */
80 #define AUDIO_ATTRIBUTES_TAGS_MAX_SIZE 256
81 typedef struct {
82     audio_content_type_t content_type;
83     audio_usage_t        usage;
84     audio_source_t       source;
85     audio_flags_mask_t   flags;
86     char                 tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */
87 } __attribute__((packed)) audio_attributes_t; // sent through Binder;
88
89 /* a unique ID allocated by AudioFlinger for use as an audio_io_handle_t, audio_session_t,
90  * effect ID (int), audio_module_handle_t, and audio_patch_handle_t.
91  * Audio port IDs (audio_port_handle_t) are allocated by AudioPolicy
92  * in a different namespace than AudioFlinger unique IDs.
93  */
94 typedef int audio_unique_id_t;
95
96 /* Possible uses for an audio_unique_id_t */
97 typedef enum {
98     AUDIO_UNIQUE_ID_USE_UNSPECIFIED = 0,
99     AUDIO_UNIQUE_ID_USE_SESSION = 1,    // for allocated sessions, not special AUDIO_SESSION_*
100     AUDIO_UNIQUE_ID_USE_MODULE = 2,
101     AUDIO_UNIQUE_ID_USE_EFFECT = 3,
102     AUDIO_UNIQUE_ID_USE_PATCH = 4,
103     AUDIO_UNIQUE_ID_USE_OUTPUT = 5,
104     AUDIO_UNIQUE_ID_USE_INPUT = 6,
105     AUDIO_UNIQUE_ID_USE_PLAYER = 7,
106     AUDIO_UNIQUE_ID_USE_MAX = 8,  // must be a power-of-two
107     AUDIO_UNIQUE_ID_USE_MASK = AUDIO_UNIQUE_ID_USE_MAX - 1
108 } audio_unique_id_use_t;
109
110 /* Return the use of an audio_unique_id_t */
111 static inline audio_unique_id_use_t audio_unique_id_get_use(audio_unique_id_t id)
112 {
113     return (audio_unique_id_use_t) (id & AUDIO_UNIQUE_ID_USE_MASK);
114 }
115
116 /* Reserved audio_unique_id_t values.  FIXME: not a complete list. */
117 #define AUDIO_UNIQUE_ID_ALLOCATE AUDIO_SESSION_ALLOCATE
118
119 /* A channel mask per se only defines the presence or absence of a channel, not the order.
120  * But see AUDIO_INTERLEAVE_* below for the platform convention of order.
121  *
122  * audio_channel_mask_t is an opaque type and its internal layout should not
123  * be assumed as it may change in the future.
124  * Instead, always use the functions declared in this header to examine.
125  *
126  * These are the current representations:
127  *
128  *   AUDIO_CHANNEL_REPRESENTATION_POSITION
129  *     is a channel mask representation for position assignment.
130  *     Each low-order bit corresponds to the spatial position of a transducer (output),
131  *     or interpretation of channel (input).
132  *     The user of a channel mask needs to know the context of whether it is for output or input.
133  *     The constants AUDIO_CHANNEL_OUT_* or AUDIO_CHANNEL_IN_* apply to the bits portion.
134  *     It is not permitted for no bits to be set.
135  *
136  *   AUDIO_CHANNEL_REPRESENTATION_INDEX
137  *     is a channel mask representation for index assignment.
138  *     Each low-order bit corresponds to a selected channel.
139  *     There is no platform interpretation of the various bits.
140  *     There is no concept of output or input.
141  *     It is not permitted for no bits to be set.
142  *
143  * All other representations are reserved for future use.
144  *
145  * Warning: current representation distinguishes between input and output, but this will not the be
146  * case in future revisions of the platform. Wherever there is an ambiguity between input and output
147  * that is currently resolved by checking the channel mask, the implementer should look for ways to
148  * fix it with additional information outside of the mask.
149  */
150 typedef uint32_t audio_channel_mask_t;
151
152 /* log(2) of maximum number of representations, not part of public API */
153 #define AUDIO_CHANNEL_REPRESENTATION_LOG2   2
154
155 /* The return value is undefined if the channel mask is invalid. */
156 static inline uint32_t audio_channel_mask_get_bits(audio_channel_mask_t channel)
157 {
158     return channel & ((1 << AUDIO_CHANNEL_COUNT_MAX) - 1);
159 }
160
161 typedef uint32_t audio_channel_representation_t;
162
163 /* The return value is undefined if the channel mask is invalid. */
164 static inline audio_channel_representation_t audio_channel_mask_get_representation(
165         audio_channel_mask_t channel)
166 {
167     // The right shift should be sufficient, but also "and" for safety in case mask is not 32 bits
168     return (audio_channel_representation_t)
169             ((channel >> AUDIO_CHANNEL_COUNT_MAX) & ((1 << AUDIO_CHANNEL_REPRESENTATION_LOG2) - 1));
170 }
171
172 /* Returns true if the channel mask is valid,
173  * or returns false for AUDIO_CHANNEL_NONE, AUDIO_CHANNEL_INVALID, and other invalid values.
174  * This function is unable to determine whether a channel mask for position assignment
175  * is invalid because an output mask has an invalid output bit set,
176  * or because an input mask has an invalid input bit set.
177  * All other APIs that take a channel mask assume that it is valid.
178  */
179 static inline bool audio_channel_mask_is_valid(audio_channel_mask_t channel)
180 {
181     uint32_t bits = audio_channel_mask_get_bits(channel);
182     audio_channel_representation_t representation = audio_channel_mask_get_representation(channel);
183     switch (representation) {
184     case AUDIO_CHANNEL_REPRESENTATION_POSITION:
185     case AUDIO_CHANNEL_REPRESENTATION_INDEX:
186         break;
187     default:
188         bits = 0;
189         break;
190     }
191     return bits != 0;
192 }
193
194 /* Not part of public API */
195 static inline audio_channel_mask_t audio_channel_mask_from_representation_and_bits(
196         audio_channel_representation_t representation, uint32_t bits)
197 {
198     return (audio_channel_mask_t) ((representation << AUDIO_CHANNEL_COUNT_MAX) | bits);
199 }
200
201 /* This enum is deprecated */
202 typedef enum {
203     AUDIO_IN_ACOUSTICS_NONE          = 0,
204     AUDIO_IN_ACOUSTICS_AGC_ENABLE    = 0x0001,
205     AUDIO_IN_ACOUSTICS_AGC_DISABLE   = 0,
206     AUDIO_IN_ACOUSTICS_NS_ENABLE     = 0x0002,
207     AUDIO_IN_ACOUSTICS_NS_DISABLE    = 0,
208     AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004,
209     AUDIO_IN_ACOUSTICS_TX_DISABLE    = 0,
210 } audio_in_acoustics_t;
211
212 typedef uint32_t audio_devices_t;
213 /**
214  * Stub audio output device. Used in policy configuration file on platforms without audio outputs.
215  * This alias value to AUDIO_DEVICE_OUT_DEFAULT is only used in the audio policy context.
216  */
217 #define AUDIO_DEVICE_OUT_STUB AUDIO_DEVICE_OUT_DEFAULT
218 /**
219  * Stub audio input device. Used in policy configuration file on platforms without audio inputs.
220  * This alias value to AUDIO_DEVICE_IN_DEFAULT is only used in the audio policy context.
221  */
222 #define AUDIO_DEVICE_IN_STUB AUDIO_DEVICE_IN_DEFAULT
223
224 /* Additional information about compressed streams offloaded to
225  * hardware playback
226  * The version and size fields must be initialized by the caller by using
227  * one of the constants defined here.
228  * Must be aligned to transmit as raw memory through Binder.
229  */
230 typedef struct {
231     uint16_t version;                   // version of the info structure
232     uint16_t size;                      // total size of the structure including version and size
233     uint32_t sample_rate;               // sample rate in Hz
234     audio_channel_mask_t channel_mask;  // channel mask
235     audio_format_t format;              // audio format
236     audio_stream_type_t stream_type;    // stream type
237     uint32_t bit_rate;                  // bit rate in bits per second
238     int64_t duration_us;                // duration in microseconds, -1 if unknown
239     bool has_video;                     // true if stream is tied to a video stream
240     bool is_streaming;                  // true if streaming, false if local playback
241     uint32_t bit_width;
242     uint32_t offload_buffer_size;       // offload fragment size
243     audio_usage_t usage;
244 } __attribute__((aligned(8))) audio_offload_info_t;
245
246 #define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \
247             ((((maj) & 0xff) << 8) | ((min) & 0xff))
248
249 #define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1)
250 #define AUDIO_OFFLOAD_INFO_VERSION_CURRENT AUDIO_OFFLOAD_INFO_VERSION_0_1
251
252 static const audio_offload_info_t AUDIO_INFO_INITIALIZER = {
253     /* .version = */ AUDIO_OFFLOAD_INFO_VERSION_CURRENT,
254     /* .size = */ sizeof(audio_offload_info_t),
255     /* .sample_rate = */ 0,
256     /* .channel_mask = */ 0,
257     /* .format = */ AUDIO_FORMAT_DEFAULT,
258     /* .stream_type = */ AUDIO_STREAM_VOICE_CALL,
259     /* .bit_rate = */ 0,
260     /* .duration_us = */ 0,
261     /* .has_video = */ false,
262     /* .is_streaming = */ false,
263     /* .bit_width = */ 16,
264     /* .offload_buffer_size = */ 0,
265     /* .usage = */ AUDIO_USAGE_UNKNOWN
266 };
267
268 /* common audio stream configuration parameters
269  * You should memset() the entire structure to zero before use to
270  * ensure forward compatibility
271  * Must be aligned to transmit as raw memory through Binder.
272  */
273 struct __attribute__((aligned(8))) audio_config {
274     uint32_t sample_rate;
275     audio_channel_mask_t channel_mask;
276     audio_format_t  format;
277     audio_offload_info_t offload_info;
278     uint32_t frame_count;
279 };
280 typedef struct audio_config audio_config_t;
281
282 static const audio_config_t AUDIO_CONFIG_INITIALIZER = {
283     /* .sample_rate = */ 0,
284     /* .channel_mask = */ AUDIO_CHANNEL_NONE,
285     /* .format = */ AUDIO_FORMAT_DEFAULT,
286     /* .offload_info = */ {
287         /* .version = */ AUDIO_OFFLOAD_INFO_VERSION_CURRENT,
288         /* .size = */ sizeof(audio_offload_info_t),
289         /* .sample_rate = */ 0,
290         /* .channel_mask = */ 0,
291         /* .format = */ AUDIO_FORMAT_DEFAULT,
292         /* .stream_type = */ AUDIO_STREAM_VOICE_CALL,
293         /* .bit_rate = */ 0,
294         /* .duration_us = */ 0,
295         /* .has_video = */ false,
296         /* .is_streaming = */ false,
297         /* .bit_width = */ 16,
298         /* .offload_buffer_size = */ 0,
299         /* .usage = */ AUDIO_USAGE_UNKNOWN
300     },
301     /* .frame_count = */ 0,
302 };
303
304 struct audio_config_base {
305     uint32_t sample_rate;
306     audio_channel_mask_t channel_mask;
307     audio_format_t  format;
308 };
309
310 typedef struct audio_config_base audio_config_base_t;
311
312 static const audio_config_base_t AUDIO_CONFIG_BASE_INITIALIZER = {
313     /* .sample_rate = */ 0,
314     /* .channel_mask = */ AUDIO_CHANNEL_NONE,
315     /* .format = */ AUDIO_FORMAT_DEFAULT
316 };
317
318 /* audio hw module handle functions or structures referencing a module */
319 typedef int audio_module_handle_t;
320
321 /******************************
322  *  Volume control
323  *****************************/
324
325 /** 3 dB headroom are allowed on float samples (3db = 10^(3/20) = 1.412538).
326 * See: https://developer.android.com/reference/android/media/AudioTrack.html#write(float[], int, int, int)
327 */
328 #define FLOAT_NOMINAL_RANGE_HEADROOM 1.412538
329
330 /* If the audio hardware supports gain control on some audio paths,
331  * the platform can expose them in the audio_policy.conf file. The audio HAL
332  * will then implement gain control functions that will use the following data
333  * structures. */
334
335 typedef uint32_t audio_gain_mode_t;
336
337
338 /* An audio_gain struct is a representation of a gain stage.
339  * A gain stage is always attached to an audio port. */
340 struct audio_gain  {
341     audio_gain_mode_t    mode;          /* e.g. AUDIO_GAIN_MODE_JOINT */
342     audio_channel_mask_t channel_mask;  /* channels which gain an be controlled.
343                                            N/A if AUDIO_GAIN_MODE_CHANNELS is not supported */
344     int                  min_value;     /* minimum gain value in millibels */
345     int                  max_value;     /* maximum gain value in millibels */
346     int                  default_value; /* default gain value in millibels */
347     unsigned int         step_value;    /* gain step in millibels */
348     unsigned int         min_ramp_ms;   /* minimum ramp duration in ms */
349     unsigned int         max_ramp_ms;   /* maximum ramp duration in ms */
350 };
351
352 /* The gain configuration structure is used to get or set the gain values of a
353  * given port */
354 struct audio_gain_config  {
355     int                  index;             /* index of the corresponding audio_gain in the
356                                                audio_port gains[] table */
357     audio_gain_mode_t    mode;              /* mode requested for this command */
358     audio_channel_mask_t channel_mask;      /* channels which gain value follows.
359                                                N/A in joint mode */
360
361     // note this "8" is not FCC_8, so it won't need to be changed for > 8 channels
362     int                  values[sizeof(audio_channel_mask_t) * 8]; /* gain values in millibels
363                                                for each channel ordered from LSb to MSb in
364                                                channel mask. The number of values is 1 in joint
365                                                mode or popcount(channel_mask) */
366     unsigned int         ramp_duration_ms; /* ramp duration in ms */
367 };
368
369 /******************************
370  *  Routing control
371  *****************************/
372
373 /* Types defined here are used to describe an audio source or sink at internal
374  * framework interfaces (audio policy, patch panel) or at the audio HAL.
375  * Sink and sources are grouped in a concept of “audio port” representing an
376  * audio end point at the edge of the system managed by the module exposing
377  * the interface. */
378
379 /* Each port has a unique ID or handle allocated by policy manager */
380 typedef int audio_port_handle_t;
381
382 /* the maximum length for the human-readable device name */
383 #define AUDIO_PORT_MAX_NAME_LEN 128
384
385 /* maximum audio device address length */
386 #define AUDIO_DEVICE_MAX_ADDRESS_LEN 32
387
388 /* extension for audio port configuration structure when the audio port is a
389  * hardware device */
390 struct audio_port_config_device_ext {
391     audio_module_handle_t hw_module;                /* module the device is attached to */
392     audio_devices_t       type;                     /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */
393     char                  address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; /* device address. "" if N/A */
394 };
395
396 /* extension for audio port configuration structure when the audio port is a
397  * sub mix */
398 struct audio_port_config_mix_ext {
399     audio_module_handle_t hw_module;    /* module the stream is attached to */
400     audio_io_handle_t handle;           /* I/O handle of the input/output stream */
401     union {
402         //TODO: change use case for output streams: use strategy and mixer attributes
403         audio_stream_type_t stream;
404         audio_source_t      source;
405     } usecase;
406 };
407
408 /* extension for audio port configuration structure when the audio port is an
409  * audio session */
410 struct audio_port_config_session_ext {
411     audio_session_t   session; /* audio session */
412 };
413
414 /* audio port configuration structure used to specify a particular configuration of
415  * an audio port */
416 struct audio_port_config {
417     audio_port_handle_t      id;           /* port unique ID */
418     audio_port_role_t        role;         /* sink or source */
419     audio_port_type_t        type;         /* device, mix ... */
420     unsigned int             config_mask;  /* e.g AUDIO_PORT_CONFIG_ALL */
421     unsigned int             sample_rate;  /* sampling rate in Hz */
422     audio_channel_mask_t     channel_mask; /* channel mask if applicable */
423     audio_format_t           format;       /* format if applicable */
424     struct audio_gain_config gain;         /* gain to apply if applicable */
425     union {
426         struct audio_port_config_device_ext  device;  /* device specific info */
427         struct audio_port_config_mix_ext     mix;     /* mix specific info */
428         struct audio_port_config_session_ext session; /* session specific info */
429     } ext;
430 };
431
432
433 /* max number of sampling rates in audio port */
434 #define AUDIO_PORT_MAX_SAMPLING_RATES 32
435 /* max number of channel masks in audio port */
436 #define AUDIO_PORT_MAX_CHANNEL_MASKS 32
437 /* max number of audio formats in audio port */
438 #define AUDIO_PORT_MAX_FORMATS 32
439 /* max number of gain controls in audio port */
440 #define AUDIO_PORT_MAX_GAINS 16
441
442 /* extension for audio port structure when the audio port is a hardware device */
443 struct audio_port_device_ext {
444     audio_module_handle_t hw_module;    /* module the device is attached to */
445     audio_devices_t       type;         /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */
446     char                  address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
447 };
448
449 /* extension for audio port structure when the audio port is a sub mix */
450 struct audio_port_mix_ext {
451     audio_module_handle_t     hw_module;     /* module the stream is attached to */
452     audio_io_handle_t         handle;        /* I/O handle of the input.output stream */
453     audio_mix_latency_class_t latency_class; /* latency class */
454     // other attributes: routing strategies
455 };
456
457 /* extension for audio port structure when the audio port is an audio session */
458 struct audio_port_session_ext {
459     audio_session_t   session; /* audio session */
460 };
461
462 struct audio_port {
463     audio_port_handle_t      id;                /* port unique ID */
464     audio_port_role_t        role;              /* sink or source */
465     audio_port_type_t        type;              /* device, mix ... */
466     char                     name[AUDIO_PORT_MAX_NAME_LEN];
467     unsigned int             num_sample_rates;  /* number of sampling rates in following array */
468     unsigned int             sample_rates[AUDIO_PORT_MAX_SAMPLING_RATES];
469     unsigned int             num_channel_masks; /* number of channel masks in following array */
470     audio_channel_mask_t     channel_masks[AUDIO_PORT_MAX_CHANNEL_MASKS];
471     unsigned int             num_formats;       /* number of formats in following array */
472     audio_format_t           formats[AUDIO_PORT_MAX_FORMATS];
473     unsigned int             num_gains;         /* number of gains in following array */
474     struct audio_gain        gains[AUDIO_PORT_MAX_GAINS];
475     struct audio_port_config active_config;     /* current audio port configuration */
476     union {
477         struct audio_port_device_ext  device;
478         struct audio_port_mix_ext     mix;
479         struct audio_port_session_ext session;
480     } ext;
481 };
482
483 /* An audio patch represents a connection between one or more source ports and
484  * one or more sink ports. Patches are connected and disconnected by audio policy manager or by
485  * applications via framework APIs.
486  * Each patch is identified by a handle at the interface used to create that patch. For instance,
487  * when a patch is created by the audio HAL, the HAL allocates and returns a handle.
488  * This handle is unique to a given audio HAL hardware module.
489  * But the same patch receives another system wide unique handle allocated by the framework.
490  * This unique handle is used for all transactions inside the framework.
491  */
492 typedef int audio_patch_handle_t;
493
494 #define AUDIO_PATCH_PORTS_MAX   16
495
496 struct audio_patch {
497     audio_patch_handle_t id;            /* patch unique ID */
498     unsigned int      num_sources;      /* number of sources in following array */
499     struct audio_port_config sources[AUDIO_PATCH_PORTS_MAX];
500     unsigned int      num_sinks;        /* number of sinks in following array */
501     struct audio_port_config sinks[AUDIO_PATCH_PORTS_MAX];
502 };
503
504
505
506 /* a HW synchronization source returned by the audio HAL */
507 typedef uint32_t audio_hw_sync_t;
508
509 /* an invalid HW synchronization source indicating an error */
510 #define AUDIO_HW_SYNC_INVALID 0
511
512 /**
513  * Mmap buffer descriptor returned by audio_stream->create_mmap_buffer().
514  * note\ Used by streams opened in mmap mode.
515  */
516 struct audio_mmap_buffer_info {
517     void*   shared_memory_address;  /**< base address of mmap memory buffer.
518                                          For use by local process only */
519     int32_t shared_memory_fd;       /**< FD for mmap memory buffer */
520     int32_t buffer_size_frames;     /**< total buffer size in frames */
521     int32_t burst_size_frames;      /**< transfer size granularity in frames */
522 };
523
524 /**
525  * Mmap buffer read/write position returned by audio_stream->get_mmap_position().
526  * note\ Used by streams opened in mmap mode.
527  */
528 struct audio_mmap_position {
529     int64_t  time_nanoseconds; /**< timestamp in ns, CLOCK_MONOTONIC */
530     int32_t  position_frames;  /**< increasing 32 bit frame count reset when stream->stop()
531                                     is called */
532 };
533
534 static inline bool audio_is_output_device(audio_devices_t device)
535 {
536     if (((device & AUDIO_DEVICE_BIT_IN) == 0) &&
537             (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
538         return true;
539     else
540         return false;
541 }
542
543 static inline bool audio_is_input_device(audio_devices_t device)
544 {
545     if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
546         device &= ~AUDIO_DEVICE_BIT_IN;
547         if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0))
548             return true;
549     }
550     return false;
551 }
552
553 static inline bool audio_is_output_devices(audio_devices_t device)
554 {
555     return (device & AUDIO_DEVICE_BIT_IN) == 0;
556 }
557
558 static inline bool audio_is_a2dp_in_device(audio_devices_t device)
559 {
560     if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
561         device &= ~AUDIO_DEVICE_BIT_IN;
562         if ((popcount(device) == 1) && (device & AUDIO_DEVICE_IN_BLUETOOTH_A2DP))
563             return true;
564     }
565     return false;
566 }
567
568 static inline bool audio_is_a2dp_out_device(audio_devices_t device)
569 {
570     if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP))
571         return true;
572     else
573         return false;
574 }
575
576 // Deprecated - use audio_is_a2dp_out_device() instead
577 static inline bool audio_is_a2dp_device(audio_devices_t device)
578 {
579     return audio_is_a2dp_out_device(device);
580 }
581
582 static inline bool audio_is_bluetooth_sco_device(audio_devices_t device)
583 {
584     if ((device & AUDIO_DEVICE_BIT_IN) == 0) {
585         if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL_SCO) == 0))
586             return true;
587     } else {
588         device &= ~AUDIO_DEVICE_BIT_IN;
589         if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) == 0))
590             return true;
591     }
592
593     return false;
594 }
595
596 static inline bool audio_is_usb_out_device(audio_devices_t device)
597 {
598     return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB));
599 }
600
601 static inline bool audio_is_usb_in_device(audio_devices_t device)
602 {
603     if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
604         device &= ~AUDIO_DEVICE_BIT_IN;
605         if (popcount(device) == 1 && (device & AUDIO_DEVICE_IN_ALL_USB) != 0)
606             return true;
607     }
608     return false;
609 }
610
611 /* OBSOLETE - use audio_is_usb_out_device() instead. */
612 static inline bool audio_is_usb_device(audio_devices_t device)
613 {
614     return audio_is_usb_out_device(device);
615 }
616
617 static inline bool audio_is_remote_submix_device(audio_devices_t device)
618 {
619     if ((audio_is_output_devices(device) &&
620          (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) == AUDIO_DEVICE_OUT_REMOTE_SUBMIX)
621         || (!audio_is_output_devices(device) &&
622          (device & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX))
623         return true;
624     else
625         return false;
626 }
627
628 /* Returns true if:
629  *  representation is valid, and
630  *  there is at least one channel bit set which _could_ correspond to an input channel, and
631  *  there are no channel bits set which could _not_ correspond to an input channel.
632  * Otherwise returns false.
633  */
634 static inline bool audio_is_input_channel(audio_channel_mask_t channel)
635 {
636     uint32_t bits = audio_channel_mask_get_bits(channel);
637     switch (audio_channel_mask_get_representation(channel)) {
638     case AUDIO_CHANNEL_REPRESENTATION_POSITION:
639         if (bits & ~AUDIO_CHANNEL_IN_ALL) {
640             bits = 0;
641         }
642         // fall through
643     case AUDIO_CHANNEL_REPRESENTATION_INDEX:
644         return bits != 0;
645     default:
646         return false;
647     }
648 }
649
650 /* Returns true if:
651  *  representation is valid, and
652  *  there is at least one channel bit set which _could_ correspond to an output channel, and
653  *  there are no channel bits set which could _not_ correspond to an output channel.
654  * Otherwise returns false.
655  */
656 static inline bool audio_is_output_channel(audio_channel_mask_t channel)
657 {
658     uint32_t bits = audio_channel_mask_get_bits(channel);
659     switch (audio_channel_mask_get_representation(channel)) {
660     case AUDIO_CHANNEL_REPRESENTATION_POSITION:
661         if (bits & ~AUDIO_CHANNEL_OUT_ALL) {
662             bits = 0;
663         }
664         // fall through
665     case AUDIO_CHANNEL_REPRESENTATION_INDEX:
666         return bits != 0;
667     default:
668         return false;
669     }
670 }
671
672 /* Returns the number of channels from an input channel mask,
673  * used in the context of audio input or recording.
674  * If a channel bit is set which could _not_ correspond to an input channel,
675  * it is excluded from the count.
676  * Returns zero if the representation is invalid.
677  */
678 static inline uint32_t audio_channel_count_from_in_mask(audio_channel_mask_t channel)
679 {
680     uint32_t bits = audio_channel_mask_get_bits(channel);
681     switch (audio_channel_mask_get_representation(channel)) {
682     case AUDIO_CHANNEL_REPRESENTATION_POSITION:
683         // TODO: We can now merge with from_out_mask and remove anding
684         bits &= AUDIO_CHANNEL_IN_ALL;
685         // fall through
686     case AUDIO_CHANNEL_REPRESENTATION_INDEX:
687         return popcount(bits);
688     default:
689         return 0;
690     }
691 }
692
693 /* Returns the number of channels from an output channel mask,
694  * used in the context of audio output or playback.
695  * If a channel bit is set which could _not_ correspond to an output channel,
696  * it is excluded from the count.
697  * Returns zero if the representation is invalid.
698  */
699 static inline uint32_t audio_channel_count_from_out_mask(audio_channel_mask_t channel)
700 {
701     uint32_t bits = audio_channel_mask_get_bits(channel);
702     switch (audio_channel_mask_get_representation(channel)) {
703     case AUDIO_CHANNEL_REPRESENTATION_POSITION:
704         // TODO: We can now merge with from_in_mask and remove anding
705         bits &= AUDIO_CHANNEL_OUT_ALL;
706         // fall through
707     case AUDIO_CHANNEL_REPRESENTATION_INDEX:
708         return popcount(bits);
709     default:
710         return 0;
711     }
712 }
713
714 /* Derive a channel mask for index assignment from a channel count.
715  * Returns the matching channel mask,
716  * or AUDIO_CHANNEL_NONE if the channel count is zero,
717  * or AUDIO_CHANNEL_INVALID if the channel count exceeds AUDIO_CHANNEL_COUNT_MAX.
718  */
719 static inline audio_channel_mask_t audio_channel_mask_for_index_assignment_from_count(
720         uint32_t channel_count)
721 {
722     if (channel_count == 0) {
723         return AUDIO_CHANNEL_NONE;
724     }
725     if (channel_count > AUDIO_CHANNEL_COUNT_MAX) {
726         return AUDIO_CHANNEL_INVALID;
727     }
728     uint32_t bits = (1 << channel_count) - 1;
729     return audio_channel_mask_from_representation_and_bits(
730             AUDIO_CHANNEL_REPRESENTATION_INDEX, bits);
731 }
732
733 /* Derive an output channel mask for position assignment from a channel count.
734  * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel
735  * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad,
736  * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC
737  * for continuity with stereo.
738  * Returns the matching channel mask,
739  * or AUDIO_CHANNEL_NONE if the channel count is zero,
740  * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the
741  * configurations for which a default output channel mask is defined.
742  */
743 static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count)
744 {
745     uint32_t bits;
746     switch (channel_count) {
747     case 0:
748         return AUDIO_CHANNEL_NONE;
749     case 1:
750         bits = AUDIO_CHANNEL_OUT_MONO;
751         break;
752     case 2:
753         bits = AUDIO_CHANNEL_OUT_STEREO;
754         break;
755     case 3:
756         bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER;
757         break;
758     case 4: // 4.0
759         bits = AUDIO_CHANNEL_OUT_QUAD;
760         break;
761     case 5: // 5.0
762         bits = AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER;
763         break;
764     case 6: // 5.1
765         bits = AUDIO_CHANNEL_OUT_5POINT1;
766         break;
767     case 7: // 6.1
768         bits = AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER;
769         break;
770     case 8:
771         bits = AUDIO_CHANNEL_OUT_7POINT1;
772         break;
773     // FIXME FCC_8
774     default:
775         return AUDIO_CHANNEL_INVALID;
776     }
777     return audio_channel_mask_from_representation_and_bits(
778             AUDIO_CHANNEL_REPRESENTATION_POSITION, bits);
779 }
780
781 /* Derive a default input channel mask from a channel count.
782  * Assumes a position mask for mono and stereo, or an index mask for channel counts > 2.
783  * Returns the matching channel mask,
784  * or AUDIO_CHANNEL_NONE if the channel count is zero,
785  * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the
786  * configurations for which a default input channel mask is defined.
787  */
788 static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count)
789 {
790     uint32_t bits;
791     switch (channel_count) {
792     case 0:
793         return AUDIO_CHANNEL_NONE;
794     case 1:
795         bits = AUDIO_CHANNEL_IN_MONO;
796         break;
797     case 2:
798         bits = AUDIO_CHANNEL_IN_STEREO;
799         break;
800     case 3:
801     case 4:
802     case 5:
803     case 6:
804     case 7:
805     case 8:
806         // FIXME FCC_8
807         return audio_channel_mask_for_index_assignment_from_count(channel_count);
808     default:
809         return AUDIO_CHANNEL_INVALID;
810     }
811     return audio_channel_mask_from_representation_and_bits(
812             AUDIO_CHANNEL_REPRESENTATION_POSITION, bits);
813 }
814
815 static inline bool audio_is_valid_format(audio_format_t format)
816 {
817     switch (format & AUDIO_FORMAT_MAIN_MASK) {
818     case AUDIO_FORMAT_PCM:
819         switch (format) {
820         case AUDIO_FORMAT_PCM_16_BIT:
821         case AUDIO_FORMAT_PCM_8_BIT:
822         case AUDIO_FORMAT_PCM_32_BIT:
823         case AUDIO_FORMAT_PCM_8_24_BIT:
824         case AUDIO_FORMAT_PCM_FLOAT:
825         case AUDIO_FORMAT_PCM_24_BIT_PACKED:
826             return true;
827         default:
828             return false;
829         }
830         /* not reached */
831     case AUDIO_FORMAT_MP3:
832     case AUDIO_FORMAT_AMR_NB:
833     case AUDIO_FORMAT_AMR_WB:
834     case AUDIO_FORMAT_AAC:
835     case AUDIO_FORMAT_AAC_ADTS:
836     case AUDIO_FORMAT_HE_AAC_V1:
837     case AUDIO_FORMAT_HE_AAC_V2:
838     case AUDIO_FORMAT_VORBIS:
839     case AUDIO_FORMAT_OPUS:
840     case AUDIO_FORMAT_AC3:
841     case AUDIO_FORMAT_E_AC3:
842     case AUDIO_FORMAT_DTS:
843     case AUDIO_FORMAT_DTS_HD:
844     case AUDIO_FORMAT_IEC61937:
845     case AUDIO_FORMAT_DOLBY_TRUEHD:
846     case AUDIO_FORMAT_QCELP:
847     case AUDIO_FORMAT_EVRC:
848     case AUDIO_FORMAT_EVRCB:
849     case AUDIO_FORMAT_EVRCWB:
850     case AUDIO_FORMAT_AAC_ADIF:
851     case AUDIO_FORMAT_AMR_WB_PLUS:
852     case AUDIO_FORMAT_MP2:
853     case AUDIO_FORMAT_EVRCNW:
854     case AUDIO_FORMAT_FLAC:
855     case AUDIO_FORMAT_ALAC:
856     case AUDIO_FORMAT_APE:
857     case AUDIO_FORMAT_WMA:
858     case AUDIO_FORMAT_WMA_PRO:
859     case AUDIO_FORMAT_DSD:
860     case AUDIO_FORMAT_AC4:
861     case AUDIO_FORMAT_LDAC:
862         return true;
863     default:
864         return false;
865     }
866 }
867
868 /**
869  * Extract the primary format, eg. PCM, AC3, etc.
870  */
871 static inline audio_format_t audio_get_main_format(audio_format_t format)
872 {
873     return (audio_format_t)(format & AUDIO_FORMAT_MAIN_MASK);
874 }
875
876 /**
877  * Is the data plain PCM samples that can be scaled and mixed?
878  */
879 static inline bool audio_is_linear_pcm(audio_format_t format)
880 {
881     return (audio_get_main_format(format) == AUDIO_FORMAT_PCM);
882 }
883
884 /**
885  * For this format, is the number of PCM audio frames directly proportional
886  * to the number of data bytes?
887  *
888  * In other words, is the format transported as PCM audio samples,
889  * but not necessarily scalable or mixable.
890  * This returns true for real PCM, but also for AUDIO_FORMAT_IEC61937,
891  * which is transported as 16 bit PCM audio, but where the encoded data
892  * cannot be mixed or scaled.
893  */
894 static inline bool audio_has_proportional_frames(audio_format_t format)
895 {
896     audio_format_t mainFormat = audio_get_main_format(format);
897     return (mainFormat == AUDIO_FORMAT_PCM
898             || mainFormat == AUDIO_FORMAT_IEC61937);
899 }
900
901 static inline size_t audio_bytes_per_sample(audio_format_t format)
902 {
903     size_t size = 0;
904
905     switch (format) {
906     case AUDIO_FORMAT_PCM_32_BIT:
907     case AUDIO_FORMAT_PCM_8_24_BIT:
908         size = sizeof(int32_t);
909         break;
910     case AUDIO_FORMAT_PCM_24_BIT_PACKED:
911         size = sizeof(uint8_t) * 3;
912         break;
913     case AUDIO_FORMAT_PCM_16_BIT:
914     case AUDIO_FORMAT_IEC61937:
915         size = sizeof(int16_t);
916         break;
917     case AUDIO_FORMAT_PCM_8_BIT:
918         size = sizeof(uint8_t);
919         break;
920     case AUDIO_FORMAT_PCM_FLOAT:
921         size = sizeof(float);
922         break;
923     default:
924         break;
925     }
926     return size;
927 }
928
929 /* converts device address to string sent to audio HAL via set_parameters */
930 static inline char *audio_device_address_to_parameter(audio_devices_t device, const char *address)
931 {
932     const size_t kSize = AUDIO_DEVICE_MAX_ADDRESS_LEN + sizeof("a2dp_sink_address=");
933     char param[kSize];
934
935     if (device & AUDIO_DEVICE_OUT_ALL_A2DP)
936         snprintf(param, kSize, "%s=%s", "a2dp_sink_address", address);
937     else if (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX)
938         snprintf(param, kSize, "%s=%s", "mix", address);
939     else
940         snprintf(param, kSize, "%s", address);
941
942     return strdup(param);
943 }
944
945 static inline bool audio_device_is_digital(audio_devices_t device) {
946     if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
947         // input
948         return (~AUDIO_DEVICE_BIT_IN & device & (AUDIO_DEVICE_IN_ALL_USB |
949                           AUDIO_DEVICE_IN_HDMI |
950                           AUDIO_DEVICE_IN_SPDIF |
951                           AUDIO_DEVICE_IN_IP |
952                           AUDIO_DEVICE_IN_BUS)) != 0;
953     } else {
954         // output
955         return (device & (AUDIO_DEVICE_OUT_ALL_USB |
956                           AUDIO_DEVICE_OUT_HDMI |
957                           AUDIO_DEVICE_OUT_HDMI_ARC |
958                           AUDIO_DEVICE_OUT_SPDIF |
959                           AUDIO_DEVICE_OUT_IP |
960                           AUDIO_DEVICE_OUT_BUS)) != 0;
961     }
962 }
963
964 // Unique effect ID (can be generated from the following site:
965 //  http://www.itu.int/ITU-T/asn1/uuid.html)
966 // This struct is used for effects identification and in soundtrigger.
967 typedef struct audio_uuid_s {
968     uint32_t timeLow;
969     uint16_t timeMid;
970     uint16_t timeHiAndVersion;
971     uint16_t clockSeq;
972     uint8_t node[6];
973 } audio_uuid_t;
974
975 //TODO: audio_microphone_location_t need to move to HAL v4.0
976 typedef enum {
977     AUDIO_MICROPHONE_LOCATION_UNKNOW = 0,
978     AUDIO_MICROPHONE_LOCATION_MAINBODY = 1,
979     AUDIO_MICROPHONE_LOCATION_MAINBODY_MOVABLE = 2,
980     AUDIO_MICROPHONE_LOCATION_PERIPHERAL = 3,
981     AUDIO_MICROPHONE_LOCATION_CNT = 4,
982 } audio_microphone_location_t;
983
984 //TODO: audio_microphone_directionality_t need to move to HAL v4.0
985 typedef enum {
986     AUDIO_MICROPHONE_DIRECTIONALITY_UNKNOW = 0,
987     AUDIO_MICROPHONE_DIRECTIONALITY_OMNI = 1,
988     AUDIO_MICROPHONE_DIRECTIONALITY_BI_DIRECTIONAL = 2,
989     AUDIO_MICROPHONE_DIRECTIONALITY_CARDIOID = 3,
990     AUDIO_MICROPHONE_DIRECTIONALITY_HYPER_CARDIOID = 4,
991     AUDIO_MICROPHONE_DIRECTIONALITY_SUPER_CARDIOID = 5,
992     AUDIO_MICROPHONE_DIRECTIONALITY_CNT = 6,
993 } audio_microphone_directionality_t;
994
995 /* A 3D point which could be used to represent geometric location
996  * or orientation of a microphone.
997  */
998 struct audio_microphone_coordinate {
999     float x;
1000     float y;
1001     float z;
1002 };
1003
1004 /* An number to indicate which group the microphone locate. Main body is
1005  * usually group 0. Developer could use this value to group the microphones
1006  * that locate on the same peripheral or attachments.
1007  */
1008 typedef int audio_microphone_group_t;
1009
1010 typedef enum {
1011     AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED = 0,
1012     AUDIO_MICROPHONE_CHANNEL_MAPPING_DIRECT = 1,
1013     AUDIO_MICROPHONE_CHANNEL_MAPPING_PROCESSED = 2,
1014 } audio_microphone_channel_mapping_t;
1015
1016 /* the maximum length for the microphone id */
1017 #define AUDIO_MICROPHONE_ID_MAX_LEN 32
1018 /* max number of frequency responses in a frequency response table */
1019 #define AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES 32
1020
1021 struct audio_microphone_characteristic_t {
1022     char                               device_id[AUDIO_MICROPHONE_ID_MAX_LEN];
1023     audio_port_handle_t                id;
1024     audio_port_type_t                  type;
1025     char                               address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
1026     audio_microphone_channel_mapping_t channel_mapping[AUDIO_CHANNEL_COUNT_MAX];
1027     audio_microphone_location_t        location;
1028     audio_microphone_group_t           group;
1029     unsigned int                       index_in_the_group;
1030     float                              sensitivity;
1031     float                              max_spl;
1032     float                              min_spl;
1033     audio_microphone_directionality_t  directionality;
1034     unsigned int                       num_frequency_responses;
1035     float frequency_responses[2][AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES];
1036     struct audio_microphone_coordinate geometric_location;
1037     struct audio_microphone_coordinate orientation;
1038 };
1039
1040 __END_DECLS
1041
1042 /**
1043  * List of known audio HAL modules. This is the base name of the audio HAL
1044  * library composed of the "audio." prefix, one of the base names below and
1045  * a suffix specific to the device.
1046  * e.g: audio.primary.goldfish.so or audio.a2dp.default.so
1047  *
1048  * The same module names are used in audio policy configuration files.
1049  */
1050
1051 #define AUDIO_HARDWARE_MODULE_ID_PRIMARY "primary"
1052 #define AUDIO_HARDWARE_MODULE_ID_A2DP "a2dp"
1053 #define AUDIO_HARDWARE_MODULE_ID_USB "usb"
1054 #define AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX "r_submix"
1055 #define AUDIO_HARDWARE_MODULE_ID_CODEC_OFFLOAD "codec_offload"
1056 #define AUDIO_HARDWARE_MODULE_ID_STUB "stub"
1057
1058 /**
1059  * Multi-Stream Decoder (MSD) HAL service name. MSD HAL is used to mix
1060  * encoded streams together with PCM streams, producing re-encoded
1061  * streams or PCM streams.
1062  *
1063  * The service must register itself using this name, and audioserver
1064  * tries to instantiate a device factory using this name as well.
1065  * Note that the HIDL implementation library file name *must* have the
1066  * suffix "msd" in order to be picked up by HIDL that is:
1067  *
1068  *   android.hardware.audio@x.x-implmsd.so
1069  */
1070 #define AUDIO_HAL_SERVICE_NAME_MSD "msd"
1071
1072 /**
1073  * Parameter definitions.
1074  * Note that in the framework code it's recommended to use AudioParameter.h
1075  * instead of these preprocessor defines, and for sure avoid just copying
1076  * the constant values.
1077  */
1078
1079 #define AUDIO_PARAMETER_VALUE_ON "on"
1080 #define AUDIO_PARAMETER_VALUE_OFF "off"
1081
1082 /**
1083  *  audio device parameters
1084  */
1085
1086 /* BT SCO Noise Reduction + Echo Cancellation parameters */
1087 #define AUDIO_PARAMETER_KEY_BT_NREC "bt_headset_nrec"
1088
1089 /* Get a new HW synchronization source identifier.
1090  * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs
1091  * or no HW sync is available. */
1092 #define AUDIO_PARAMETER_HW_AV_SYNC "hw_av_sync"
1093
1094 /* Screen state */
1095 #define AUDIO_PARAMETER_KEY_SCREEN_STATE "screen_state"
1096
1097 /**
1098  *  audio stream parameters
1099  */
1100
1101 #define AUDIO_PARAMETER_STREAM_ROUTING "routing"             /* audio_devices_t */
1102 #define AUDIO_PARAMETER_STREAM_FORMAT "format"               /* audio_format_t */
1103 #define AUDIO_PARAMETER_STREAM_CHANNELS "channels"           /* audio_channel_mask_t */
1104 #define AUDIO_PARAMETER_STREAM_FRAME_COUNT "frame_count"     /* size_t */
1105 #define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source"   /* audio_source_t */
1106 #define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */
1107
1108 #define AUDIO_PARAMETER_DEVICE_CONNECT "connect"            /* audio_devices_t */
1109 #define AUDIO_PARAMETER_DEVICE_DISCONNECT "disconnect"      /* audio_devices_t */
1110
1111 /* Enable mono audio playback if 1, else should be 0. */
1112 #define AUDIO_PARAMETER_MONO_OUTPUT "mono_output"
1113
1114 /* Set the HW synchronization source for an output stream. */
1115 #define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync"
1116
1117 /* Query supported formats. The response is a '|' separated list of strings from
1118  * audio_format_t enum e.g: "sup_formats=AUDIO_FORMAT_PCM_16_BIT" */
1119 #define AUDIO_PARAMETER_STREAM_SUP_FORMATS "sup_formats"
1120 /* Query supported channel masks. The response is a '|' separated list of strings from
1121  * audio_channel_mask_t enum e.g: "sup_channels=AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO" */
1122 #define AUDIO_PARAMETER_STREAM_SUP_CHANNELS "sup_channels"
1123 /* Query supported sampling rates. The response is a '|' separated list of integer values e.g:
1124  * "sup_sampling_rates=44100|48000" */
1125 #define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates"
1126
1127 #define AUDIO_PARAMETER_VALUE_LIST_SEPARATOR "|"
1128
1129 /**
1130  * audio codec parameters
1131  */
1132
1133 #define AUDIO_OFFLOAD_CODEC_PARAMS "music_offload_codec_param"
1134 #define AUDIO_OFFLOAD_CODEC_BIT_PER_SAMPLE "music_offload_bit_per_sample"
1135 #define AUDIO_OFFLOAD_CODEC_BIT_RATE "music_offload_bit_rate"
1136 #define AUDIO_OFFLOAD_CODEC_AVG_BIT_RATE "music_offload_avg_bit_rate"
1137 #define AUDIO_OFFLOAD_CODEC_ID "music_offload_codec_id"
1138 #define AUDIO_OFFLOAD_CODEC_BLOCK_ALIGN "music_offload_block_align"
1139 #define AUDIO_OFFLOAD_CODEC_SAMPLE_RATE "music_offload_sample_rate"
1140 #define AUDIO_OFFLOAD_CODEC_ENCODE_OPTION "music_offload_encode_option"
1141 #define AUDIO_OFFLOAD_CODEC_NUM_CHANNEL  "music_offload_num_channels"
1142 #define AUDIO_OFFLOAD_CODEC_DOWN_SAMPLING  "music_offload_down_sampling"
1143 #define AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES  "delay_samples"
1144 #define AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES  "padding_samples"
1145
1146 // FIXME: a temporary declaration for the incall music flag, will be removed when
1147 // declared in types.hal for audio HAL V4.0 and auto imported to audio-base.h
1148 #define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x10000
1149
1150 #endif  // ANDROID_AUDIO_CORE_H