blob: 917d9a74db86e5330fbcfbdeb42e19db1d007ff5 [file] [log] [blame]
Jean-Michel Trivi0008a482016-12-26 15:58:24 -08001/*
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
20namespace android {
21
22// must be kept in sync with definitions in AudioPlaybackConfiguration.java
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080023#define PLAYER_PIID_INVALID -1
24
Jean-Michel Trivi63189322017-01-05 18:05:28 -080025typedef enum {
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080026 PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE = 11,
27 PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD = 12,
Jean-Michel Trivi10fed362017-05-25 15:17:39 -070028 PLAYER_TYPE_AAUDIO = 13,
29 PLAYER_TYPE_HW_SOURCE = 14,
30 PLAYER_TYPE_EXTERNAL_PROXY = 15,
Jean-Michel Trivi63189322017-01-05 18:05:28 -080031} player_type_t;
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080032
Jean-Michel Trivi63189322017-01-05 18:05:28 -080033typedef enum {
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080034 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,
Oscar Azucenafae808f2020-12-22 20:40:07 +000040 PLAYER_UPDATE_DEVICE_ID = 5,
Vlad Popa459fc742022-06-10 00:07:27 +020041 PLAYER_UPDATE_PORT_ID = 6,
Vlad Popa5cb98562022-06-30 15:48:16 +020042 PLAYER_UPDATE_MUTED = 7,
Jean-Michel Trivi26e617d2022-12-21 03:42:34 +000043 PLAYER_UPDATE_FORMAT = 8,
Jean-Michel Trivi63189322017-01-05 18:05:28 -080044} player_state_t;
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080045
Vlad Popa5cb98562022-06-30 15:48:16 +020046static constexpr char
Jean-Michel Trivi26e617d2022-12-21 03:42:34 +000047 kExtraPlayerEventSpatializedKey[] = "android.media.extra.PLAYER_EVENT_SPATIALIZED";
48static constexpr char
49 kExtraPlayerEventSampleRateKey[] = "android.media.extra.PLAYER_EVENT_SAMPLE_RATE";
50static constexpr char
51 kExtraPlayerEventChannelMaskKey[] = "android.media.extra.PLAYER_EVENT_CHANNEL_MASK";
52
53static constexpr char
Vlad Popa5cb98562022-06-30 15:48:16 +020054 kExtraPlayerEventMuteKey[] = "android.media.extra.PLAYER_EVENT_MUTE";
55enum {
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),
Vlad Popa99ac9472022-07-25 15:42:50 +020060 PLAYER_MUTE_CLIENT_VOLUME = (1 << 4),
Vlad Popa5ceac8f2022-08-02 15:46:39 +020061 PLAYER_MUTE_VOLUME_SHAPER = (1 << 5),
Vlad Popadc1ce4d2024-08-27 15:08:14 -070062 PLAYER_MUTE_PORT_VOLUME = (1 << 6),
Vlad Popa5cb98562022-06-30 15:48:16 +020063};
64
65struct mute_state_t {
66 /** Flag used when the master volume is causing the mute state. */
67 bool muteFromMasterMute = false;
68 /** Flag used when the stream volume is causing the mute state. */
69 bool muteFromStreamVolume = false;
70 /** Flag used when the stream muted is causing the mute state. */
71 bool muteFromStreamMuted = false;
72 /** Flag used when playback is restricted by AppOps manager with OP_PLAY_AUDIO. */
73 bool muteFromPlaybackRestricted = false;
Vlad Popa99ac9472022-07-25 15:42:50 +020074 /** Flag used when audio track was muted by client volume. */
75 bool muteFromClientVolume = false;
Vlad Popadc1ce4d2024-08-27 15:08:14 -070076 /** Flag used when volume is muted by volume shaper. */
Vlad Popa5ceac8f2022-08-02 15:46:39 +020077 bool muteFromVolumeShaper = false;
Vlad Popadc1ce4d2024-08-27 15:08:14 -070078 /** Flag used when volume is muted by port volume. */
79 bool muteFromPortVolume = false;
Vlad Popa5cb98562022-06-30 15:48:16 +020080
81 explicit operator int() const
82 {
83 int result = muteFromMasterMute * PLAYER_MUTE_MASTER;
84 result |= muteFromStreamVolume * PLAYER_MUTE_STREAM_VOLUME;
85 result |= muteFromStreamMuted * PLAYER_MUTE_STREAM_MUTED;
86 result |= muteFromPlaybackRestricted * PLAYER_MUTE_PLAYBACK_RESTRICTED;
Vlad Popa99ac9472022-07-25 15:42:50 +020087 result |= muteFromClientVolume * PLAYER_MUTE_CLIENT_VOLUME;
Vlad Popa5ceac8f2022-08-02 15:46:39 +020088 result |= muteFromVolumeShaper * PLAYER_MUTE_VOLUME_SHAPER;
Vlad Popadc1ce4d2024-08-27 15:08:14 -070089 result |= muteFromPortVolume * PLAYER_MUTE_PORT_VOLUME;
Vlad Popa5cb98562022-06-30 15:48:16 +020090 return result;
91 }
92
93 bool operator==(const mute_state_t& other) const
94 {
95 return static_cast<int>(*this) == static_cast<int>(other);
96 }
97};
98
Mikhail Naganovdecb6292019-04-10 16:49:02 -070099// must be kept in sync with definitions in AudioManager.java
100#define RECORD_RIID_INVALID -1
101
102typedef enum {
103 RECORDER_STATE_UNKNOWN = -1,
104 RECORDER_STATE_STARTED = 0,
105 RECORDER_STATE_STOPPED = 1,
106} recorder_state_t;
107
Jean-Michel Trivi0008a482016-12-26 15:58:24 -0800108}; // namespace android
109
110#endif // ANDROID_AUDIOMANAGER_H