Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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_IAUDIOPOLICYSERVICE_H |
| 18 | #define ANDROID_IAUDIOPOLICYSERVICE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <unistd.h> |
| 23 | |
| 24 | #include <utils/RefBase.h> |
| 25 | #include <utils/Errors.h> |
| 26 | #include <binder/IInterface.h> |
| 27 | #include <media/AudioSystem.h> |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame^] | 28 | #include <media/AudioPolicy.h> |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 29 | #include <media/IAudioPolicyServiceClient.h> |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 30 | |
Dima Zavin | 7394a4f | 2011-06-13 18:16:26 -0700 | [diff] [blame] | 31 | #include <system/audio_policy.h> |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 32 | |
| 33 | namespace android { |
| 34 | |
| 35 | // ---------------------------------------------------------------------------- |
| 36 | |
| 37 | class IAudioPolicyService : public IInterface |
| 38 | { |
| 39 | public: |
| 40 | DECLARE_META_INTERFACE(AudioPolicyService); |
| 41 | |
| 42 | // |
| 43 | // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions) |
| 44 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 45 | virtual status_t setDeviceConnectionState(audio_devices_t device, |
| 46 | audio_policy_dev_state_t state, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 47 | const char *device_address) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 48 | virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 49 | const char *device_address) = 0; |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 50 | virtual status_t setPhoneState(audio_mode_t state) = 0; |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 51 | virtual status_t setForceUse(audio_policy_force_use_t usage, |
| 52 | audio_policy_forced_cfg_t config) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 53 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0; |
| 54 | virtual audio_io_handle_t getOutput(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 55 | uint32_t samplingRate = 0, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 56 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 57 | audio_channel_mask_t channelMask = 0, |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 58 | audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, |
| 59 | const audio_offload_info_t *offloadInfo = NULL) = 0; |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 60 | virtual status_t getOutputForAttr(const audio_attributes_t *attr, |
| 61 | audio_io_handle_t *output, |
| 62 | audio_session_t session, |
| 63 | audio_stream_type_t *stream, |
| 64 | uint32_t samplingRate = 0, |
| 65 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
| 66 | audio_channel_mask_t channelMask = 0, |
| 67 | audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, |
| 68 | const audio_offload_info_t *offloadInfo = NULL) = 0; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 69 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 70 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 71 | audio_session_t session) = 0; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 72 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 73 | audio_stream_type_t stream, |
Eric Laurent | e83b55d | 2014-11-14 10:06:21 -0800 | [diff] [blame] | 74 | audio_session_t session) = 0; |
| 75 | virtual void releaseOutput(audio_io_handle_t output, |
| 76 | audio_stream_type_t stream, |
| 77 | audio_session_t session) = 0; |
Eric Laurent | caf7f48 | 2014-11-25 17:50:47 -0800 | [diff] [blame] | 78 | virtual status_t getInputForAttr(const audio_attributes_t *attr, |
| 79 | audio_io_handle_t *input, |
| 80 | audio_session_t session, |
| 81 | uint32_t samplingRate, |
| 82 | audio_format_t format, |
| 83 | audio_channel_mask_t channelMask, |
| 84 | audio_input_flags_t flags) = 0; |
Eric Laurent | 4dc6806 | 2014-07-28 17:26:49 -0700 | [diff] [blame] | 85 | virtual status_t startInput(audio_io_handle_t input, |
| 86 | audio_session_t session) = 0; |
| 87 | virtual status_t stopInput(audio_io_handle_t input, |
| 88 | audio_session_t session) = 0; |
| 89 | virtual void releaseInput(audio_io_handle_t input, |
| 90 | audio_session_t session) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 91 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 92 | int indexMin, |
| 93 | int indexMax) = 0; |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 94 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 95 | int index, |
| 96 | audio_devices_t device) = 0; |
| 97 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 98 | int *index, |
| 99 | audio_devices_t device) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 100 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0; |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 101 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0; |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 102 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0; |
| 103 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 104 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 105 | uint32_t strategy, |
| 106 | int session, |
| 107 | int id) = 0; |
| 108 | virtual status_t unregisterEffect(int id) = 0; |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 109 | virtual status_t setEffectEnabled(int id, bool enabled) = 0; |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 110 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0; |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 111 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) |
| 112 | const = 0; |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 113 | virtual bool isSourceActive(audio_source_t source) const = 0; |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 114 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 115 | effect_descriptor_t *descriptors, |
| 116 | uint32_t *count) = 0; |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 117 | // Check if offload is possible for given format, stream type, sample rate, |
| 118 | // bit rate, duration, video and streaming or offload property is enabled |
| 119 | virtual bool isOffloadSupported(const audio_offload_info_t& info) = 0; |
Eric Laurent | 203b1a1 | 2014-04-01 10:34:16 -0700 | [diff] [blame] | 120 | |
| 121 | /* List available audio ports and their attributes */ |
| 122 | virtual status_t listAudioPorts(audio_port_role_t role, |
| 123 | audio_port_type_t type, |
| 124 | unsigned int *num_ports, |
| 125 | struct audio_port *ports, |
| 126 | unsigned int *generation) = 0; |
| 127 | |
| 128 | /* Get attributes for a given audio port */ |
| 129 | virtual status_t getAudioPort(struct audio_port *port) = 0; |
| 130 | |
| 131 | /* Create an audio patch between several source and sink ports */ |
| 132 | virtual status_t createAudioPatch(const struct audio_patch *patch, |
| 133 | audio_patch_handle_t *handle) = 0; |
| 134 | |
| 135 | /* Release an audio patch */ |
| 136 | virtual status_t releaseAudioPatch(audio_patch_handle_t handle) = 0; |
| 137 | |
| 138 | /* List existing audio patches */ |
| 139 | virtual status_t listAudioPatches(unsigned int *num_patches, |
| 140 | struct audio_patch *patches, |
| 141 | unsigned int *generation) = 0; |
| 142 | /* Set audio port configuration */ |
| 143 | virtual status_t setAudioPortConfig(const struct audio_port_config *config) = 0; |
| 144 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 145 | virtual void registerClient(const sp<IAudioPolicyServiceClient>& client) = 0; |
Eric Laurent | df3dc7e | 2014-07-27 18:39:40 -0700 | [diff] [blame] | 146 | |
| 147 | virtual status_t acquireSoundTriggerSession(audio_session_t *session, |
| 148 | audio_io_handle_t *ioHandle, |
| 149 | audio_devices_t *device) = 0; |
| 150 | |
| 151 | virtual status_t releaseSoundTriggerSession(audio_session_t session) = 0; |
Eric Laurent | bb6c9a0 | 2014-09-25 14:11:47 -0700 | [diff] [blame] | 152 | |
| 153 | virtual audio_mode_t getPhoneState() = 0; |
Eric Laurent | baac183 | 2014-12-01 17:52:59 -0800 | [diff] [blame^] | 154 | |
| 155 | virtual status_t registerPolicyMixes(Vector<AudioMix> mixes, bool registration) = 0; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | |
| 159 | // ---------------------------------------------------------------------------- |
| 160 | |
| 161 | class BnAudioPolicyService : public BnInterface<IAudioPolicyService> |
| 162 | { |
| 163 | public: |
| 164 | virtual status_t onTransact( uint32_t code, |
| 165 | const Parcel& data, |
| 166 | Parcel* reply, |
| 167 | uint32_t flags = 0); |
| 168 | }; |
| 169 | |
| 170 | // ---------------------------------------------------------------------------- |
| 171 | |
| 172 | }; // namespace android |
| 173 | |
| 174 | #endif // ANDROID_IAUDIOPOLICYSERVICE_H |