1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #ifndef ANDROID_AUDIO_POLICY_CORE_H
19 #define ANDROID_AUDIO_POLICY_CORE_H
20
21 #include <stdint.h>
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
24
25 __BEGIN_DECLS
26
27 /* The enums were moved here mostly from
28 * frameworks/base/include/media/AudioSystem.h
29 */
30
31 #define AUDIO_ENUM_QUOTE(x) #x
32 #define AUDIO_ENUM_STRINGIFY(x) AUDIO_ENUM_QUOTE(x)
33 #define AUDIO_DEFINE_ENUM_SYMBOL(symbol) symbol,
34 #define AUDIO_DEFINE_STRINGIFY_CASE(symbol) case symbol: return AUDIO_ENUM_STRINGIFY(symbol);
35
36 /* device categories used for audio_policy->set_force_use()
37 * These must match the values in AudioSystem.java
38 */
39 #define AUDIO_POLICY_FORCE_LIST_DEF(V) \
40 V(AUDIO_POLICY_FORCE_NONE) \
41 V(AUDIO_POLICY_FORCE_SPEAKER) \
42 V(AUDIO_POLICY_FORCE_HEADPHONES) \
43 V(AUDIO_POLICY_FORCE_BT_SCO) \
44 V(AUDIO_POLICY_FORCE_BT_A2DP) \
45 V(AUDIO_POLICY_FORCE_WIRED_ACCESSORY) \
46 V(AUDIO_POLICY_FORCE_BT_CAR_DOCK) \
47 V(AUDIO_POLICY_FORCE_BT_DESK_DOCK) \
48 V(AUDIO_POLICY_FORCE_ANALOG_DOCK) \
49 V(AUDIO_POLICY_FORCE_DIGITAL_DOCK) \
50 V(AUDIO_POLICY_FORCE_NO_BT_A2DP) \
51 V(AUDIO_POLICY_FORCE_SYSTEM_ENFORCED) \
52 V(AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED) \
53 V(AUDIO_POLICY_FORCE_ENCODED_SURROUND_NEVER) \
54 V(AUDIO_POLICY_FORCE_ENCODED_SURROUND_ALWAYS) \
55 V(AUDIO_POLICY_FORCE_ENCODED_SURROUND_MANUAL) \
56 V(AUDIO_POLICY_FORCE_BT_BLE)
57
58 typedef enum {
59 AUDIO_POLICY_FORCE_LIST_DEF(AUDIO_DEFINE_ENUM_SYMBOL)
60
61 AUDIO_POLICY_FORCE_CFG_CNT,
62 AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1,
63
64 AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE,
65 } audio_policy_forced_cfg_t;
66
audio_policy_forced_cfg_to_string(audio_policy_forced_cfg_t t)67 inline const char* audio_policy_forced_cfg_to_string(audio_policy_forced_cfg_t t) {
68 switch (t) {
69 AUDIO_POLICY_FORCE_LIST_DEF(AUDIO_DEFINE_STRINGIFY_CASE)
70 default:
71 return "";
72 }
73 }
74
75 #undef AUDIO_POLICY_FORCE_LIST_DEF
76
77 /* usages used for audio_policy->set_force_use()
78 * These must match the values in AudioSystem.java
79 */
80 typedef enum {
81 AUDIO_POLICY_FORCE_FOR_COMMUNICATION,
82 AUDIO_POLICY_FORCE_FOR_MEDIA,
83 AUDIO_POLICY_FORCE_FOR_RECORD,
84 AUDIO_POLICY_FORCE_FOR_DOCK,
85 AUDIO_POLICY_FORCE_FOR_SYSTEM,
86 AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO,
87 AUDIO_POLICY_FORCE_FOR_ENCODED_SURROUND,
88 AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING,
89
90 AUDIO_POLICY_FORCE_USE_CNT,
91 AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1,
92 } audio_policy_force_use_t;
93
94 /* device connection states used for audio_policy->set_device_connection_state()
95 */
96 typedef enum {
97 AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
98 AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
99
100 AUDIO_POLICY_DEVICE_STATE_CNT,
101 AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1,
102 } audio_policy_dev_state_t;
103
104 typedef enum {
105 /* Used to generate a tone to notify the user of a
106 * notification/alarm/ringtone while they are in a call. */
107 AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION = 0,
108
109 AUDIO_POLICY_TONE_CNT,
110 AUDIO_POLICY_TONE_MAX = AUDIO_POLICY_TONE_CNT - 1,
111 } audio_policy_tone_t;
112
113 /* AudioRecord client UID state derived from ActivityManager::PROCESS_STATE_XXX
114 * and used for concurrent capture policy.
115 */
116 typedef enum {
117 APP_STATE_IDLE = 0, /* client is idle: cannot capture */
118 APP_STATE_FOREGROUND, /* client has a foreground service: can capture */
119 APP_STATE_TOP, /* client has a visible UI: can capture and select use case */
120 } app_state_t;
121
122 /* The role indicates how the audio policy manager should consider particular
123 * device(s) when making routing decisions for a particular strategy or audio
124 * source. It is primarily used to override the default routing rules.
125 */
126 typedef enum {
127 DEVICE_ROLE_NONE = 0, /* default routing rules and priority apply */
128 DEVICE_ROLE_PREFERRED = 1, /* devices are specified as preferred devices */
129 DEVICE_ROLE_DISABLED = 2, /* devices cannot be used */
130 } device_role_t;
131
132 #undef AUDIO_DEFINE_STRINGIFY_CASE
133 #undef AUDIO_DEFINE_ENUM_SYMBOL
134 #undef AUDIO_ENUM_STRINGIFY
135 #undef AUDIO_ENUM_QUOTE
136
137 __END_DECLS
138
139 #endif // ANDROID_AUDIO_POLICY_CORE_H
140