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 | |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 25 | typedef enum { |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 26 | PLAYER_TYPE_SLES_AUDIOPLAYER_BUFFERQUEUE = 11, |
| 27 | PLAYER_TYPE_SLES_AUDIOPLAYER_URI_FD = 12, |
Jean-Michel Trivi | 10fed36 | 2017-05-25 15:17:39 -0700 | [diff] [blame] | 28 | PLAYER_TYPE_AAUDIO = 13, |
| 29 | PLAYER_TYPE_HW_SOURCE = 14, |
| 30 | PLAYER_TYPE_EXTERNAL_PROXY = 15, |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 31 | } player_type_t; |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 32 | |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 33 | typedef enum { |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 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, |
Oscar Azucena | fae808f | 2020-12-22 20:40:07 +0000 | [diff] [blame] | 40 | PLAYER_UPDATE_DEVICE_ID = 5, |
Vlad Popa | 459fc74 | 2022-06-10 00:07:27 +0200 | [diff] [blame] | 41 | PLAYER_UPDATE_PORT_ID = 6, |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 42 | PLAYER_UPDATE_MUTED = 7, |
Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 43 | } player_state_t; |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 44 | |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 45 | static constexpr char |
| 46 | kExtraPlayerEventMuteKey[] = "android.media.extra.PLAYER_EVENT_MUTE"; |
| 47 | enum { |
| 48 | PLAYER_MUTE_MASTER = (1 << 0), |
| 49 | PLAYER_MUTE_STREAM_VOLUME = (1 << 1), |
| 50 | PLAYER_MUTE_STREAM_MUTED = (1 << 2), |
| 51 | PLAYER_MUTE_PLAYBACK_RESTRICTED = (1 << 3), |
Vlad Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 52 | PLAYER_MUTE_CLIENT_VOLUME = (1 << 4), |
Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame^] | 53 | PLAYER_MUTE_VOLUME_SHAPER = (1 << 5), |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct mute_state_t { |
| 57 | /** Flag used when the master volume is causing the mute state. */ |
| 58 | bool muteFromMasterMute = false; |
| 59 | /** Flag used when the stream volume is causing the mute state. */ |
| 60 | bool muteFromStreamVolume = false; |
| 61 | /** Flag used when the stream muted is causing the mute state. */ |
| 62 | bool muteFromStreamMuted = false; |
| 63 | /** Flag used when playback is restricted by AppOps manager with OP_PLAY_AUDIO. */ |
| 64 | bool muteFromPlaybackRestricted = false; |
Vlad Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 65 | /** Flag used when audio track was muted by client volume. */ |
| 66 | bool muteFromClientVolume = false; |
Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame^] | 67 | /** Flag used when volume is muted by volume shaper. */ |
| 68 | bool muteFromVolumeShaper = false; |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 69 | |
| 70 | explicit operator int() const |
| 71 | { |
| 72 | int result = muteFromMasterMute * PLAYER_MUTE_MASTER; |
| 73 | result |= muteFromStreamVolume * PLAYER_MUTE_STREAM_VOLUME; |
| 74 | result |= muteFromStreamMuted * PLAYER_MUTE_STREAM_MUTED; |
| 75 | result |= muteFromPlaybackRestricted * PLAYER_MUTE_PLAYBACK_RESTRICTED; |
Vlad Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 76 | result |= muteFromClientVolume * PLAYER_MUTE_CLIENT_VOLUME; |
Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame^] | 77 | result |= muteFromVolumeShaper * PLAYER_MUTE_VOLUME_SHAPER; |
Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 78 | return result; |
| 79 | } |
| 80 | |
| 81 | bool operator==(const mute_state_t& other) const |
| 82 | { |
| 83 | return static_cast<int>(*this) == static_cast<int>(other); |
| 84 | } |
| 85 | }; |
| 86 | |
Mikhail Naganov | decb629 | 2019-04-10 16:49:02 -0700 | [diff] [blame] | 87 | // must be kept in sync with definitions in AudioManager.java |
| 88 | #define RECORD_RIID_INVALID -1 |
| 89 | |
| 90 | typedef enum { |
| 91 | RECORDER_STATE_UNKNOWN = -1, |
| 92 | RECORDER_STATE_STARTED = 0, |
| 93 | RECORDER_STATE_STOPPED = 1, |
| 94 | } recorder_state_t; |
| 95 | |
Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 96 | }; // namespace android |
| 97 | |
| 98 | #endif // ANDROID_AUDIOMANAGER_H |