19bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/*
29bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Copyright (C) 2011 The Android Open Source Project
39bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
49bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Licensed under the Apache License, Version 2.0 (the "License");
59bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * you may not use this file except in compliance with the License.
69bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * You may obtain a copy of the License at
79bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
89bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *      http://www.apache.org/licenses/LICENSE-2.0
99bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Unless required by applicable law or agreed to in writing, software
119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * distributed under the License is distributed on an "AS IS" BASIS,
129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * See the License for the specific language governing permissions and
149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * limitations under the License.
159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#ifndef ANDROID_AUDIO_CORE_H
199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define ANDROID_AUDIO_CORE_H
209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#include <stdbool.h>
229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#include <stdint.h>
239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#include <stdio.h>
249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#include <sys/cdefs.h>
259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#include <sys/types.h>
269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#include <cutils/bitops.h>
289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand__BEGIN_DECLS
309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
31d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten/* The macro FCC_2 highlights places where there are 2-channel assumptions.
32d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten * This is typically due to legacy implementation of stereo input or output.
33d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten * Search also for "2", "left", "right", "[0]", "[1]", ">> 16", "<< 16", etc.
34d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten * Do not change this value.
35d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten */
36d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten#define FCC_2 2     // FCC_2 = Fixed Channel Count 2
37d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten
38d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten/* The macro FCC_8 highlights places where there are 8-channel assumptions.
39d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten * This is typically due to audio mixer and resampler limitations.
40d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten * Do not change this value without verifying all locations that use it.
41d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten */
42d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten#define FCC_8 8     // FCC_8 = Fixed Channel Count 8
43d190da511b137d315e8e60b1e1a772444b26bedbGlenn Kasten
449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* The enums were moved here mostly from
459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * frameworks/base/include/media/AudioSystem.h
469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* device address used to refer to the standard remote submix */
499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_REMOTE_SUBMIX_DEVICE_ADDRESS "0"
509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* AudioFlinger and AudioPolicy services use I/O handles to identify audio sources and sinks */
529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef int audio_io_handle_t;
539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_IO_HANDLE_NONE    0
549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Audio stream types */
569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* These values must kept in sync with
589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     * frameworks/base/media/java/android/media/AudioSystem.java
599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     */
609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_DEFAULT          = -1,
619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_MIN              = 0,
629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_VOICE_CALL       = 0,
639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_SYSTEM           = 1,
649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_RING             = 2,
659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_MUSIC            = 3,
669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_ALARM            = 4,
679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_NOTIFICATION     = 5,
689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_BLUETOOTH_SCO    = 6,
699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted by user
709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        * and must be routed to speaker
719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        */
729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_DTMF             = 8,
739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_TTS              = 9,  /* Transmitted Through Speaker.
749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                         * Plays over speaker only, silent on other devices.
759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                         */
769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_ACCESSIBILITY    = 10, /* For accessibility talk back prompts */
779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_REROUTING        = 11, /* For dynamic policy output mixes */
789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_PATCH            = 12, /* For internal audio flinger tracks. Fixed volume */
799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_PUBLIC_CNT       = AUDIO_STREAM_TTS + 1,
807b29a903091fb51b30bcc6f3f7a7323d00b2a96dEric Laurent    AUDIO_STREAM_FOR_POLICY_CNT   = AUDIO_STREAM_PATCH, /* number of streams considered by
817b29a903091fb51b30bcc6f3f7a7323d00b2a96dEric Laurent                                           audio policy for volume and routing */
829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_STREAM_CNT              = AUDIO_STREAM_PATCH + 1,
839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_stream_type_t;
849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Do not change these values without updating their counterparts
869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * in frameworks/base/media/java/android/media/AudioAttributes.java
879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CONTENT_TYPE_UNKNOWN      = 0,
909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CONTENT_TYPE_SPEECH       = 1,
919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CONTENT_TYPE_MUSIC        = 2,
929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CONTENT_TYPE_MOVIE        = 3,
939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CONTENT_TYPE_SONIFICATION = 4,
949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CONTENT_TYPE_CNT,
969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CONTENT_TYPE_MAX          = AUDIO_CONTENT_TYPE_CNT - 1,
979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_content_type_t;
989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Do not change these values without updating their counterparts
1009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * in frameworks/base/media/java/android/media/AudioAttributes.java
1019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
1029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
1039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_UNKNOWN                            = 0,
1049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_MEDIA                              = 1,
1059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_VOICE_COMMUNICATION                = 2,
1069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING     = 3,
1079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_ALARM                              = 4,
1089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_NOTIFICATION                       = 5,
1099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE    = 6,
1109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST = 7,
1119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT = 8,
1129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED = 9,
1139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_NOTIFICATION_EVENT                 = 10,
1149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY           = 11,
1159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE     = 12,
1169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_ASSISTANCE_SONIFICATION            = 13,
1179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_GAME                               = 14,
1189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_VIRTUAL_SOURCE                     = 15,
1199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_CNT,
1219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_USAGE_MAX                                = AUDIO_USAGE_CNT - 1,
1229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_usage_t;
1239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef uint32_t audio_flags_mask_t;
1259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Do not change these values without updating their counterparts
1279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * in frameworks/base/media/java/android/media/AudioAttributes.java
1289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
1299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandenum {
130b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_AUDIBILITY_ENFORCED        = 0x1,
131b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_SECURE                     = 0x2,
132b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_SCO                        = 0x4,
133b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_BEACON                     = 0x8,
134b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_HW_AV_SYNC                 = 0x10,
135b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_HW_HOTWORD                 = 0x20,
136b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY = 0x40,
137b5307ff75f42faa8333e7042e6fd95751a3755f0Jean-Michel Trivi    AUDIO_FLAG_BYPASS_MUTE                = 0x80,
13844070ca5ddc92d1fee8f96db12e63b64f6ef96c4Phil Burk    AUDIO_FLAG_LOW_LATENCY                = 0x100,
1399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
1409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Do not change these values without updating their counterparts
1429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * in frameworks/base/media/java/android/media/MediaRecorder.java,
1439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * frameworks/av/services/audiopolicy/AudioPolicyService.cpp,
1449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * and system/media/audio_effects/include/audio_effects/audio_effects_conf.h!
1459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
1469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
1479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_DEFAULT             = 0,
1489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_MIC                 = 1,
1499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_VOICE_UPLINK        = 2,
1509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_VOICE_DOWNLINK      = 3,
1519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_VOICE_CALL          = 4,
1529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_CAMCORDER           = 5,
1539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_VOICE_RECOGNITION   = 6,
1549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
1559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_REMOTE_SUBMIX       = 8, /* Source for the mix to be presented remotely.      */
1569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                          /* An example of remote presentation is Wifi Display */
1579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                          /*  where a dongle attached to a TV can be used to   */
1589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                          /*  play the mix captured by this audio source.      */
159ff9834731ae20dceeaa23b883648b254886f347arago    AUDIO_SOURCE_UNPROCESSED         = 9, /* Source for unprocessed sound.
160ff9834731ae20dceeaa23b883648b254886f347arago                                             Usage examples include level measurement and raw
161ff9834731ae20dceeaa23b883648b254886f347arago                                             signal analysis. */
1629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_CNT,
1639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_MAX                 = AUDIO_SOURCE_CNT - 1,
1649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_FM_TUNER            = 1998,
1659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SOURCE_HOTWORD             = 1999, /* A low-priority, preemptible audio source for
1669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                                for background software hotword detection.
1679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                                Same tuning as AUDIO_SOURCE_VOICE_RECOGNITION.
1689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                                Used only internally to the framework. Not exposed
1699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                                at the audio HAL. */
1709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_source_t;
1719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Audio attributes */
1739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_ATTRIBUTES_TAGS_MAX_SIZE 256
1749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef struct {
1759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_content_type_t content_type;
1769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_usage_t        usage;
1779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_source_t       source;
1789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_flags_mask_t   flags;
1799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    char                 tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */
1809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_attributes_t;
1819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* special audio session values
18345afd619058eefebd9100ce50f67a8fa5f9c45aeGlenn Kasten * do not need to have audio_unique_id_get_use(session) == AUDIO_UNIQUE_ID_USE_SESSION
1849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * (XXX: should this be living in the audio effects land?)
1859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
1869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
1879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* session for effects attached to a particular output stream
1889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     * (value must be less than 0)
1899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     */
1909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SESSION_OUTPUT_STAGE = -1,
1919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* session for effects applied to output mix. These effects can
1939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     * be moved by audio policy manager to another output stream
1949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     * (value must be 0)
1959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     */
1969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SESSION_OUTPUT_MIX = 0,
1979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
1989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* application does not specify an explicit session ID to be used,
1999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     * and requests a new session ID to be allocated
2009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     * TODO use unique values for AUDIO_SESSION_OUTPUT_MIX and AUDIO_SESSION_ALLOCATE,
2019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     * after all uses have been updated from 0 to the appropriate symbol, and have been tested.
202bdf067758071bc2e9866c8d6443000b1a49653cbGlenn Kasten     * Corresponds to AudioManager.AUDIO_SESSION_ID_GENERATE and AudioSystem.AUDIO_SESSION_ALLOCATE.
2039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand     */
2049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_SESSION_ALLOCATE = 0,
205bdf067758071bc2e9866c8d6443000b1a49653cbGlenn Kasten
206bdf067758071bc2e9866c8d6443000b1a49653cbGlenn Kasten    /* For use with AudioRecord::start(), this indicates no trigger session.
207bdf067758071bc2e9866c8d6443000b1a49653cbGlenn Kasten     * It is also used with output tracks and patch tracks, which never have a session.
208bdf067758071bc2e9866c8d6443000b1a49653cbGlenn Kasten     */
209bdf067758071bc2e9866c8d6443000b1a49653cbGlenn Kasten    AUDIO_SESSION_NONE = 0,
2109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_session_t;
2119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2126df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten/* a unique ID allocated by AudioFlinger for use as an audio_io_handle_t, audio_session_t,
2136df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten * effect ID (int), audio_module_handle_t, and audio_patch_handle_t.
2146df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten * Audio port IDs (audio_port_handle_t) are allocated by AudioPolicy
2156df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten * in a different namespace than AudioFlinger unique IDs.
2166df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten */
2179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef int audio_unique_id_t;
2189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2196df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten/* Possible uses for an audio_unique_id_t */
2206df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kastentypedef enum {
2216df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_UNSPECIFIED = 0,
22245afd619058eefebd9100ce50f67a8fa5f9c45aeGlenn Kasten    AUDIO_UNIQUE_ID_USE_SESSION = 1,    // for allocated sessions, not special AUDIO_SESSION_*
2236df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_MODULE = 2,
2246df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_EFFECT = 3,
2256df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_PATCH = 4,
2266df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_OUTPUT = 5,
2276df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_INPUT = 6,
2286df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    // 7 is available
2296df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_MAX = 8,  // must be a power-of-two
2306df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    AUDIO_UNIQUE_ID_USE_MASK = AUDIO_UNIQUE_ID_USE_MAX - 1
2316df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten} audio_unique_id_use_t;
2326df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten
2336df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten/* Return the use of an audio_unique_id_t */
2346df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kastenstatic inline audio_unique_id_use_t audio_unique_id_get_use(audio_unique_id_t id)
2356df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten{
2366df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten    return (audio_unique_id_use_t) (id & AUDIO_UNIQUE_ID_USE_MASK);
2376df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten}
2386df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten
2396df66e0b5115b1834c8304ed3b5dfe0497e661baGlenn Kasten/* Reserved audio_unique_id_t values.  FIXME: not a complete list. */
2409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_UNIQUE_ID_ALLOCATE AUDIO_SESSION_ALLOCATE
2419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Audio sub formats (see enum audio_format). */
2439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* PCM sub formats */
2459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
2469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* All of these are in native byte order */
2479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_SUB_16_BIT          = 0x1, /* DO NOT CHANGE - PCM signed 16 bits */
2489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_SUB_8_BIT           = 0x2, /* DO NOT CHANGE - PCM unsigned 8 bits */
2499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_SUB_32_BIT          = 0x3, /* PCM signed .31 fixed point */
2509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_SUB_8_24_BIT        = 0x4, /* PCM signed 8.23 fixed point */
2519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_SUB_FLOAT           = 0x5, /* PCM single-precision floating point */
2529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED   = 0x6, /* PCM signed .23 fixed point packed in 3 bytes */
2539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_format_pcm_sub_fmt_t;
2549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* The audio_format_*_sub_fmt_t declarations are not currently used */
2569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* MP3 sub format field definition : can use 11 LSBs in the same way as MP3
2589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * frame header to specify bit rate, stereo mode, version...
2599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
2609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
2619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_MP3_SUB_NONE            = 0x0,
2629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_format_mp3_sub_fmt_t;
2639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* AMR NB/WB sub format field definition: specify frame block interleaving,
2659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * bandwidth efficient or octet aligned, encoding mode for recording...
2669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
2679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
2689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AMR_SUB_NONE            = 0x0,
2699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_format_amr_sub_fmt_t;
2709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* AAC sub format field definition: specify profile or bitrate for recording... */
2729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
2739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_MAIN            = 0x1,
2749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_LC              = 0x2,
2759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_SSR             = 0x4,
2769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_LTP             = 0x8,
2779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_HE_V1           = 0x10,
2789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_SCALABLE        = 0x20,
2799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_ERLC            = 0x40,
2809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_LD              = 0x80,
2819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_HE_V2           = 0x100,
2829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SUB_ELD             = 0x200,
2839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_format_aac_sub_fmt_t;
2849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* VORBIS sub format field definition: specify quality for recording... */
2869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
2879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_VORBIS_SUB_NONE         = 0x0,
2889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_format_vorbis_sub_fmt_t;
2899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
2909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
29197763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk/* Audio format  is a 32-bit word that consists of:
29297763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk *   main format field (upper 8 bits)
29397763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk *   sub format field (lower 24 bits).
2949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
2959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * The main format indicates the main codec type. The sub format field
2969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * indicates options and parameters for each format. The sub format is mainly
2979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * used for record to indicate for instance the requested bitrate or profile.
2989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * It can also be used for certain formats to give informations not present in
2999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * the encoded audio stream (e.g. octet alignement for AMR).
3009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
3019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
3029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_INVALID             = 0xFFFFFFFFUL,
3039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_DEFAULT             = 0,
3049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM                 = 0x00000000UL, /* DO NOT CHANGE */
3059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_MP3                 = 0x01000000UL,
3069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AMR_NB              = 0x02000000UL,
3079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AMR_WB              = 0x03000000UL,
3089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC                 = 0x04000000UL,
3099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_HE_AAC_V1           = 0x05000000UL, /* Deprecated, Use AUDIO_FORMAT_AAC_HE_V1*/
3109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_HE_AAC_V2           = 0x06000000UL, /* Deprecated, Use AUDIO_FORMAT_AAC_HE_V2*/
3119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_VORBIS              = 0x07000000UL,
3129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_OPUS                = 0x08000000UL,
3139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AC3                 = 0x09000000UL,
3149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_E_AC3               = 0x0A000000UL,
3159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_DTS                 = 0x0B000000UL,
3169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_DTS_HD              = 0x0C000000UL,
31797763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    // IEC61937 is encoded audio wrapped in 16-bit PCM.
31897763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    AUDIO_FORMAT_IEC61937            = 0x0D000000UL,
31997763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    AUDIO_FORMAT_MAIN_MASK           = 0xFF000000UL, /* Deprecated. Use audio_get_main_format() */
3209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_SUB_MASK            = 0x00FFFFFFUL,
3219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* Aliases */
3239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* note != AudioFormat.ENCODING_PCM_16BIT */
3249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_16_BIT          = (AUDIO_FORMAT_PCM |
3259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_PCM_SUB_16_BIT),
3269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* note != AudioFormat.ENCODING_PCM_8BIT */
3279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_8_BIT           = (AUDIO_FORMAT_PCM |
3289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_PCM_SUB_8_BIT),
3299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_32_BIT          = (AUDIO_FORMAT_PCM |
3309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_PCM_SUB_32_BIT),
3319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_8_24_BIT        = (AUDIO_FORMAT_PCM |
3329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_PCM_SUB_8_24_BIT),
3339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_FLOAT           = (AUDIO_FORMAT_PCM |
3349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_PCM_SUB_FLOAT),
3359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_PCM_24_BIT_PACKED   = (AUDIO_FORMAT_PCM |
3369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED),
3379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_MAIN            = (AUDIO_FORMAT_AAC |
3389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_MAIN),
3399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_LC              = (AUDIO_FORMAT_AAC |
3409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_LC),
3419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SSR             = (AUDIO_FORMAT_AAC |
3429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_SSR),
3439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_LTP             = (AUDIO_FORMAT_AAC |
3449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_LTP),
3459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_HE_V1           = (AUDIO_FORMAT_AAC |
3469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_HE_V1),
3479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_SCALABLE        = (AUDIO_FORMAT_AAC |
3489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_SCALABLE),
3499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_ERLC            = (AUDIO_FORMAT_AAC |
3509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_ERLC),
3519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_LD              = (AUDIO_FORMAT_AAC |
3529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_LD),
3539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_HE_V2           = (AUDIO_FORMAT_AAC |
3549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_HE_V2),
3559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_FORMAT_AAC_ELD             = (AUDIO_FORMAT_AAC |
3569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        AUDIO_FORMAT_AAC_SUB_ELD),
3579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_format_t;
3589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* For the channel mask for position assignment representation */
3609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandenum {
3619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* These can be a complete audio_channel_mask_t. */
3639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_NONE                      = 0x0,
3659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_INVALID                   = 0xC0000000,
3669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* These can be the bits portion of an audio_channel_mask_t
3689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * with representation AUDIO_CHANNEL_REPRESENTATION_POSITION.
3699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Using these bits as a complete audio_channel_mask_t is deprecated.
3709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
3719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* output channels */
3739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_FRONT_LEFT            = 0x1,
3749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_FRONT_RIGHT           = 0x2,
3759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_FRONT_CENTER          = 0x4,
3769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_LOW_FREQUENCY         = 0x8,
3779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_BACK_LEFT             = 0x10,
3789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_BACK_RIGHT            = 0x20,
3799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER  = 0x40,
3809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80,
3819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_BACK_CENTER           = 0x100,
3829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_SIDE_LEFT             = 0x200,
3839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_SIDE_RIGHT            = 0x400,
3849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_TOP_CENTER            = 0x800,
3859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT        = 0x1000,
3869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER      = 0x2000,
3879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT       = 0x4000,
3889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_TOP_BACK_LEFT         = 0x8000,
3899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_TOP_BACK_CENTER       = 0x10000,
3909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT        = 0x20000,
3919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* TODO: should these be considered complete channel masks, or only bits? */
3939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
3949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_MONO     = AUDIO_CHANNEL_OUT_FRONT_LEFT,
3959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_STEREO   = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
3969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT),
3979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_QUAD     = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
3989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
3999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_LEFT |
4009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_RIGHT),
4019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_QUAD_BACK = AUDIO_CHANNEL_OUT_QUAD,
4029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* like AUDIO_CHANNEL_OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
4039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_QUAD_SIDE = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
4049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
4059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_LEFT |
4069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_RIGHT),
4079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_5POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
4089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
4099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_CENTER |
4109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
4119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_LEFT |
4129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_RIGHT),
4139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_5POINT1_BACK = AUDIO_CHANNEL_OUT_5POINT1,
4149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* like AUDIO_CHANNEL_OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
4159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_5POINT1_SIDE = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
4169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
4179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_CENTER |
4189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
4199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_LEFT |
4209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_RIGHT),
4219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    // matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND definition for 7.1
4229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_7POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
4239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
4249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_CENTER |
4259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
4269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_LEFT |
4279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_RIGHT |
4289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_LEFT |
4299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_RIGHT),
4309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_OUT_ALL      = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
4319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
4329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_CENTER |
4339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
4349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_LEFT |
4359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_RIGHT |
4369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER |
4379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER |
4389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_BACK_CENTER|
4399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_LEFT|
4409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_SIDE_RIGHT|
4419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_TOP_CENTER|
4429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT|
4439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER|
4449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT|
4459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_TOP_BACK_LEFT|
4469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_TOP_BACK_CENTER|
4479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                  AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT),
4489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
4499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* These are bits only, not complete values */
4509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
4519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* input channels */
4529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_LEFT            = 0x4,
4539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_RIGHT           = 0x8,
4549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_FRONT           = 0x10,
4559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_BACK            = 0x20,
4569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_LEFT_PROCESSED  = 0x40,
4579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 0x80,
4589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_FRONT_PROCESSED = 0x100,
4599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_BACK_PROCESSED  = 0x200,
4609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_PRESSURE        = 0x400,
4619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_X_AXIS          = 0x800,
4629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_Y_AXIS          = 0x1000,
4639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_Z_AXIS          = 0x2000,
4649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_VOICE_UPLINK    = 0x4000,
4659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_VOICE_DNLINK    = 0x8000,
4669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
4679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* TODO: should these be considered complete channel masks, or only bits, or deprecated? */
4689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
4699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_MONO   = AUDIO_CHANNEL_IN_FRONT,
4709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_STEREO = (AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT),
4719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_FRONT_BACK = (AUDIO_CHANNEL_IN_FRONT | AUDIO_CHANNEL_IN_BACK),
4729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_IN_ALL    = (AUDIO_CHANNEL_IN_LEFT |
4739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_RIGHT |
4749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_FRONT |
4759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_BACK|
4769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_LEFT_PROCESSED |
4779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_RIGHT_PROCESSED |
4789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_FRONT_PROCESSED |
4799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_BACK_PROCESSED|
4809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_PRESSURE |
4819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_X_AXIS |
4829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_Y_AXIS |
4839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_Z_AXIS |
4849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_VOICE_UPLINK |
4859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_CHANNEL_IN_VOICE_DNLINK),
4869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
4879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
4889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* A channel mask per se only defines the presence or absence of a channel, not the order.
4899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * But see AUDIO_INTERLEAVE_* below for the platform convention of order.
4909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
4919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * audio_channel_mask_t is an opaque type and its internal layout should not
4929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * be assumed as it may change in the future.
4939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Instead, always use the functions declared in this header to examine.
4949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
4959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * These are the current representations:
4969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
4979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *   AUDIO_CHANNEL_REPRESENTATION_POSITION
4989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     is a channel mask representation for position assignment.
4999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     Each low-order bit corresponds to the spatial position of a transducer (output),
5009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     or interpretation of channel (input).
5019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     The user of a channel mask needs to know the context of whether it is for output or input.
5029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     The constants AUDIO_CHANNEL_OUT_* or AUDIO_CHANNEL_IN_* apply to the bits portion.
5039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     It is not permitted for no bits to be set.
5049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
5059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *   AUDIO_CHANNEL_REPRESENTATION_INDEX
5069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     is a channel mask representation for index assignment.
5079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     Each low-order bit corresponds to a selected channel.
5089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     There is no platform interpretation of the various bits.
5099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     There is no concept of output or input.
5109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *     It is not permitted for no bits to be set.
5119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
5129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * All other representations are reserved for future use.
5139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
5149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Warning: current representation distinguishes between input and output, but this will not the be
5159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * case in future revisions of the platform. Wherever there is an ambiguity between input and output
5169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * that is currently resolved by checking the channel mask, the implementer should look for ways to
5179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * fix it with additional information outside of the mask.
5189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
5199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef uint32_t audio_channel_mask_t;
5209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Maximum number of channels for all representations */
5229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_CHANNEL_COUNT_MAX             30
5239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* log(2) of maximum number of representations, not part of public API */
5259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_CHANNEL_REPRESENTATION_LOG2   2
5269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Representations */
5289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
5299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_REPRESENTATION_POSITION    = 0,    // must be zero for compatibility
5309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    // 1 is reserved for future use
5319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_CHANNEL_REPRESENTATION_INDEX       = 2,
5329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    // 3 is reserved for future use
5339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_channel_representation_t;
5349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5351f6902ea391a84a33b0dca376285a5440ba5f55fAndy Hung/* The channel index masks defined here are the canonical masks for 1 to 8 channel
5361f6902ea391a84a33b0dca376285a5440ba5f55fAndy Hung * endpoints and apply to both source and sink.
5371f6902ea391a84a33b0dca376285a5440ba5f55fAndy Hung */
5381f6902ea391a84a33b0dca376285a5440ba5f55fAndy Hungenum {
5391f6902ea391a84a33b0dca376285a5440ba5f55fAndy Hung    AUDIO_CHANNEL_INDEX_HDR  = AUDIO_CHANNEL_REPRESENTATION_INDEX << AUDIO_CHANNEL_COUNT_MAX,
5402bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_1 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 1) - 1),
5412bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_2 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 2) - 1),
5422bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_3 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 3) - 1),
5432bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_4 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 4) - 1),
5442bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_5 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 5) - 1),
5452bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_6 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 6) - 1),
5462bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_7 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 7) - 1),
5472bd237dd9da7fa3d7278ec8ae8091d95be3eadc0Ryan Haining    AUDIO_CHANNEL_INDEX_MASK_8 =  AUDIO_CHANNEL_INDEX_HDR | ((1 << 8) - 1),
5482c29cee2e519db2decc91747b01f54597a856d1bGlenn Kasten    // FIXME FCC_8
5491f6902ea391a84a33b0dca376285a5440ba5f55fAndy Hung};
5501f6902ea391a84a33b0dca376285a5440ba5f55fAndy Hung
5519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* The return value is undefined if the channel mask is invalid. */
5529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline uint32_t audio_channel_mask_get_bits(audio_channel_mask_t channel)
5539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
5549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return channel & ((1 << AUDIO_CHANNEL_COUNT_MAX) - 1);
5559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
5569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* The return value is undefined if the channel mask is invalid. */
5589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline audio_channel_representation_t audio_channel_mask_get_representation(
5599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        audio_channel_mask_t channel)
5609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
5619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    // The right shift should be sufficient, but also "and" for safety in case mask is not 32 bits
5629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return (audio_channel_representation_t)
5639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            ((channel >> AUDIO_CHANNEL_COUNT_MAX) & ((1 << AUDIO_CHANNEL_REPRESENTATION_LOG2) - 1));
5649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
5659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Returns true if the channel mask is valid,
5679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * or returns false for AUDIO_CHANNEL_NONE, AUDIO_CHANNEL_INVALID, and other invalid values.
5689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * This function is unable to determine whether a channel mask for position assignment
5699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * is invalid because an output mask has an invalid output bit set,
5709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * or because an input mask has an invalid input bit set.
5719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * All other APIs that take a channel mask assume that it is valid.
5729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
5739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_channel_mask_is_valid(audio_channel_mask_t channel)
5749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
5759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bits = audio_channel_mask_get_bits(channel);
5769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_channel_representation_t representation = audio_channel_mask_get_representation(channel);
5779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (representation) {
5789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_POSITION:
5799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_INDEX:
5809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
5819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
5829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = 0;
5839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
5849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
5859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return bits != 0;
5869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
5879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Not part of public API */
5899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline audio_channel_mask_t audio_channel_mask_from_representation_and_bits(
5909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        audio_channel_representation_t representation, uint32_t bits)
5919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
5929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return (audio_channel_mask_t) ((representation << AUDIO_CHANNEL_COUNT_MAX) | bits);
5939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
5949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
5959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Expresses the convention when stereo audio samples are stored interleaved
5969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * in an array.  This should improve readability by allowing code to use
5979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * symbolic indices instead of hard-coded [0] and [1].
5989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *
5999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * For multi-channel beyond stereo, the platform convention is that channels
6009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * are interleaved in order from least significant channel mask bit
6019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * to most significant channel mask bit, with unused bits skipped.
6029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Any exceptions to this convention will be noted at the appropriate API.
6039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
6049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandenum {
6059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_INTERLEAVE_LEFT   = 0,
6069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_INTERLEAVE_RIGHT  = 1,
6079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
6089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
6099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
6109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_INVALID          = -2,
6119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_CURRENT          = -1,
6129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_NORMAL           = 0,
6139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_RINGTONE         = 1,
6149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_IN_CALL          = 2,
6159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_IN_COMMUNICATION = 3,
6169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
6179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_CNT,
6189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_MODE_MAX              = AUDIO_MODE_CNT - 1,
6199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_mode_t;
6209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
6219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* This enum is deprecated */
6229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
6239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_IN_ACOUSTICS_NONE          = 0,
6249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_IN_ACOUSTICS_AGC_ENABLE    = 0x0001,
6259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_IN_ACOUSTICS_AGC_DISABLE   = 0,
6269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_IN_ACOUSTICS_NS_ENABLE     = 0x0002,
6279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_IN_ACOUSTICS_NS_DISABLE    = 0,
6289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004,
6299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_IN_ACOUSTICS_TX_DISABLE    = 0,
6309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_in_acoustics_t;
6319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
6329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandenum {
6339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_NONE                          = 0x0,
6349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* reserved bits */
6359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_BIT_IN                        = 0x80000000,
6369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_BIT_DEFAULT                   = 0x40000000,
6379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* output devices */
6389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_EARPIECE                  = 0x1,
6399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_SPEAKER                   = 0x2,
6409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_WIRED_HEADSET             = 0x4,
6419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_WIRED_HEADPHONE           = 0x8,
6429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_BLUETOOTH_SCO             = 0x10,
6439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET     = 0x20,
6449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT      = 0x40,
6459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP            = 0x80,
6469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
6479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER    = 0x200,
6489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_AUX_DIGITAL               = 0x400,
6499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_HDMI                      = AUDIO_DEVICE_OUT_AUX_DIGITAL,
6509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* uses an analog connection (multiplexed over the USB connector pins for instance) */
6519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET         = 0x800,
6529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET         = 0x1000,
6539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* USB accessory mode: your Android device is a USB device and the dock is a USB host */
6549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_USB_ACCESSORY             = 0x2000,
6559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* USB host mode: your Android device is a USB host and the dock is a USB device */
6569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_USB_DEVICE                = 0x4000,
6579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_REMOTE_SUBMIX             = 0x8000,
6589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* Telephony voice TX path */
6599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_TELEPHONY_TX              = 0x10000,
6609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* Analog jack with line impedance detected */
6619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_LINE                      = 0x20000,
6629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* HDMI Audio Return Channel */
6639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_HDMI_ARC                  = 0x40000,
6649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* S/PDIF out */
6659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_SPDIF                     = 0x80000,
6669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* FM transmitter out */
6679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_FM                        = 0x100000,
6689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* Line out for av devices */
6699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_AUX_LINE                  = 0x200000,
6709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* limited-output speaker device for acoustic safety */
6719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_SPEAKER_SAFE              = 0x400000,
6724d5418183c209ecd5c4109f0ecb6c6f259360c0eEric Laurent    AUDIO_DEVICE_OUT_IP                        = 0x800000,
6737f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent    /* audio bus implemented by the audio system (e.g an MOST stereo channel) */
6747f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent    AUDIO_DEVICE_OUT_BUS                       = 0x1000000,
6759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_DEFAULT                   = AUDIO_DEVICE_BIT_DEFAULT,
6769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_ALL      = (AUDIO_DEVICE_OUT_EARPIECE |
6779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_SPEAKER |
6789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_WIRED_HEADSET |
6799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
6809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
6819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
6829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT |
6839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
6849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
6859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER |
6869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_HDMI |
6879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
6889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET |
6899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_USB_ACCESSORY |
6909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_USB_DEVICE |
6919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_REMOTE_SUBMIX |
6929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_TELEPHONY_TX |
6939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_LINE |
6949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_HDMI_ARC |
6959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_SPDIF |
6969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_FM |
6979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_AUX_LINE |
6989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_SPEAKER_SAFE |
6994d5418183c209ecd5c4109f0ecb6c6f259360c0eEric Laurent                                 AUDIO_DEVICE_OUT_IP |
7007f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent                                 AUDIO_DEVICE_OUT_BUS |
7019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_DEFAULT),
7029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
7039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
7049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
7059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_ALL_SCO  = (AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
7069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
7079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT),
7089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_OUT_ALL_USB  = (AUDIO_DEVICE_OUT_USB_ACCESSORY |
7099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                 AUDIO_DEVICE_OUT_USB_DEVICE),
7109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* input devices */
7119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_COMMUNICATION         = AUDIO_DEVICE_BIT_IN | 0x1,
7129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_AMBIENT               = AUDIO_DEVICE_BIT_IN | 0x2,
7139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_BUILTIN_MIC           = AUDIO_DEVICE_BIT_IN | 0x4,
7149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = AUDIO_DEVICE_BIT_IN | 0x8,
7159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_WIRED_HEADSET         = AUDIO_DEVICE_BIT_IN | 0x10,
7169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_AUX_DIGITAL           = AUDIO_DEVICE_BIT_IN | 0x20,
7179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_HDMI                  = AUDIO_DEVICE_IN_AUX_DIGITAL,
7189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* Telephony voice RX path */
7199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_VOICE_CALL            = AUDIO_DEVICE_BIT_IN | 0x40,
7209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_TELEPHONY_RX          = AUDIO_DEVICE_IN_VOICE_CALL,
7219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_BACK_MIC              = AUDIO_DEVICE_BIT_IN | 0x80,
7229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_REMOTE_SUBMIX         = AUDIO_DEVICE_BIT_IN | 0x100,
7239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN | 0x200,
7249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN | 0x400,
7259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_USB_ACCESSORY         = AUDIO_DEVICE_BIT_IN | 0x800,
7269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_USB_DEVICE            = AUDIO_DEVICE_BIT_IN | 0x1000,
7279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* FM tuner input */
7289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_FM_TUNER              = AUDIO_DEVICE_BIT_IN | 0x2000,
7299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* TV tuner input */
7309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_TV_TUNER              = AUDIO_DEVICE_BIT_IN | 0x4000,
7319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* Analog jack with line impedance detected */
7329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_LINE                  = AUDIO_DEVICE_BIT_IN | 0x8000,
7339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    /* S/PDIF in */
7349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_SPDIF                 = AUDIO_DEVICE_BIT_IN | 0x10000,
7359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_BLUETOOTH_A2DP        = AUDIO_DEVICE_BIT_IN | 0x20000,
7369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_LOOPBACK              = AUDIO_DEVICE_BIT_IN | 0x40000,
7374d5418183c209ecd5c4109f0ecb6c6f259360c0eEric Laurent    AUDIO_DEVICE_IN_IP                    = AUDIO_DEVICE_BIT_IN | 0x80000,
7387f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent    /* audio bus implemented by the audio system (e.g an MOST stereo channel) */
7397f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent    AUDIO_DEVICE_IN_BUS                   = AUDIO_DEVICE_BIT_IN | 0x100000,
7409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_DEFAULT               = AUDIO_DEVICE_BIT_IN | AUDIO_DEVICE_BIT_DEFAULT,
7419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
7429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_ALL     = (AUDIO_DEVICE_IN_COMMUNICATION |
7439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_AMBIENT |
7449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_BUILTIN_MIC |
7459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET |
7469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_WIRED_HEADSET |
7479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_HDMI |
7489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_TELEPHONY_RX |
7499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_BACK_MIC |
7509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_REMOTE_SUBMIX |
7519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET |
7529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET |
7539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_USB_ACCESSORY |
7549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_USB_DEVICE |
7559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_FM_TUNER |
7569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_TV_TUNER |
7579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_LINE |
7589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_SPDIF |
7599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_BLUETOOTH_A2DP |
7609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_LOOPBACK |
7614d5418183c209ecd5c4109f0ecb6c6f259360c0eEric Laurent                               AUDIO_DEVICE_IN_IP |
7627f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent                               AUDIO_DEVICE_IN_BUS |
7639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_DEVICE_IN_DEFAULT),
7649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
7659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_DEVICE_IN_ALL_USB  = (AUDIO_DEVICE_IN_USB_ACCESSORY |
7669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                AUDIO_DEVICE_IN_USB_DEVICE),
7679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
7689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
7699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef uint32_t audio_devices_t;
7709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
7719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* the audio output flags serve two purposes:
7729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * - when an AudioTrack is created they indicate a "wish" to be connected to an
7739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * output stream with attributes corresponding to the specified flags
7749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * - when present in an output profile descriptor listed for a particular audio
7759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * hardware module, they indicate that an output stream can be opened that
7769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * supports the attributes indicated by the flags.
7779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * the audio policy manager will try to match the flags in the request
7789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * (when getOuput() is called) to an available output stream.
7799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
7809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
7819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_OUTPUT_FLAG_NONE = 0x0,       // no attributes
7829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_OUTPUT_FLAG_DIRECT = 0x1,     // this output directly connects a track
7839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        // to one output stream: no software mixer
7849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_OUTPUT_FLAG_PRIMARY = 0x2,    // this output is the primary output of
7859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        // the device. It is unique and must be
7869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        // present. It is opened by default and
7879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        // receives routing, audio mode and volume
7889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        // controls related to voice calls.
7899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_OUTPUT_FLAG_FAST = 0x4,       // output supports "fast tracks",
7909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                        // defined elsewhere
7919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8, // use deep audio buffers
7929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 0x10,  // offload playback of compressed
7939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                                // streams to hardware codec
7949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_OUTPUT_FLAG_NON_BLOCKING = 0x20, // use non-blocking write
79555093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten    AUDIO_OUTPUT_FLAG_HW_AV_SYNC = 0x40,   // output uses a hardware A/V synchronization source
79655093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten    AUDIO_OUTPUT_FLAG_TTS = 0x80,          // output for streams transmitted through speaker
79755093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten                                           // at a sample rate high enough to accommodate
79855093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten                                           // lower-range ultrasonic playback
79955093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten    AUDIO_OUTPUT_FLAG_RAW = 0x100,         // minimize signal processing
80055093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten    AUDIO_OUTPUT_FLAG_SYNC = 0x200,        // synchronize I/O streams
80180b8823a7fd689283093ddaf074f9d67ec152aa8Ravi Kumar Alamanda
802cf6443f4e67079e2b3c3f7849f49681e856f7f38Phil Burk    AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in
803cf6443f4e67079e2b3c3f7849f49681e856f7f38Phil Burk                                               // SPDIF data bursts, not PCM.
8049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_output_flags_t;
8059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* The audio input flags are analogous to audio output flags.
8079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Currently they are used only when an AudioRecord is created,
8089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * to indicate a preference to be connected to an input stream with
8099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * attributes corresponding to the specified flags.
8109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
8119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
8129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_INPUT_FLAG_NONE       = 0x0,  // no attributes
8139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_INPUT_FLAG_FAST       = 0x1,  // prefer an input that supports "fast tracks"
8149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_INPUT_FLAG_HW_HOTWORD = 0x2,  // prefer an input that captures from hw hotword source
81555093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten    AUDIO_INPUT_FLAG_RAW        = 0x4,  // minimize signal processing
81655093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten    AUDIO_INPUT_FLAG_SYNC       = 0x8,  // synchronize I/O streams
81755093a1d870e97a2c4ae88a406601568feebda5dGlenn Kasten
8189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_input_flags_t;
8199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Additional information about compressed streams offloaded to
8219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * hardware playback
8229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * The version and size fields must be initialized by the caller by using
8239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * one of the constants defined here.
8249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
8259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef struct {
8269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint16_t version;                   // version of the info structure
8279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint16_t size;                      // total size of the structure including version and size
8289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t sample_rate;               // sample rate in Hz
8299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_channel_mask_t channel_mask;  // channel mask
8309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_format_t format;              // audio format
8319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_stream_type_t stream_type;    // stream type
8329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bit_rate;                  // bit rate in bits per second
8339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    int64_t duration_us;                // duration in microseconds, -1 if unknown
8349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    bool has_video;                     // true if stream is tied to a video stream
8359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    bool is_streaming;                  // true if streaming, false if local playback
8369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_offload_info_t;
8379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \
8399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            ((((maj) & 0xff) << 8) | ((min) & 0xff))
8409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1)
8429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_OFFLOAD_INFO_VERSION_CURRENT AUDIO_OFFLOAD_INFO_VERSION_0_1
8439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic const audio_offload_info_t AUDIO_INFO_INITIALIZER = {
8459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    version: AUDIO_OFFLOAD_INFO_VERSION_CURRENT,
8469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    size: sizeof(audio_offload_info_t),
8479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    sample_rate: 0,
8489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    channel_mask: 0,
8499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    format: AUDIO_FORMAT_DEFAULT,
8509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    stream_type: AUDIO_STREAM_VOICE_CALL,
8519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    bit_rate: 0,
8529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    duration_us: 0,
8539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    has_video: false,
8549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    is_streaming: false
8559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
8569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* common audio stream configuration parameters
8589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * You should memset() the entire structure to zero before use to
8599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * ensure forward compatibility
8609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
8619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_config {
8629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t sample_rate;
8639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_channel_mask_t channel_mask;
8649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_format_t  format;
8659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_offload_info_t offload_info;
8669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    size_t frame_count;
8679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
8689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef struct audio_config audio_config_t;
8699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic const audio_config_t AUDIO_CONFIG_INITIALIZER = {
8719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    sample_rate: 0,
8729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    channel_mask: AUDIO_CHANNEL_NONE,
8739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    format: AUDIO_FORMAT_DEFAULT,
8749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    offload_info: {
8759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        version: AUDIO_OFFLOAD_INFO_VERSION_CURRENT,
8769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        size: sizeof(audio_offload_info_t),
8779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        sample_rate: 0,
8789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        channel_mask: 0,
8799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        format: AUDIO_FORMAT_DEFAULT,
8809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        stream_type: AUDIO_STREAM_VOICE_CALL,
8819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bit_rate: 0,
8829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        duration_us: 0,
8839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        has_video: false,
8849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        is_streaming: false
8859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    },
8869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    frame_count: 0,
8879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
8889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
8895413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivistruct audio_config_base {
8905413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi    uint32_t sample_rate;
8915413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi    audio_channel_mask_t channel_mask;
8925413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi    audio_format_t  format;
8935413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi};
8945413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi
8955413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivitypedef struct audio_config_base audio_config_base_t;
8965413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi
8975413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivistatic const audio_config_base_t AUDIO_CONFIG_BASE_INITIALIZER = {
8985413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi    sample_rate: 0,
8995413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi    channel_mask: AUDIO_CHANNEL_NONE,
9005413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi    format: AUDIO_FORMAT_DEFAULT
9015413dc382ba613605086f4dcae9423df82d6a932Jean-Michel Trivi};
9029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* audio hw module handle functions or structures referencing a module */
9045612e098e2cbf9bbae69780f003144010fcc899cGlenn Kastentypedef enum {
9055612e098e2cbf9bbae69780f003144010fcc899cGlenn Kasten    AUDIO_MODULE_HANDLE_NONE = 0,
9065612e098e2cbf9bbae69780f003144010fcc899cGlenn Kasten} audio_module_handle_t;
9079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/******************************
9099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  Volume control
9109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *****************************/
9119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* If the audio hardware supports gain control on some audio paths,
9139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * the platform can expose them in the audio_policy.conf file. The audio HAL
9149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * will then implement gain control functions that will use the following data
9159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * structures. */
9169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Type of gain control exposed by an audio port */
9189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_GAIN_MODE_JOINT     0x1 /* supports joint channel gain control */
9199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_GAIN_MODE_CHANNELS  0x2 /* supports separate channel gain control */
9209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_GAIN_MODE_RAMP      0x4 /* supports gain ramps */
9219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef uint32_t audio_gain_mode_t;
9239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* An audio_gain struct is a representation of a gain stage.
9269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * A gain stage is always attached to an audio port. */
9279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_gain  {
9289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_gain_mode_t    mode;          /* e.g. AUDIO_GAIN_MODE_JOINT */
9299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_channel_mask_t channel_mask;  /* channels which gain an be controlled.
9309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                           N/A if AUDIO_GAIN_MODE_CHANNELS is not supported */
9319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    int                  min_value;     /* minimum gain value in millibels */
9329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    int                  max_value;     /* maximum gain value in millibels */
9339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    int                  default_value; /* default gain value in millibels */
9349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int         step_value;    /* gain step in millibels */
9359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int         min_ramp_ms;   /* minimum ramp duration in ms */
9369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int         max_ramp_ms;   /* maximum ramp duration in ms */
9379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
9389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* The gain configuration structure is used to get or set the gain values of a
9409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * given port */
9419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_gain_config  {
9429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    int                  index;             /* index of the corresponding audio_gain in the
9439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                               audio_port gains[] table */
9449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_gain_mode_t    mode;              /* mode requested for this command */
9459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_channel_mask_t channel_mask;      /* channels which gain value follows.
9469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                               N/A in joint mode */
9472c29cee2e519db2decc91747b01f54597a856d1bGlenn Kasten
9482c29cee2e519db2decc91747b01f54597a856d1bGlenn Kasten    // note this "8" is not FCC_8, so it won't need to be changed for > 8 channels
9499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    int                  values[sizeof(audio_channel_mask_t) * 8]; /* gain values in millibels
9509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                               for each channel ordered from LSb to MSb in
9519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                               channel mask. The number of values is 1 in joint
9529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                                               mode or popcount(channel_mask) */
9539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int         ramp_duration_ms; /* ramp duration in ms */
9549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
9559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/******************************
9579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  Routing control
9589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *****************************/
9599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Types defined here are used to describe an audio source or sink at internal
9619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * framework interfaces (audio policy, patch panel) or at the audio HAL.
9629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Sink and sources are grouped in a concept of “audio port” representing an
9639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * audio end point at the edge of the system managed by the module exposing
9649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * the interface. */
9659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Audio port role: either source or sink */
9679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
9689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_PORT_ROLE_NONE,
9699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_PORT_ROLE_SOURCE,
9709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_PORT_ROLE_SINK,
9719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_port_role_t;
9729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Audio port type indicates if it is a session (e.g AudioTrack),
9749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * a mix (e.g PlaybackThread output) or a physical device
9759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * (e.g AUDIO_DEVICE_OUT_SPEAKER) */
9769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
9779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_PORT_TYPE_NONE,
9789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_PORT_TYPE_DEVICE,
9799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_PORT_TYPE_MIX,
9809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_PORT_TYPE_SESSION,
9819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_port_type_t;
9829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Each port has a unique ID or handle allocated by policy manager */
9849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef int audio_port_handle_t;
9859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_HANDLE_NONE 0
9869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* the maximum length for the human-readable device name */
9889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_MAX_NAME_LEN 128
9899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* maximum audio device address length */
9919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_DEVICE_MAX_ADDRESS_LEN 32
9929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
9939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* extension for audio port configuration structure when the audio port is a
9949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * hardware device */
9959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port_config_device_ext {
9969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_module_handle_t hw_module;                /* module the device is attached to */
9979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_devices_t       type;                     /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */
9989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    char                  address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; /* device address. "" if N/A */
9999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
10009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* extension for audio port configuration structure when the audio port is a
10029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * sub mix */
10039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port_config_mix_ext {
10049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_module_handle_t hw_module;    /* module the stream is attached to */
10059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_io_handle_t handle;           /* I/O handle of the input/output stream */
10069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    union {
10079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        //TODO: change use case for output streams: use strategy and mixer attributes
10089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        audio_stream_type_t stream;
10099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        audio_source_t      source;
10109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    } usecase;
10119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
10129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* extension for audio port configuration structure when the audio port is an
10149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * audio session */
10159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port_config_session_ext {
10169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_session_t   session; /* audio session */
10179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
10189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Flags indicating which fields are to be considered in struct audio_port_config */
10209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_CONFIG_SAMPLE_RATE  0x1
10219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_CONFIG_CHANNEL_MASK 0x2
10229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_CONFIG_FORMAT       0x4
10239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_CONFIG_GAIN         0x8
10249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_CONFIG_ALL (AUDIO_PORT_CONFIG_SAMPLE_RATE | \
10259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_PORT_CONFIG_CHANNEL_MASK | \
10269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_PORT_CONFIG_FORMAT | \
10279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand                               AUDIO_PORT_CONFIG_GAIN)
10289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* audio port configuration structure used to specify a particular configuration of
10309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * an audio port */
10319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port_config {
10329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_port_handle_t      id;           /* port unique ID */
10339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_port_role_t        role;         /* sink or source */
10349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_port_type_t        type;         /* device, mix ... */
10359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int             config_mask;  /* e.g AUDIO_PORT_CONFIG_ALL */
10369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int             sample_rate;  /* sampling rate in Hz */
10379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_channel_mask_t     channel_mask; /* channel mask if applicable */
10389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_format_t           format;       /* format if applicable */
10399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    struct audio_gain_config gain;         /* gain to apply if applicable */
10409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    union {
10419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        struct audio_port_config_device_ext  device;  /* device specific info */
10429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        struct audio_port_config_mix_ext     mix;     /* mix specific info */
10439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        struct audio_port_config_session_ext session; /* session specific info */
10449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    } ext;
10459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
10469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* max number of sampling rates in audio port */
10499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_MAX_SAMPLING_RATES 16
10509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* max number of channel masks in audio port */
10519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_MAX_CHANNEL_MASKS 16
10529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* max number of audio formats in audio port */
10539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_MAX_FORMATS 16
10549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* max number of gain controls in audio port */
10559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PORT_MAX_GAINS 16
10569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* extension for audio port structure when the audio port is a hardware device */
10589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port_device_ext {
10599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_module_handle_t hw_module;    /* module the device is attached to */
10609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_devices_t       type;         /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */
10619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    char                  address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
10629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
10639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Latency class of the audio mix */
10659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef enum {
10669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_LATENCY_LOW,
10679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    AUDIO_LATENCY_NORMAL,
10689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand} audio_mix_latency_class_t;
10699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* extension for audio port structure when the audio port is a sub mix */
10719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port_mix_ext {
10729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_module_handle_t     hw_module;     /* module the stream is attached to */
10739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_io_handle_t         handle;        /* I/O handle of the input.output stream */
10749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_mix_latency_class_t latency_class; /* latency class */
10759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    // other attributes: routing strategies
10769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
10779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* extension for audio port structure when the audio port is an audio session */
10799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port_session_ext {
10809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_session_t   session; /* audio session */
10819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
10829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
10839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_port {
10849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_port_handle_t      id;                /* port unique ID */
10859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_port_role_t        role;              /* sink or source */
10869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_port_type_t        type;              /* device, mix ... */
10879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    char                     name[AUDIO_PORT_MAX_NAME_LEN];
10889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int             num_sample_rates;  /* number of sampling rates in following array */
10899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int             sample_rates[AUDIO_PORT_MAX_SAMPLING_RATES];
10909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int             num_channel_masks; /* number of channel masks in following array */
10919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_channel_mask_t     channel_masks[AUDIO_PORT_MAX_CHANNEL_MASKS];
10929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int             num_formats;       /* number of formats in following array */
10939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_format_t           formats[AUDIO_PORT_MAX_FORMATS];
10949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int             num_gains;         /* number of gains in following array */
10959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    struct audio_gain        gains[AUDIO_PORT_MAX_GAINS];
10969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    struct audio_port_config active_config;     /* current audio port configuration */
10979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    union {
10989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        struct audio_port_device_ext  device;
10999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        struct audio_port_mix_ext     mix;
11009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        struct audio_port_session_ext session;
11019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    } ext;
11029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
11039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* An audio patch represents a connection between one or more source ports and
11059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * one or more sink ports. Patches are connected and disconnected by audio policy manager or by
11069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * applications via framework APIs.
11079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Each patch is identified by a handle at the interface used to create that patch. For instance,
11089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * when a patch is created by the audio HAL, the HAL allocates and returns a handle.
11099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * This handle is unique to a given audio HAL hardware module.
11109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * But the same patch receives another system wide unique handle allocated by the framework.
11119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * This unique handle is used for all transactions inside the framework.
11129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
11135612e098e2cbf9bbae69780f003144010fcc899cGlenn Kastentypedef enum {
11145612e098e2cbf9bbae69780f003144010fcc899cGlenn Kasten    AUDIO_PATCH_HANDLE_NONE = 0,
11155612e098e2cbf9bbae69780f003144010fcc899cGlenn Kasten} audio_patch_handle_t;
11169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_PATCH_PORTS_MAX   16
11189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstruct audio_patch {
11209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    audio_patch_handle_t id;            /* patch unique ID */
11219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int      num_sources;      /* number of sources in following array */
11229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    struct audio_port_config sources[AUDIO_PATCH_PORTS_MAX];
11239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    unsigned int      num_sinks;        /* number of sinks in following array */
11249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    struct audio_port_config sinks[AUDIO_PATCH_PORTS_MAX];
11259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand};
11269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* a HW synchronization source returned by the audio HAL */
11309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandtypedef uint32_t audio_hw_sync_t;
11319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* an invalid HW synchronization source indicating an error */
11339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#define AUDIO_HW_SYNC_INVALID 0
11349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_output_device(audio_devices_t device)
11369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    if (((device & AUDIO_DEVICE_BIT_IN) == 0) &&
11389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
11399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return true;
11409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    else
11419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return false;
11429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
11439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_input_device(audio_devices_t device)
11459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
11479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        device &= ~AUDIO_DEVICE_BIT_IN;
11489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0))
11499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            return true;
11509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
11519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return false;
11529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
11539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_output_devices(audio_devices_t device)
11559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return (device & AUDIO_DEVICE_BIT_IN) == 0;
11579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
11589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_a2dp_in_device(audio_devices_t device)
11609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
11629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        device &= ~AUDIO_DEVICE_BIT_IN;
11639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        if ((popcount(device) == 1) && (device & AUDIO_DEVICE_IN_BLUETOOTH_A2DP))
11649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            return true;
11659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
11669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return false;
11679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
11689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_a2dp_out_device(audio_devices_t device)
11709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP))
11729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return true;
11739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    else
11749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return false;
11759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
11769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand// Deprecated - use audio_is_a2dp_out_device() instead
11789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_a2dp_device(audio_devices_t device)
11799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return audio_is_a2dp_out_device(device);
11819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
11829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_bluetooth_sco_device(audio_devices_t device)
11849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    if ((device & AUDIO_DEVICE_BIT_IN) == 0) {
11869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL_SCO) == 0))
11879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            return true;
11889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    } else {
11899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        device &= ~AUDIO_DEVICE_BIT_IN;
11909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) == 0))
11919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            return true;
11929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
11939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return false;
11959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
11969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
11979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_usb_out_device(audio_devices_t device)
11989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
11999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB));
12009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
12019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
12029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_usb_in_device(audio_devices_t device)
12039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
12049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
12059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        device &= ~AUDIO_DEVICE_BIT_IN;
12069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        if (popcount(device) == 1 && (device & AUDIO_DEVICE_IN_ALL_USB) != 0)
12079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            return true;
12089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
12099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return false;
12109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
12119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
12129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* OBSOLETE - use audio_is_usb_out_device() instead. */
12139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_usb_device(audio_devices_t device)
12149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
12159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return audio_is_usb_out_device(device);
12169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
12179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
12189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_remote_submix_device(audio_devices_t device)
12199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
1220794857a8a1800e515d61970363c405db5359c2aaMisael Lopez Cruz    if ((audio_is_output_devices(device) &&
1221794857a8a1800e515d61970363c405db5359c2aaMisael Lopez Cruz         (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) == AUDIO_DEVICE_OUT_REMOTE_SUBMIX)
1222794857a8a1800e515d61970363c405db5359c2aaMisael Lopez Cruz        || (!audio_is_output_devices(device) &&
1223794857a8a1800e515d61970363c405db5359c2aaMisael Lopez Cruz         (device & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX))
12249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return true;
12259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    else
12269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return false;
12279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
12289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
12299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Returns true if:
12309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  representation is valid, and
12319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  there is at least one channel bit set which _could_ correspond to an input channel, and
12329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  there are no channel bits set which could _not_ correspond to an input channel.
12339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Otherwise returns false.
12349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
12359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_input_channel(audio_channel_mask_t channel)
12369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
12379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bits = audio_channel_mask_get_bits(channel);
12389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (audio_channel_mask_get_representation(channel)) {
12399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_POSITION:
12409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        if (bits & ~AUDIO_CHANNEL_IN_ALL) {
12419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            bits = 0;
12429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        }
12439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        // fall through
12449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_INDEX:
12459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return bits != 0;
12469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
12479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return false;
12489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
12499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
12509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
12519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Returns true if:
12529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  representation is valid, and
12539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  there is at least one channel bit set which _could_ correspond to an output channel, and
12549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand *  there are no channel bits set which could _not_ correspond to an output channel.
12559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Otherwise returns false.
12569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
12579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_output_channel(audio_channel_mask_t channel)
12589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
12599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bits = audio_channel_mask_get_bits(channel);
12609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (audio_channel_mask_get_representation(channel)) {
12619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_POSITION:
12629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        if (bits & ~AUDIO_CHANNEL_OUT_ALL) {
12639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            bits = 0;
12649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        }
12659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        // fall through
12669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_INDEX:
12679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return bits != 0;
12689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
12699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return false;
12709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
12719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
12729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
12739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Returns the number of channels from an input channel mask,
12749bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * used in the context of audio input or recording.
12759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * If a channel bit is set which could _not_ correspond to an input channel,
12769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * it is excluded from the count.
12779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Returns zero if the representation is invalid.
12789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
12799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline uint32_t audio_channel_count_from_in_mask(audio_channel_mask_t channel)
12809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
12819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bits = audio_channel_mask_get_bits(channel);
12829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (audio_channel_mask_get_representation(channel)) {
12839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_POSITION:
12849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        // TODO: We can now merge with from_out_mask and remove anding
12859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits &= AUDIO_CHANNEL_IN_ALL;
12869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        // fall through
12879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_INDEX:
12889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return popcount(bits);
12899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
12909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return 0;
12919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
12929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
12939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
12949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Returns the number of channels from an output channel mask,
12959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * used in the context of audio output or playback.
12969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * If a channel bit is set which could _not_ correspond to an output channel,
12979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * it is excluded from the count.
12989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Returns zero if the representation is invalid.
12999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
13009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline uint32_t audio_channel_count_from_out_mask(audio_channel_mask_t channel)
13019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
13029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bits = audio_channel_mask_get_bits(channel);
13039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (audio_channel_mask_get_representation(channel)) {
13049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_POSITION:
13059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        // TODO: We can now merge with from_in_mask and remove anding
13069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits &= AUDIO_CHANNEL_OUT_ALL;
13079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        // fall through
13089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_CHANNEL_REPRESENTATION_INDEX:
13099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return popcount(bits);
13109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
13119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return 0;
13129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
13139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
13149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
131521aa43a5ea032080aee301abc60780887f94665fGlenn Kasten/* Derive a channel mask for index assignment from a channel count.
131621aa43a5ea032080aee301abc60780887f94665fGlenn Kasten * Returns the matching channel mask,
131721aa43a5ea032080aee301abc60780887f94665fGlenn Kasten * or AUDIO_CHANNEL_NONE if the channel count is zero,
131821aa43a5ea032080aee301abc60780887f94665fGlenn Kasten * or AUDIO_CHANNEL_INVALID if the channel count exceeds AUDIO_CHANNEL_COUNT_MAX.
131921aa43a5ea032080aee301abc60780887f94665fGlenn Kasten */
132021aa43a5ea032080aee301abc60780887f94665fGlenn Kastenstatic inline audio_channel_mask_t audio_channel_mask_for_index_assignment_from_count(
132121aa43a5ea032080aee301abc60780887f94665fGlenn Kasten        uint32_t channel_count)
132221aa43a5ea032080aee301abc60780887f94665fGlenn Kasten{
132321aa43a5ea032080aee301abc60780887f94665fGlenn Kasten    if (channel_count == 0) {
132421aa43a5ea032080aee301abc60780887f94665fGlenn Kasten        return AUDIO_CHANNEL_NONE;
132521aa43a5ea032080aee301abc60780887f94665fGlenn Kasten    }
132621aa43a5ea032080aee301abc60780887f94665fGlenn Kasten    if (channel_count > AUDIO_CHANNEL_COUNT_MAX) {
132721aa43a5ea032080aee301abc60780887f94665fGlenn Kasten        return AUDIO_CHANNEL_INVALID;
132821aa43a5ea032080aee301abc60780887f94665fGlenn Kasten    }
132921aa43a5ea032080aee301abc60780887f94665fGlenn Kasten    uint32_t bits = (1 << channel_count) - 1;
133021aa43a5ea032080aee301abc60780887f94665fGlenn Kasten    return audio_channel_mask_from_representation_and_bits(
133121aa43a5ea032080aee301abc60780887f94665fGlenn Kasten            AUDIO_CHANNEL_REPRESENTATION_INDEX, bits);
133221aa43a5ea032080aee301abc60780887f94665fGlenn Kasten}
133321aa43a5ea032080aee301abc60780887f94665fGlenn Kasten
13349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* Derive an output channel mask for position assignment from a channel count.
13359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel
13369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad,
13379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC
13389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * for continuity with stereo.
13399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Returns the matching channel mask,
13409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * or AUDIO_CHANNEL_NONE if the channel count is zero,
13419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the
13429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * configurations for which a default output channel mask is defined.
13439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
13449bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count)
13459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
13469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bits;
13479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (channel_count) {
13489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 0:
13499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return AUDIO_CHANNEL_NONE;
13509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 1:
13519bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_MONO;
13529bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13539bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 2:
13549bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_STEREO;
13559bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13569bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 3:
13579bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER;
13589bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13599bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 4: // 4.0
13609bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_QUAD;
13619bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 5: // 5.0
13639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER;
13649bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13659bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 6: // 5.1
13669bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_5POINT1;
13679bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13689bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 7: // 6.1
13699bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER;
13709bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13719bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 8:
13729bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_OUT_7POINT1;
13739bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13742c29cee2e519db2decc91747b01f54597a856d1bGlenn Kasten    // FIXME FCC_8
13759bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
13769bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return AUDIO_CHANNEL_INVALID;
13779bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
13789bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return audio_channel_mask_from_representation_and_bits(
13799bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            AUDIO_CHANNEL_REPRESENTATION_POSITION, bits);
13809bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
13819bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
13827cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten/* Derive a default input channel mask from a channel count.
13837cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten * Assumes a position mask for mono and stereo, or an index mask for channel counts > 2.
13849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * Returns the matching channel mask,
13859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * or AUDIO_CHANNEL_NONE if the channel count is zero,
13869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the
13879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand * configurations for which a default input channel mask is defined.
13889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand */
13899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count)
13909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
13919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    uint32_t bits;
13929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (channel_count) {
13939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 0:
13949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return AUDIO_CHANNEL_NONE;
13959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 1:
13969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_IN_MONO;
13979bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
13989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case 2:
13999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        bits = AUDIO_CHANNEL_IN_STEREO;
14009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
14017cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten    case 3:
14027cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten    case 4:
14037cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten    case 5:
14047cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten    case 6:
14057cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten    case 7:
14067cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten    case 8:
14077cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten        // FIXME FCC_8
14087cb33cef3d5031ed0c14d114aec1ef7c972df476Glenn Kasten        return audio_channel_mask_for_index_assignment_from_count(channel_count);
14099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
14109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return AUDIO_CHANNEL_INVALID;
14119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
14129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return audio_channel_mask_from_representation_and_bits(
14139bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            AUDIO_CHANNEL_REPRESENTATION_POSITION, bits);
14149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
14159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
14169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_valid_format(audio_format_t format)
14179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
14189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (format & AUDIO_FORMAT_MAIN_MASK) {
14199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_PCM:
14209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        switch (format) {
14219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        case AUDIO_FORMAT_PCM_16_BIT:
14229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        case AUDIO_FORMAT_PCM_8_BIT:
14239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        case AUDIO_FORMAT_PCM_32_BIT:
14249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        case AUDIO_FORMAT_PCM_8_24_BIT:
14259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        case AUDIO_FORMAT_PCM_FLOAT:
14269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        case AUDIO_FORMAT_PCM_24_BIT_PACKED:
14279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            return true;
14289bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        default:
14299bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand            return false;
14309bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        }
14319bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        /* not reached */
14329bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_MP3:
14339bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_AMR_NB:
14349bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_AMR_WB:
14359bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_AAC:
14369bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_HE_AAC_V1:
14379bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_HE_AAC_V2:
14389bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_VORBIS:
14399bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_OPUS:
14409bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_AC3:
14419bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_E_AC3:
14429bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_DTS:
14439bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_DTS_HD:
144497763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    case AUDIO_FORMAT_IEC61937:
14459bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return true;
14469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
14479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        return false;
14489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
14499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
14509bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
145197763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk/**
145297763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * Extract the primary format, eg. PCM, AC3, etc.
145397763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk */
145497763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burkstatic inline audio_format_t audio_get_main_format(audio_format_t format)
145597763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk{
145697763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    return (audio_format_t)(format & AUDIO_FORMAT_MAIN_MASK);
145797763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk}
145897763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk
145997763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk/**
146097763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * Is the data plain PCM samples that can be scaled and mixed?
146197763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk */
14629bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline bool audio_is_linear_pcm(audio_format_t format)
14639bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
146497763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    return (audio_get_main_format(format) == AUDIO_FORMAT_PCM);
146597763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk}
146697763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk
146797763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk/**
146897763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * For this format, is the number of PCM audio frames directly proportional
146997763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * to the number of data bytes?
147097763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk *
147197763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * In other words, is the format transported as PCM audio samples,
147297763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * but not necessarily scalable or mixable.
147397763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * This returns true for real PCM, but also for AUDIO_FORMAT_IEC61937,
147497763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * which is transported as 16 bit PCM audio, but where the encoded data
147597763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk * cannot be mixed or scaled.
147697763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk */
147797763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burkstatic inline bool audio_has_proportional_frames(audio_format_t format)
147897763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk{
147997763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    audio_format_t mainFormat = audio_get_main_format(format);
148097763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    return (mainFormat == AUDIO_FORMAT_PCM
148197763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk            || mainFormat == AUDIO_FORMAT_IEC61937);
14829bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
14839bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
14849bd6157cdd2e513293005081c431604df4da6750Rom Lemarchandstatic inline size_t audio_bytes_per_sample(audio_format_t format)
14859bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
14869bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    size_t size = 0;
14879bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
14889bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    switch (format) {
14899bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_PCM_32_BIT:
14909bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_PCM_8_24_BIT:
14919bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        size = sizeof(int32_t);
14929bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
14939bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_PCM_24_BIT_PACKED:
14949bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        size = sizeof(uint8_t) * 3;
14959bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
14969bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_PCM_16_BIT:
149797763f31a43caaf6b76e99e8d20abcc27141ec52Phil Burk    case AUDIO_FORMAT_IEC61937:
14989bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        size = sizeof(int16_t);
14999bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
15009bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_PCM_8_BIT:
15019bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        size = sizeof(uint8_t);
15029bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
15039bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    case AUDIO_FORMAT_PCM_FLOAT:
15049bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        size = sizeof(float);
15059bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
15069bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    default:
15079bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        break;
15089bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    }
15099bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return size;
15109bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
15119bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
15129bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand/* converts device address to string sent to audio HAL via set_parameters */
1513ed5246d4a581cdc5aa16a27e8dd70d52fe8cd2bbArman Uguraystatic inline char *audio_device_address_to_parameter(audio_devices_t device, const char *address)
15149bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand{
15159bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    const size_t kSize = AUDIO_DEVICE_MAX_ADDRESS_LEN + sizeof("a2dp_sink_address=");
15169bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    char param[kSize];
15179bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
15189bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    if (device & AUDIO_DEVICE_OUT_ALL_A2DP)
15199bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        snprintf(param, kSize, "%s=%s", "a2dp_sink_address", address);
15209bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    else if (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX)
15219bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        snprintf(param, kSize, "%s=%s", "mix", address);
15229bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    else
15239bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand        snprintf(param, kSize, "%s", address);
15249bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
15259bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand    return strdup(param);
15269bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand}
15279bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
15289598786860a469193a65c23bf424093d9ae5867cPaul McLeanstatic inline bool audio_device_is_digital(audio_devices_t device) {
15299598786860a469193a65c23bf424093d9ae5867cPaul McLean    if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
15309598786860a469193a65c23bf424093d9ae5867cPaul McLean        // input
15310b1a35902f6a9033ac11f245624aab198ff236b1Eric Laurent        return (~AUDIO_DEVICE_BIT_IN & device & (AUDIO_DEVICE_IN_ALL_USB |
15329598786860a469193a65c23bf424093d9ae5867cPaul McLean                          AUDIO_DEVICE_IN_HDMI |
15334d5418183c209ecd5c4109f0ecb6c6f259360c0eEric Laurent                          AUDIO_DEVICE_IN_SPDIF |
15347f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent                          AUDIO_DEVICE_IN_IP |
15357f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent                          AUDIO_DEVICE_IN_BUS)) != 0;
15369598786860a469193a65c23bf424093d9ae5867cPaul McLean    } else {
15379598786860a469193a65c23bf424093d9ae5867cPaul McLean        // output
15389598786860a469193a65c23bf424093d9ae5867cPaul McLean        return (device & (AUDIO_DEVICE_OUT_ALL_USB |
15399598786860a469193a65c23bf424093d9ae5867cPaul McLean                          AUDIO_DEVICE_OUT_HDMI |
15409598786860a469193a65c23bf424093d9ae5867cPaul McLean                          AUDIO_DEVICE_OUT_HDMI_ARC |
15414d5418183c209ecd5c4109f0ecb6c6f259360c0eEric Laurent                          AUDIO_DEVICE_OUT_SPDIF |
15427f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent                          AUDIO_DEVICE_OUT_IP |
15437f695e4d92da0de59fa4087b5f21e2cdbe82da2aEric Laurent                          AUDIO_DEVICE_OUT_BUS)) != 0;
15449598786860a469193a65c23bf424093d9ae5867cPaul McLean    }
15459598786860a469193a65c23bf424093d9ae5867cPaul McLean}
15469bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
15479bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand__END_DECLS
15489bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand
15499bd6157cdd2e513293005081c431604df4da6750Rom Lemarchand#endif  // ANDROID_AUDIO_CORE_H
1550