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 /* device categories used for audio_policy->set_force_use()
32  * These must match the values in AudioSystem.java
33  */
34 typedef enum {
35     AUDIO_POLICY_FORCE_NONE,
36     AUDIO_POLICY_FORCE_SPEAKER,
37     AUDIO_POLICY_FORCE_HEADPHONES,
38     AUDIO_POLICY_FORCE_BT_SCO,
39     AUDIO_POLICY_FORCE_BT_A2DP,
40     AUDIO_POLICY_FORCE_WIRED_ACCESSORY,
41     AUDIO_POLICY_FORCE_BT_CAR_DOCK,
42     AUDIO_POLICY_FORCE_BT_DESK_DOCK,
43     AUDIO_POLICY_FORCE_ANALOG_DOCK,
44     AUDIO_POLICY_FORCE_DIGITAL_DOCK,
45     AUDIO_POLICY_FORCE_NO_BT_A2DP, /* A2DP sink is not preferred to speaker or wired HS */
46     AUDIO_POLICY_FORCE_SYSTEM_ENFORCED,
47     AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED,
48     AUDIO_POLICY_FORCE_ENCODED_SURROUND_NEVER,
49     AUDIO_POLICY_FORCE_ENCODED_SURROUND_ALWAYS,
50     AUDIO_POLICY_FORCE_ENCODED_SURROUND_MANUAL,
51 
52     AUDIO_POLICY_FORCE_CFG_CNT,
53     AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1,
54 
55     AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE,
56 } audio_policy_forced_cfg_t;
57 
58 /* usages used for audio_policy->set_force_use()
59  * These must match the values in AudioSystem.java
60  */
61 typedef enum {
62     AUDIO_POLICY_FORCE_FOR_COMMUNICATION,
63     AUDIO_POLICY_FORCE_FOR_MEDIA,
64     AUDIO_POLICY_FORCE_FOR_RECORD,
65     AUDIO_POLICY_FORCE_FOR_DOCK,
66     AUDIO_POLICY_FORCE_FOR_SYSTEM,
67     AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO,
68     AUDIO_POLICY_FORCE_FOR_ENCODED_SURROUND,
69     AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING,
70 
71     AUDIO_POLICY_FORCE_USE_CNT,
72     AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1,
73 } audio_policy_force_use_t;
74 
75 /* device connection states used for audio_policy->set_device_connection_state()
76  */
77 typedef enum {
78     AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
79     AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
80 
81     AUDIO_POLICY_DEVICE_STATE_CNT,
82     AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1,
83 } audio_policy_dev_state_t;
84 
85 typedef enum {
86     /* Used to generate a tone to notify the user of a
87      * notification/alarm/ringtone while they are in a call. */
88     AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION = 0,
89 
90     AUDIO_POLICY_TONE_CNT,
91     AUDIO_POLICY_TONE_MAX                  = AUDIO_POLICY_TONE_CNT - 1,
92 } audio_policy_tone_t;
93 
94 /* AudioRecord client UID state derived from ActivityManager::PROCESS_STATE_XXX
95  * and used for concurrent capture policy.
96  */
97 typedef enum {
98     APP_STATE_IDLE = 0,   /* client is idle: cannot capture */
99     APP_STATE_FOREGROUND, /* client has a foreground service: can capture */
100     APP_STATE_TOP, /* client has a visible UI: can capture and select use case */
101 } app_state_t;
102 
103 /* The role indicates how the audio policy manager should consider particular
104  * device(s) when making routing decisions for a particular strategy or audio
105  * source. It is primarily used to override the default routing rules.
106  */
107 typedef enum {
108     DEVICE_ROLE_NONE = 0, /* default routing rules and priority apply */
109     DEVICE_ROLE_PREFERRED = 1, /* devices are specified as preferred devices */
110     DEVICE_ROLE_DISABLED = 2, /* devices cannot be used */
111 } device_role_t;
112 
113 __END_DECLS
114 
115 #endif  // ANDROID_AUDIO_POLICY_CORE_H
116