Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 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 |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 23 | #define PLAYER_PIID_INVALID -1 |
| 24 | |
Atneya Nair | cb9ce7d | 2024-11-21 10:39:36 -0800 | [diff] [blame] | 25 | // TODO (b/309532236) remove manual IAudioManager impl in favor of AIDL. |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 26 | typedef enum { |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 27 | PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE = 11, |
| 28 | PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD = 12, |
Jean-Michel Trivi | 10fed36 | 2017-05-25 15:17:39 -0700 | [diff] [blame] | 29 | PLAYER_TYPE_AAUDIO = 13, |
| 30 | PLAYER_TYPE_HW_SOURCE = 14, |
| 31 | PLAYER_TYPE_EXTERNAL_PROXY = 15, |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 32 | } player_type_t; |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 33 | |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 34 | typedef enum { |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 35 | 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 Azucena | fae808f | 2020-12-22 20:40:07 +0000 | [diff] [blame] | 41 | PLAYER_UPDATE_DEVICE_ID = 5, |
Vlad Popa | 459fc74 | 2022-06-10 00:07:27 +0200 | [diff] [blame] | 42 | PLAYER_UPDATE_PORT_ID = 6, |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 43 | PLAYER_UPDATE_MUTED = 7, |
Jean-Michel Trivi | 26e617d | 2022-12-21 03:42:34 +0000 | [diff] [blame] | 44 | PLAYER_UPDATE_FORMAT = 8, |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 45 | } player_state_t; |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 46 | |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 47 | static constexpr char |
Jean-Michel Trivi | 26e617d | 2022-12-21 03:42:34 +0000 | [diff] [blame] | 48 | kExtraPlayerEventSpatializedKey[] = "android.media.extra.PLAYER_EVENT_SPATIALIZED"; |
| 49 | static constexpr char |
| 50 | kExtraPlayerEventSampleRateKey[] = "android.media.extra.PLAYER_EVENT_SAMPLE_RATE"; |
| 51 | static constexpr char |
| 52 | kExtraPlayerEventChannelMaskKey[] = "android.media.extra.PLAYER_EVENT_CHANNEL_MASK"; |
| 53 | |
| 54 | static constexpr char |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 55 | kExtraPlayerEventMuteKey[] = "android.media.extra.PLAYER_EVENT_MUTE"; |
| 56 | enum { |
| 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 Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 61 | PLAYER_MUTE_CLIENT_VOLUME = (1 << 4), |
Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame] | 62 | PLAYER_MUTE_VOLUME_SHAPER = (1 << 5), |
Vlad Popa | dc1ce4d | 2024-08-27 15:08:14 -0700 | [diff] [blame] | 63 | PLAYER_MUTE_PORT_VOLUME = (1 << 6), |
Atneya Nair | cb9ce7d | 2024-11-21 10:39:36 -0800 | [diff] [blame] | 64 | PLAYER_MUTE_OP_AUDIO_CONTROL = (1 << 7), |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | struct 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 Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 76 | /** Flag used when audio track was muted by client volume. */ |
| 77 | bool muteFromClientVolume = false; |
Vlad Popa | dc1ce4d | 2024-08-27 15:08:14 -0700 | [diff] [blame] | 78 | /** Flag used when volume is muted by volume shaper. */ |
Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame] | 79 | bool muteFromVolumeShaper = false; |
Vlad Popa | dc1ce4d | 2024-08-27 15:08:14 -0700 | [diff] [blame] | 80 | /** Flag used when volume is muted by port volume. */ |
| 81 | bool muteFromPortVolume = false; |
Atneya Nair | cb9ce7d | 2024-11-21 10:39:36 -0800 | [diff] [blame] | 82 | /** Flag used when volume is muted by audio control op. */ |
| 83 | bool muteFromOpAudioControl = false; |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 84 | |
| 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 Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 91 | result |= muteFromClientVolume * PLAYER_MUTE_CLIENT_VOLUME; |
Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame] | 92 | result |= muteFromVolumeShaper * PLAYER_MUTE_VOLUME_SHAPER; |
Vlad Popa | dc1ce4d | 2024-08-27 15:08:14 -0700 | [diff] [blame] | 93 | result |= muteFromPortVolume * PLAYER_MUTE_PORT_VOLUME; |
Atneya Nair | cb9ce7d | 2024-11-21 10:39:36 -0800 | [diff] [blame] | 94 | result |= muteFromOpAudioControl * PLAYER_MUTE_OP_AUDIO_CONTROL; |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 95 | 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 Naganov | decb629 | 2019-04-10 16:49:02 -0700 | [diff] [blame] | 104 | // must be kept in sync with definitions in AudioManager.java |
| 105 | #define RECORD_RIID_INVALID -1 |
| 106 | |
| 107 | typedef enum { |
| 108 | RECORDER_STATE_UNKNOWN = -1, |
| 109 | RECORDER_STATE_STARTED = 0, |
| 110 | RECORDER_STATE_STOPPED = 1, |
| 111 | } recorder_state_t; |
| 112 | |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 113 | }; // namespace android |
| 114 | |
| 115 | #endif // ANDROID_AUDIOMANAGER_H |