| 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 | 26e617d | 2022-12-21 03:42:34 +0000 | [diff] [blame] | 43 | PLAYER_UPDATE_FORMAT = 8, | 
| Jean-Michel Trivi | 6318932 | 2017-01-05 18:05:28 -0800 | [diff] [blame] | 44 | } player_state_t; | 
| Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 45 |  | 
| Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 46 | static constexpr char | 
| Jean-Michel Trivi | 26e617d | 2022-12-21 03:42:34 +0000 | [diff] [blame] | 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 | 
| Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 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), | 
| Vlad Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 60 | PLAYER_MUTE_CLIENT_VOLUME = (1 << 4), | 
| Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame] | 61 | PLAYER_MUTE_VOLUME_SHAPER = (1 << 5), | 
| Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 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; | 
| Vlad Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 73 | /** Flag used when audio track was muted by client volume. */ | 
|  | 74 | bool muteFromClientVolume = false; | 
| Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame] | 75 | /** Flag used when volume is muted by volume shaper. */ | 
|  | 76 | bool muteFromVolumeShaper = false; | 
| Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 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; | 
| Vlad Popa | 99ac947 | 2022-07-25 15:42:50 +0200 | [diff] [blame] | 84 | result |= muteFromClientVolume * PLAYER_MUTE_CLIENT_VOLUME; | 
| Vlad Popa | 5ceac8f | 2022-08-02 15:46:39 +0200 | [diff] [blame] | 85 | result |= muteFromVolumeShaper * PLAYER_MUTE_VOLUME_SHAPER; | 
| Vlad Popa | 5cb9856 | 2022-06-30 15:48:16 +0200 | [diff] [blame] | 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 |  | 
| Mikhail Naganov | decb629 | 2019-04-10 16:49:02 -0700 | [diff] [blame] | 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 |  | 
| Jean-Michel Trivi | 0008a48 | 2016-12-26 15:58:24 -0800 | [diff] [blame] | 104 | }; // namespace android | 
|  | 105 |  | 
|  | 106 | #endif // ANDROID_AUDIOMANAGER_H |