blob: 203623dea712bb2004ece52f183a68f6d18812c9 [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
Atneya Naircb9ce7d2024-11-21 10:39:36 -080025// TODO (b/309532236) remove manual IAudioManager impl in favor of AIDL.
Jean-Michel Trivi63189322017-01-05 18:05:28 -080026typedef enum {
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080027 PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE = 11,
28 PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD = 12,
Jean-Michel Trivi10fed362017-05-25 15:17:39 -070029 PLAYER_TYPE_AAUDIO = 13,
30 PLAYER_TYPE_HW_SOURCE = 14,
31 PLAYER_TYPE_EXTERNAL_PROXY = 15,
Jean-Michel Trivi63189322017-01-05 18:05:28 -080032} player_type_t;
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080033
Jean-Michel Trivi63189322017-01-05 18:05:28 -080034typedef enum {
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080035 PLAYER_STATE_UNKNOWN = -1,
36 PLAYER_STATE_RELEASED = 0,
37 PLAYER_STATE_IDLE = 1,
38 PLAYER_STATE_STARTED = 2,
39 PLAYER_STATE_PAUSED = 3,
40 PLAYER_STATE_STOPPED = 4,
Oscar Azucenafae808f2020-12-22 20:40:07 +000041 PLAYER_UPDATE_DEVICE_ID = 5,
Vlad Popa459fc742022-06-10 00:07:27 +020042 PLAYER_UPDATE_PORT_ID = 6,
Vlad Popa5cb98562022-06-30 15:48:16 +020043 PLAYER_UPDATE_MUTED = 7,
Jean-Michel Trivi26e617d2022-12-21 03:42:34 +000044 PLAYER_UPDATE_FORMAT = 8,
Jean-Michel Trivi63189322017-01-05 18:05:28 -080045} player_state_t;
Jean-Michel Trivi0008a482016-12-26 15:58:24 -080046
Vlad Popa5cb98562022-06-30 15:48:16 +020047static constexpr char
Jean-Michel Trivi26e617d2022-12-21 03:42:34 +000048 kExtraPlayerEventSpatializedKey[] = "android.media.extra.PLAYER_EVENT_SPATIALIZED";
49static constexpr char
50 kExtraPlayerEventSampleRateKey[] = "android.media.extra.PLAYER_EVENT_SAMPLE_RATE";
51static constexpr char
52 kExtraPlayerEventChannelMaskKey[] = "android.media.extra.PLAYER_EVENT_CHANNEL_MASK";
53
54static constexpr char
Vlad Popa5cb98562022-06-30 15:48:16 +020055 kExtraPlayerEventMuteKey[] = "android.media.extra.PLAYER_EVENT_MUTE";
56enum {
57 PLAYER_MUTE_MASTER = (1 << 0),
58 PLAYER_MUTE_STREAM_VOLUME = (1 << 1),
59 PLAYER_MUTE_STREAM_MUTED = (1 << 2),
60 PLAYER_MUTE_PLAYBACK_RESTRICTED = (1 << 3),
Vlad Popa99ac9472022-07-25 15:42:50 +020061 PLAYER_MUTE_CLIENT_VOLUME = (1 << 4),
Vlad Popa5ceac8f2022-08-02 15:46:39 +020062 PLAYER_MUTE_VOLUME_SHAPER = (1 << 5),
Vlad Popadc1ce4d2024-08-27 15:08:14 -070063 PLAYER_MUTE_PORT_VOLUME = (1 << 6),
Atneya Naircb9ce7d2024-11-21 10:39:36 -080064 PLAYER_MUTE_OP_AUDIO_CONTROL = (1 << 7),
Vlad Popa5cb98562022-06-30 15:48:16 +020065};
66
67struct mute_state_t {
68 /** Flag used when the master volume is causing the mute state. */
69 bool muteFromMasterMute = false;
70 /** Flag used when the stream volume is causing the mute state. */
71 bool muteFromStreamVolume = false;
72 /** Flag used when the stream muted is causing the mute state. */
73 bool muteFromStreamMuted = false;
74 /** Flag used when playback is restricted by AppOps manager with OP_PLAY_AUDIO. */
75 bool muteFromPlaybackRestricted = false;
Vlad Popa99ac9472022-07-25 15:42:50 +020076 /** Flag used when audio track was muted by client volume. */
77 bool muteFromClientVolume = false;
Vlad Popadc1ce4d2024-08-27 15:08:14 -070078 /** Flag used when volume is muted by volume shaper. */
Vlad Popa5ceac8f2022-08-02 15:46:39 +020079 bool muteFromVolumeShaper = false;
Vlad Popadc1ce4d2024-08-27 15:08:14 -070080 /** Flag used when volume is muted by port volume. */
81 bool muteFromPortVolume = false;
Atneya Naircb9ce7d2024-11-21 10:39:36 -080082 /** Flag used when volume is muted by audio control op. */
83 bool muteFromOpAudioControl = false;
Vlad Popa5cb98562022-06-30 15:48:16 +020084
85 explicit operator int() const
86 {
87 int result = muteFromMasterMute * PLAYER_MUTE_MASTER;
88 result |= muteFromStreamVolume * PLAYER_MUTE_STREAM_VOLUME;
89 result |= muteFromStreamMuted * PLAYER_MUTE_STREAM_MUTED;
90 result |= muteFromPlaybackRestricted * PLAYER_MUTE_PLAYBACK_RESTRICTED;
Vlad Popa99ac9472022-07-25 15:42:50 +020091 result |= muteFromClientVolume * PLAYER_MUTE_CLIENT_VOLUME;
Vlad Popa5ceac8f2022-08-02 15:46:39 +020092 result |= muteFromVolumeShaper * PLAYER_MUTE_VOLUME_SHAPER;
Vlad Popadc1ce4d2024-08-27 15:08:14 -070093 result |= muteFromPortVolume * PLAYER_MUTE_PORT_VOLUME;
Atneya Naircb9ce7d2024-11-21 10:39:36 -080094 result |= muteFromOpAudioControl * PLAYER_MUTE_OP_AUDIO_CONTROL;
Vlad Popa5cb98562022-06-30 15:48:16 +020095 return result;
96 }
97
98 bool operator==(const mute_state_t& other) const
99 {
100 return static_cast<int>(*this) == static_cast<int>(other);
101 }
102};
103
Mikhail Naganovdecb6292019-04-10 16:49:02 -0700104// must be kept in sync with definitions in AudioManager.java
105#define RECORD_RIID_INVALID -1
106
107typedef enum {
108 RECORDER_STATE_UNKNOWN = -1,
109 RECORDER_STATE_STARTED = 0,
110 RECORDER_STATE_STOPPED = 1,
111} recorder_state_t;
112
Jean-Michel Trivi0008a482016-12-26 15:58:24 -0800113}; // namespace android
114
115#endif // ANDROID_AUDIOMANAGER_H