• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_AUDIO_BASE_UTILS_H
18 #define ANDROID_AUDIO_BASE_UTILS_H
19 
20 #include "audio-base.h"
21 
22 /** Define helper values to iterate over enum, extend them or checking value validity.
23  *  Those values are compatible with the O corresponding enum values.
24  *  They are not macro like similar values in audio.h to avoid conflicting
25  *  with the libhardware_legacy audio.h.
26  */
27 enum {
28     /** Number of audio stream available to vendors. */
29     AUDIO_STREAM_PUBLIC_CNT = AUDIO_STREAM_ACCESSIBILITY + 1,
30 
31 #ifndef AUDIO_NO_SYSTEM_DECLARATIONS
32     /** Total number of stream handled by the policy*/
33     AUDIO_STREAM_FOR_POLICY_CNT= AUDIO_STREAM_REROUTING + 1,
34 #endif
35 
36    /** Total number of stream. */
37     AUDIO_STREAM_CNT          = AUDIO_STREAM_PATCH + 1,
38 
39     AUDIO_SOURCE_MAX          = AUDIO_SOURCE_VOICE_PERFORMANCE,
40     AUDIO_SOURCE_CNT          = AUDIO_SOURCE_MAX + 1,
41 
42     AUDIO_MODE_MAX            = AUDIO_MODE_IN_COMMUNICATION,
43     AUDIO_MODE_CNT            = AUDIO_MODE_MAX + 1,
44 
45     /** For retrocompatibility AUDIO_MODE_* and AUDIO_STREAM_* must be signed. */
46     AUDIO_DETAIL_NEGATIVE_VALUE = -1,
47 };
48 
49 enum {
50     AUDIO_CHANNEL_OUT_ALL     = AUDIO_CHANNEL_OUT_FRONT_LEFT |
51                                 AUDIO_CHANNEL_OUT_FRONT_RIGHT |
52                                 AUDIO_CHANNEL_OUT_FRONT_CENTER |
53                                 AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
54                                 AUDIO_CHANNEL_OUT_BACK_LEFT |
55                                 AUDIO_CHANNEL_OUT_BACK_RIGHT |
56                                 AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER |
57                                 AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER |
58                                 AUDIO_CHANNEL_OUT_BACK_CENTER |
59                                 AUDIO_CHANNEL_OUT_SIDE_LEFT |
60                                 AUDIO_CHANNEL_OUT_SIDE_RIGHT |
61                                 AUDIO_CHANNEL_OUT_TOP_CENTER |
62                                 AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT |
63                                 AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER |
64                                 AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT |
65                                 AUDIO_CHANNEL_OUT_TOP_BACK_LEFT |
66                                 AUDIO_CHANNEL_OUT_TOP_BACK_CENTER |
67                                 AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT |
68                                 AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT |
69                                 AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT |
70                                 AUDIO_CHANNEL_OUT_HAPTIC_B |
71                                 AUDIO_CHANNEL_OUT_HAPTIC_A,
72 
73     AUDIO_CHANNEL_IN_ALL      = AUDIO_CHANNEL_IN_LEFT |
74                                 AUDIO_CHANNEL_IN_RIGHT |
75                                 AUDIO_CHANNEL_IN_FRONT |
76                                 AUDIO_CHANNEL_IN_BACK|
77                                 AUDIO_CHANNEL_IN_LEFT_PROCESSED |
78                                 AUDIO_CHANNEL_IN_RIGHT_PROCESSED |
79                                 AUDIO_CHANNEL_IN_FRONT_PROCESSED |
80                                 AUDIO_CHANNEL_IN_BACK_PROCESSED|
81                                 AUDIO_CHANNEL_IN_PRESSURE |
82                                 AUDIO_CHANNEL_IN_X_AXIS |
83                                 AUDIO_CHANNEL_IN_Y_AXIS |
84                                 AUDIO_CHANNEL_IN_Z_AXIS |
85                                 AUDIO_CHANNEL_IN_VOICE_UPLINK |
86                                 AUDIO_CHANNEL_IN_VOICE_DNLINK |
87                                 AUDIO_CHANNEL_IN_BACK_LEFT |
88                                 AUDIO_CHANNEL_IN_BACK_RIGHT |
89                                 AUDIO_CHANNEL_IN_CENTER |
90                                 AUDIO_CHANNEL_IN_LOW_FREQUENCY |
91                                 AUDIO_CHANNEL_IN_TOP_LEFT |
92                                 AUDIO_CHANNEL_IN_TOP_RIGHT,
93 
94     AUDIO_CHANNEL_HAPTIC_ALL  = AUDIO_CHANNEL_OUT_HAPTIC_B |
95                                 AUDIO_CHANNEL_OUT_HAPTIC_A,
96 
97     AUDIO_DEVICE_OUT_ALL      = AUDIO_DEVICE_OUT_EARPIECE |
98                                 AUDIO_DEVICE_OUT_SPEAKER |
99                                 AUDIO_DEVICE_OUT_WIRED_HEADSET |
100                                 AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
101                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
102                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
103                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT |
104                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
105                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
106                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER |
107                                 AUDIO_DEVICE_OUT_HDMI |
108                                 AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
109                                 AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET |
110                                 AUDIO_DEVICE_OUT_USB_ACCESSORY |
111                                 AUDIO_DEVICE_OUT_USB_DEVICE |
112                                 AUDIO_DEVICE_OUT_REMOTE_SUBMIX |
113                                 AUDIO_DEVICE_OUT_TELEPHONY_TX |
114                                 AUDIO_DEVICE_OUT_LINE |
115                                 AUDIO_DEVICE_OUT_HDMI_ARC |
116                                 AUDIO_DEVICE_OUT_SPDIF |
117                                 AUDIO_DEVICE_OUT_FM |
118                                 AUDIO_DEVICE_OUT_AUX_LINE |
119                                 AUDIO_DEVICE_OUT_SPEAKER_SAFE |
120                                 AUDIO_DEVICE_OUT_IP |
121                                 AUDIO_DEVICE_OUT_BUS |
122                                 AUDIO_DEVICE_OUT_PROXY |
123                                 AUDIO_DEVICE_OUT_USB_HEADSET |
124                                 AUDIO_DEVICE_OUT_HEARING_AID |
125                                 AUDIO_DEVICE_OUT_ECHO_CANCELLER |
126                                 AUDIO_DEVICE_OUT_DEFAULT,
127 
128     AUDIO_DEVICE_OUT_ALL_A2DP = AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
129                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
130                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER,
131 
132     AUDIO_DEVICE_OUT_ALL_SCO  = AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
133                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
134                                 AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT,
135 
136     AUDIO_DEVICE_OUT_ALL_USB  = AUDIO_DEVICE_OUT_USB_ACCESSORY |
137                                 AUDIO_DEVICE_OUT_USB_DEVICE |
138                                 AUDIO_DEVICE_OUT_USB_HEADSET,
139 
140     AUDIO_DEVICE_IN_ALL       = AUDIO_DEVICE_IN_COMMUNICATION |
141                                 AUDIO_DEVICE_IN_AMBIENT |
142                                 AUDIO_DEVICE_IN_BUILTIN_MIC |
143                                 AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET |
144                                 AUDIO_DEVICE_IN_WIRED_HEADSET |
145                                 AUDIO_DEVICE_IN_HDMI |
146                                 AUDIO_DEVICE_IN_TELEPHONY_RX |
147                                 AUDIO_DEVICE_IN_BACK_MIC |
148                                 AUDIO_DEVICE_IN_REMOTE_SUBMIX |
149                                 AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET |
150                                 AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET |
151                                 AUDIO_DEVICE_IN_USB_ACCESSORY |
152                                 AUDIO_DEVICE_IN_USB_DEVICE |
153                                 AUDIO_DEVICE_IN_FM_TUNER |
154                                 AUDIO_DEVICE_IN_TV_TUNER |
155                                 AUDIO_DEVICE_IN_LINE |
156                                 AUDIO_DEVICE_IN_SPDIF |
157                                 AUDIO_DEVICE_IN_BLUETOOTH_A2DP |
158                                 AUDIO_DEVICE_IN_LOOPBACK |
159                                 AUDIO_DEVICE_IN_IP |
160                                 AUDIO_DEVICE_IN_BUS |
161                                 AUDIO_DEVICE_IN_PROXY |
162                                 AUDIO_DEVICE_IN_USB_HEADSET |
163                                 AUDIO_DEVICE_IN_BLUETOOTH_BLE |
164                                 AUDIO_DEVICE_IN_HDMI_ARC |
165                                 AUDIO_DEVICE_IN_ECHO_REFERENCE |
166                                 AUDIO_DEVICE_IN_DEFAULT,
167 
168     AUDIO_DEVICE_IN_ALL_SCO   = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
169 
170     AUDIO_DEVICE_IN_ALL_USB   = AUDIO_DEVICE_IN_USB_ACCESSORY |
171                                 AUDIO_DEVICE_IN_USB_DEVICE |
172                                 AUDIO_DEVICE_IN_USB_HEADSET,
173 
174     AUDIO_USAGE_MAX           = AUDIO_USAGE_ASSISTANT,
175     AUDIO_USAGE_CNT           = AUDIO_USAGE_ASSISTANT + 1,
176 
177     AUDIO_PORT_CONFIG_ALL     = AUDIO_PORT_CONFIG_SAMPLE_RATE |
178                                 AUDIO_PORT_CONFIG_CHANNEL_MASK |
179                                 AUDIO_PORT_CONFIG_FORMAT |
180                                 AUDIO_PORT_CONFIG_GAIN,
181 }; // enum
182 
183 // Add new aliases
184 enum {
185     AUDIO_CHANNEL_OUT_TRI                   = 0x7u,     // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER
186     AUDIO_CHANNEL_OUT_TRI_BACK              = 0x103u,   // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_BACK_CENTER
187     AUDIO_CHANNEL_OUT_3POINT1               = 0xFu,     // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY
188 };
189 
190 // Microphone Field Dimension Constants
191 #define MIC_FIELD_DIMENSION_WIDE (-1.0f)
192 #define MIC_FIELD_DIMENSION_NORMAL (0.0f)
193 #define MIC_FIELD_DIMENSION_NARROW (1.0f)
194 #define MIC_FIELD_DIMENSION_DEFAULT MIC_FIELD_DIMENSION_NORMAL
195 
196 #endif  // ANDROID_AUDIO_BASE_UTILS_H
197