• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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_AUDIOMANAGER_H
18 #define ANDROID_AUDIOMANAGER_H
19 
20 namespace android {
21 
22 // must be kept in sync with definitions in AudioPlaybackConfiguration.java
23 #define PLAYER_PIID_INVALID -1
24 
25 typedef enum {
26     PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE = 11,
27     PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD = 12,
28     PLAYER_TYPE_AAUDIO = 13,
29     PLAYER_TYPE_HW_SOURCE = 14,
30     PLAYER_TYPE_EXTERNAL_PROXY = 15,
31 } player_type_t;
32 
33 typedef enum {
34     PLAYER_STATE_UNKNOWN  = -1,
35     PLAYER_STATE_RELEASED = 0,
36     PLAYER_STATE_IDLE     = 1,
37     PLAYER_STATE_STARTED  = 2,
38     PLAYER_STATE_PAUSED   = 3,
39     PLAYER_STATE_STOPPED  = 4,
40     PLAYER_UPDATE_DEVICE_ID = 5,
41     PLAYER_UPDATE_PORT_ID = 6,
42     PLAYER_UPDATE_MUTED = 7,
43     PLAYER_UPDATE_FORMAT = 8,
44 } player_state_t;
45 
46 static constexpr char
47     kExtraPlayerEventSpatializedKey[] = "android.media.extra.PLAYER_EVENT_SPATIALIZED";
48 static constexpr char
49     kExtraPlayerEventSampleRateKey[] = "android.media.extra.PLAYER_EVENT_SAMPLE_RATE";
50 static constexpr char
51     kExtraPlayerEventChannelMaskKey[] = "android.media.extra.PLAYER_EVENT_CHANNEL_MASK";
52 
53 static constexpr char
54     kExtraPlayerEventMuteKey[] = "android.media.extra.PLAYER_EVENT_MUTE";
55 enum {
56     PLAYER_MUTE_MASTER = (1 << 0),
57     PLAYER_MUTE_STREAM_VOLUME = (1 << 1),
58     PLAYER_MUTE_STREAM_MUTED = (1 << 2),
59     PLAYER_MUTE_PLAYBACK_RESTRICTED = (1 << 3),
60     PLAYER_MUTE_CLIENT_VOLUME = (1 << 4),
61     PLAYER_MUTE_VOLUME_SHAPER = (1 << 5),
62 };
63 
64 struct mute_state_t {
65     /** Flag used when the master volume is causing the mute state. */
66     bool muteFromMasterMute = false;
67     /** Flag used when the stream volume is causing the mute state. */
68     bool muteFromStreamVolume = false;
69     /** Flag used when the stream muted is causing the mute state. */
70     bool muteFromStreamMuted = false;
71     /** Flag used when playback is restricted by AppOps manager with OP_PLAY_AUDIO. */
72     bool muteFromPlaybackRestricted = false;
73     /** Flag used when audio track was muted by client volume. */
74     bool muteFromClientVolume = false;
75      /** Flag used when volume is muted by volume shaper. */
76     bool muteFromVolumeShaper = false;
77 
78     explicit operator int() const
79     {
80         int result = muteFromMasterMute * PLAYER_MUTE_MASTER;
81         result |= muteFromStreamVolume * PLAYER_MUTE_STREAM_VOLUME;
82         result |= muteFromStreamMuted * PLAYER_MUTE_STREAM_MUTED;
83         result |= muteFromPlaybackRestricted * PLAYER_MUTE_PLAYBACK_RESTRICTED;
84         result |= muteFromClientVolume * PLAYER_MUTE_CLIENT_VOLUME;
85         result |= muteFromVolumeShaper * PLAYER_MUTE_VOLUME_SHAPER;
86         return result;
87     }
88 
89     bool operator==(const mute_state_t& other) const
90     {
91         return static_cast<int>(*this) == static_cast<int>(other);
92     }
93 };
94 
95 // must be kept in sync with definitions in AudioManager.java
96 #define RECORD_RIID_INVALID -1
97 
98 typedef enum {
99     RECORDER_STATE_UNKNOWN  = -1,
100     RECORDER_STATE_STARTED  = 0,
101     RECORDER_STATE_STOPPED  = 1,
102 } recorder_state_t;
103 
104 }; // namespace android
105 
106 #endif // ANDROID_AUDIOMANAGER_H
107