François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | #pragma once |
| 18 | |
| 19 | #include <AudioPolicyManagerObserver.h> |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 20 | #include <media/AudioProductStrategy.h> |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 21 | #include <media/AudioVolumeGroup.h> |
Eric Laurent | f5aa58d | 2019-02-22 18:20:11 -0800 | [diff] [blame] | 22 | #include <IVolumeCurves.h> |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 23 | #include <policy.h> |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 24 | #include <Volume.h> |
| 25 | #include <HwModule.h> |
| 26 | #include <DeviceDescriptor.h> |
| 27 | #include <system/audio.h> |
| 28 | #include <system/audio_policy.h> |
| 29 | #include <utils/Errors.h> |
| 30 | #include <utils/Vector.h> |
| 31 | |
| 32 | namespace android { |
| 33 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 34 | using DeviceStrategyMap = std::map<product_strategy_t, DeviceVector>; |
| 35 | using StrategyVector = std::vector<product_strategy_t>; |
François Gaffie | 251c7f0 | 2018-11-07 10:41:08 +0100 | [diff] [blame] | 36 | using VolumeGroupVector = std::vector<volume_group_t>; |
Jiabin Huang | 3b98d32 | 2020-09-03 17:54:16 +0000 | [diff] [blame] | 37 | using CapturePresetDevicesRoleMap = |
| 38 | std::map<audio_source_t, std::map<device_role_t, AudioDeviceTypeAddrVector>>; |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 39 | |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 40 | /** |
| 41 | * This interface is dedicated to the policy manager that a Policy Engine shall implement. |
| 42 | */ |
Mikhail Naganov | 4783555 | 2019-05-14 10:32:51 -0700 | [diff] [blame] | 43 | class EngineInterface |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 44 | { |
| 45 | public: |
| 46 | /** |
| 47 | * Checks if the engine was correctly initialized. |
| 48 | * |
| 49 | * @return NO_ERROR if initialization has been done correctly, error code otherwise.. |
| 50 | */ |
| 51 | virtual status_t initCheck() = 0; |
| 52 | |
| 53 | /** |
| 54 | * Sets the Manager observer that allows the engine to retrieve information on collection |
| 55 | * of devices, streams, HwModules, ... |
| 56 | * |
| 57 | * @param[in] observer handle on the manager. |
| 58 | */ |
| 59 | virtual void setObserver(AudioPolicyManagerObserver *observer) = 0; |
| 60 | |
| 61 | /** |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 62 | * Set the Telephony Mode. |
| 63 | * |
| 64 | * @param[in] mode: Android Phone state (normal, ringtone, csv, in communication) |
| 65 | * |
| 66 | * @return NO_ERROR if Telephony Mode set correctly, error code otherwise. |
| 67 | */ |
| 68 | virtual status_t setPhoneState(audio_mode_t mode) = 0; |
| 69 | |
| 70 | /** |
| 71 | * Get the telephony Mode |
| 72 | * |
| 73 | * @return the current telephony mode |
| 74 | */ |
| 75 | virtual audio_mode_t getPhoneState() const = 0; |
| 76 | |
| 77 | /** |
| 78 | * Set Force Use config for a given usage. |
| 79 | * |
| 80 | * @param[in] usage for which a configuration shall be forced. |
| 81 | * @param[in] config wished to be forced for the given usage. |
| 82 | * |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 83 | * @return NO_ERROR if the Force Use config was set correctly, error code otherwise (e.g. config |
| 84 | * not allowed a given usage...) |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 85 | */ |
| 86 | virtual status_t setForceUse(audio_policy_force_use_t usage, |
| 87 | audio_policy_forced_cfg_t config) = 0; |
| 88 | |
| 89 | /** |
| 90 | * Get Force Use config for a given usage. |
| 91 | * |
| 92 | * @param[in] usage for which a configuration shall be forced. |
| 93 | * |
| 94 | * @return config wished to be forced for the given usage. |
| 95 | */ |
| 96 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) const = 0; |
| 97 | |
| 98 | /** |
| 99 | * Set the connection state of device(s). |
| 100 | * |
| 101 | * @param[in] devDesc for which the state has changed. |
| 102 | * @param[in] state of availability of this(these) device(s). |
| 103 | * |
| 104 | * @return NO_ERROR if devices criterion updated correctly, error code otherwise. |
| 105 | */ |
| 106 | virtual status_t setDeviceConnectionState(const android::sp<android::DeviceDescriptor> devDesc, |
| 107 | audio_policy_dev_state_t state) = 0; |
| 108 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 109 | /** |
| 110 | * Get the strategy selected for a given audio attributes. |
| 111 | * |
| 112 | * @param[in] audio attributes to get the selected @product_strategy_t followed by. |
| 113 | * |
| 114 | * @return @product_strategy_t to be followed. |
| 115 | */ |
| 116 | virtual product_strategy_t getProductStrategyForAttributes( |
| 117 | const audio_attributes_t &attr) const = 0; |
| 118 | |
| 119 | /** |
| 120 | * @brief getOutputDevicesForAttributes retrieves the devices to be used for given |
| 121 | * audio attributes. |
| 122 | * @param attributes of the output requesting Device(s) selection |
| 123 | * @param preferedDevice valid reference if a prefered device is requested, nullptr otherwise. |
| 124 | * @param fromCache if true, the device is returned from internal cache, |
| 125 | * otherwise it is determined by current state (device connected,phone state, |
| 126 | * force use, a2dp output...) |
| 127 | * @return vector of selected device descriptors. |
| 128 | * Appropriate device for streams handled by the specified audio attributes according |
| 129 | * to current phone state, forced states, connected devices... |
| 130 | * if fromCache is true, the device is returned from internal cache, |
| 131 | * otherwise it is determined by current state (device connected,phone state, force use, |
| 132 | * a2dp output...) |
| 133 | * This allows to: |
| 134 | * 1 speed up process when the state is stable (when starting or stopping an output) |
| 135 | * 2 access to either current device selection (fromCache == true) or |
| 136 | * "future" device selection (fromCache == false) when called from a context |
| 137 | * where conditions are changing (setDeviceConnectionState(), setPhoneState()...) AND |
| 138 | * before manager updates its outputs. |
| 139 | */ |
| 140 | virtual DeviceVector getOutputDevicesForAttributes( |
| 141 | const audio_attributes_t &attributes, |
| 142 | const sp<DeviceDescriptor> &preferedDevice = nullptr, |
| 143 | bool fromCache = false) const = 0; |
| 144 | |
| 145 | /** |
| 146 | * @brief getOutputDevicesForStream Legacy function retrieving devices from a stream type. |
| 147 | * @param stream type of the output requesting Device(s) selection |
| 148 | * @param fromCache if true, the device is returned from internal cache, |
| 149 | * otherwise it is determined by current state (device connected,phone state, |
| 150 | * force use, a2dp output...) |
| 151 | * @return appropriate device for streams handled by the specified audio attributes according |
| 152 | * to current phone state, forced states, connected devices... |
| 153 | * if fromCache is true, the device is returned from internal cache, |
| 154 | * otherwise it is determined by current state (device connected,phone state, force use, |
| 155 | * a2dp output...) |
| 156 | * This allows to: |
| 157 | * 1 speed up process when the state is stable (when starting or stopping an output) |
| 158 | * 2 access to either current device selection (fromCache == true) or |
| 159 | * "future" device selection (fromCache == false) when called from a context |
| 160 | * where conditions are changing (setDeviceConnectionState(), setPhoneState()...) AND |
| 161 | * before manager updates its outputs. |
| 162 | */ |
| 163 | virtual DeviceVector getOutputDevicesForStream(audio_stream_type_t stream, |
| 164 | bool fromCache = false) const = 0; |
| 165 | |
| 166 | /** |
| 167 | * Get the input device selected for given audio attributes. |
| 168 | * |
| 169 | * @param[in] attr audio attributes to consider |
| 170 | * @param[out] mix to be used if a mix has been installed for the given audio attributes. |
| 171 | * @return selected input device for the audio attributes, may be null if error. |
| 172 | */ |
| 173 | virtual sp<DeviceDescriptor> getInputDeviceForAttributes( |
Mikhail Naganov | bfac583 | 2019-03-05 16:55:28 -0800 | [diff] [blame] | 174 | const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const = 0; |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 175 | |
| 176 | /** |
| 177 | * Get the legacy stream type for a given audio attributes. |
| 178 | * |
| 179 | * @param[in] audio attributes to get the associated audio_stream_type_t. |
| 180 | * |
| 181 | * @return audio_stream_type_t associated to the attributes. |
| 182 | */ |
| 183 | virtual audio_stream_type_t getStreamTypeForAttributes( |
| 184 | const audio_attributes_t &attr) const = 0; |
| 185 | |
| 186 | /** |
| 187 | * @brief getAttributesForStream get the audio attributes from legacy stream type |
François Gaffie | 251c7f0 | 2018-11-07 10:41:08 +0100 | [diff] [blame] | 188 | * Attributes returned might only be used to check upon routing decision, not volume decisions. |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 189 | * @param stream to consider |
| 190 | * @return audio attributes matching the legacy stream type |
| 191 | */ |
| 192 | virtual audio_attributes_t getAttributesForStreamType(audio_stream_type_t stream) const = 0; |
| 193 | |
| 194 | /** |
| 195 | * @brief getStreamTypesForProductStrategy retrieves the list of legacy stream type following |
| 196 | * the given product strategy |
| 197 | * @param ps product strategy to consider |
| 198 | * @return associated legacy Stream Types vector of the given product strategy |
| 199 | */ |
| 200 | virtual StreamTypeVector getStreamTypesForProductStrategy(product_strategy_t ps) const = 0; |
| 201 | |
| 202 | /** |
| 203 | * @brief getAllAttributesForProductStrategy retrieves all the attributes following the given |
| 204 | * product strategy. Any attributes that "matches" with this one will follow the product |
| 205 | * strategy. |
| 206 | * "matching" means the usage shall match if reference attributes has a defined usage, AND |
| 207 | * content type shall match if reference attributes has a defined content type AND |
| 208 | * flags shall match if reference attributes has defined flags AND |
| 209 | * tags shall match if reference attributes has defined tags. |
| 210 | * @param ps product strategy to consider |
| 211 | * @return vector of product strategy ids, empty if unknown strategy. |
| 212 | */ |
| 213 | virtual AttributesVector getAllAttributesForProductStrategy(product_strategy_t ps) const = 0; |
| 214 | |
| 215 | /** |
| 216 | * @brief getOrderedAudioProductStrategies |
| 217 | * @return priority ordered product strategies to help the AudioPolicyManager evaluating the |
| 218 | * device selection per output according to the prioritized strategies. |
| 219 | */ |
| 220 | virtual StrategyVector getOrderedProductStrategies() const = 0; |
| 221 | |
| 222 | /** |
| 223 | * @brief updateDeviceSelectionCache. Device selection for AudioAttribute / Streams is cached |
| 224 | * in the engine in order to speed up process when the audio system is stable. |
| 225 | * When a device is connected, the android mode is changed, engine is notified and can update |
| 226 | * the cache. |
| 227 | * When starting / stopping an output with a stream that can affect notification, the engine |
| 228 | * needs to update the cache upon this function call. |
| 229 | */ |
| 230 | virtual void updateDeviceSelectionCache() = 0; |
| 231 | |
François Gaffie | d0ba9ed | 2018-11-05 11:50:42 +0100 | [diff] [blame] | 232 | /** |
| 233 | * @brief listAudioProductStrategies. Introspection API to retrieve a collection of |
| 234 | * AudioProductStrategyVector that allows to build AudioAttributes according to a |
| 235 | * product_strategy which is just an index. It has also a human readable name to help the |
| 236 | * Car/Oem/AudioManager identiying the use case. |
| 237 | * @param strategies collection. |
| 238 | * @return OK if the list has been retrieved, error code otherwise |
| 239 | */ |
| 240 | virtual status_t listAudioProductStrategies(AudioProductStrategyVector &strategies) const = 0; |
| 241 | |
Eric Laurent | f5aa58d | 2019-02-22 18:20:11 -0800 | [diff] [blame] | 242 | /** |
| 243 | * @brief getVolumeCurvesForAttributes retrieves the Volume Curves interface for the |
| 244 | * requested Audio Attributes. |
| 245 | * @param attr to be considered |
| 246 | * @return IVolumeCurves interface pointer if found, nullptr otherwise |
| 247 | */ |
François Gaffie | 251c7f0 | 2018-11-07 10:41:08 +0100 | [diff] [blame] | 248 | virtual IVolumeCurves *getVolumeCurvesForAttributes(const audio_attributes_t &attr) const = 0; |
Eric Laurent | f5aa58d | 2019-02-22 18:20:11 -0800 | [diff] [blame] | 249 | |
| 250 | /** |
| 251 | * @brief getVolumeCurvesForStreamType retrieves the Volume Curves interface for the stream |
| 252 | * @param stream to be considered |
| 253 | * @return IVolumeCurves interface pointer if found, nullptr otherwise |
| 254 | */ |
François Gaffie | 251c7f0 | 2018-11-07 10:41:08 +0100 | [diff] [blame] | 255 | virtual IVolumeCurves *getVolumeCurvesForStreamType(audio_stream_type_t stream) const = 0; |
| 256 | |
| 257 | /** |
| 258 | * @brief getVolumeCurvesForVolumeGroup retrieves the Volume Curves interface for volume group |
| 259 | * @param group to be considered |
| 260 | * @return IVolumeCurves interface pointer if found, nullptr otherwise |
| 261 | */ |
| 262 | virtual IVolumeCurves *getVolumeCurvesForVolumeGroup(volume_group_t group) const = 0; |
| 263 | |
| 264 | /** |
| 265 | * @brief getVolumeGroups retrieves the collection of volume groups. |
| 266 | * @return vector of volume groups |
| 267 | */ |
| 268 | virtual VolumeGroupVector getVolumeGroups() const = 0; |
| 269 | |
| 270 | /** |
| 271 | * @brief getVolumeGroupForAttributes gets the appropriate volume group to be used for a given |
| 272 | * Audio Attributes. |
| 273 | * @param attr to be considered |
| 274 | * @return volume group associated to the given audio attributes, default group if none |
| 275 | * applicable, VOLUME_GROUP_NONE if no default group defined. |
| 276 | */ |
| 277 | virtual volume_group_t getVolumeGroupForAttributes(const audio_attributes_t &attr) const = 0; |
| 278 | |
| 279 | /** |
| 280 | * @brief getVolumeGroupForStreamType gets the appropriate volume group to be used for a given |
| 281 | * legacy stream type |
| 282 | * @param stream type to be considered |
| 283 | * @return volume group associated to the given stream type, default group if none applicable, |
| 284 | * VOLUME_GROUP_NONE if no default group defined. |
| 285 | */ |
| 286 | virtual volume_group_t getVolumeGroupForStreamType(audio_stream_type_t stream) const = 0; |
| 287 | |
François Gaffie | 4b2018b | 2018-11-07 11:18:59 +0100 | [diff] [blame] | 288 | /** |
| 289 | * @brief listAudioVolumeGroups introspection API to get the Audio Volume Groups, aka |
| 290 | * former stream aliases in Audio Service, defining volume curves attached to one or more |
| 291 | * Audio Attributes. |
| 292 | * @param groups |
| 293 | * @return NO_ERROR if the volume groups were retrieved successfully, error code otherwise |
| 294 | */ |
| 295 | virtual status_t listAudioVolumeGroups(AudioVolumeGroupVector &groups) const = 0; |
| 296 | |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 297 | /** |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 298 | * @brief setDevicesRoleForStrategy sets devices role for a strategy when available. To remove |
| 299 | * devices role, removeDevicesRoleForStrategy must be called. When devices role is set |
| 300 | * successfully, previously set devices for the same role and strategy will be removed. |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 301 | * @param strategy the audio strategy whose routing will be affected |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 302 | * @param role the role of the devices for the strategy. All device roles are defined at |
| 303 | * system/media/audio/include/system/audio_policy.h. DEVICE_ROLE_NONE is invalid |
| 304 | * for setting. |
| 305 | * @param devices the audio devices to be set |
| 306 | * @return BAD_VALUE if the strategy or role is invalid, |
| 307 | * or NO_ERROR if the role of the devices for strategy was set |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 308 | */ |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 309 | virtual status_t setDevicesRoleForStrategy(product_strategy_t strategy, device_role_t role, |
| 310 | const AudioDeviceTypeAddrVector &devices) = 0; |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 311 | |
| 312 | /** |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 313 | * @brief removeDevicesRoleForStrategy removes the role of device(s) previously set |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 314 | * for the given strategy |
| 315 | * @param strategy the audio strategy whose routing will be affected |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 316 | * @param role the role of the devices for strategy |
| 317 | * @return BAD_VALUE if the strategy or role is invalid, |
| 318 | * or NO_ERROR if the devices for this role was removed |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 319 | */ |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 320 | virtual status_t removeDevicesRoleForStrategy(product_strategy_t strategy, |
| 321 | device_role_t role) = 0; |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 322 | |
| 323 | /** |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 324 | * @brief getDevicesForRoleAndStrategy queries which devices have the specified role for the |
| 325 | * specified strategy |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 326 | * @param strategy the strategy to query |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 327 | * @param role the role of the devices to query |
| 328 | * @param devices returns list of devices with matching role for the specified strategy. |
| 329 | * DEVICE_ROLE_NONE is invalid as input. |
| 330 | * @return BAD_VALUE if the strategy or role is invalid, |
| 331 | * or NAME_NOT_FOUND if no device for the role and strategy was set |
| 332 | * or NO_ERROR if the devices parameter contains a list of devices |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 333 | */ |
jiabin | 0a48893 | 2020-08-07 17:32:40 -0700 | [diff] [blame] | 334 | virtual status_t getDevicesForRoleAndStrategy(product_strategy_t strategy, device_role_t role, |
| 335 | AudioDeviceTypeAddrVector &devices) const = 0; |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 336 | |
Jiabin Huang | 3b98d32 | 2020-09-03 17:54:16 +0000 | [diff] [blame] | 337 | /** |
| 338 | * @brief setDevicesRoleForCapturePreset sets devices role for a capture preset when available. |
| 339 | * To remove devices role, removeDevicesRoleForCapturePreset must be called. Calling |
| 340 | * clearDevicesRoleForCapturePreset will remove all devices as role. When devices role is set |
| 341 | * successfully, previously set devices for the same role and capture preset will be removed. |
| 342 | * @param audioSource the audio capture preset whose routing will be affected |
| 343 | * @param role the role of the devices for the capture preset. All device roles are defined at |
| 344 | * system/media/audio/include/system/audio_policy.h. DEVICE_ROLE_NONE is invalid |
| 345 | * for setting. |
| 346 | * @param devices the audio devices to be set |
| 347 | * @return BAD_VALUE if the capture preset or role is invalid, |
| 348 | * or NO_ERROR if the role of the devices for capture preset was set |
| 349 | */ |
| 350 | virtual status_t setDevicesRoleForCapturePreset(audio_source_t audioSource, device_role_t role, |
| 351 | const AudioDeviceTypeAddrVector &devices) = 0; |
| 352 | |
| 353 | /** |
| 354 | * @brief addDevicesRoleForCapturePreset adds devices role for a capture preset when available. |
| 355 | * To remove devices role, removeDevicesRoleForCapturePreset must be called. Calling |
| 356 | * clearDevicesRoleForCapturePreset will remove all devices as role. |
| 357 | * @param audioSource the audio capture preset whose routing will be affected |
| 358 | * @param role the role of the devices for the capture preset. All device roles are defined at |
| 359 | * system/media/audio/include/system/audio_policy.h. DEVICE_ROLE_NONE is invalid |
| 360 | * for setting. |
| 361 | * @param devices the audio devices to be added |
| 362 | * @return BAD_VALUE if the capture preset or role is invalid, |
| 363 | * or NO_ERROR if the role of the devices for capture preset was added |
| 364 | */ |
| 365 | virtual status_t addDevicesRoleForCapturePreset(audio_source_t audioSource, device_role_t role, |
| 366 | const AudioDeviceTypeAddrVector &devices) = 0; |
| 367 | |
| 368 | /** |
| 369 | * @brief removeDevicesRoleForCapturePreset removes the role of device(s) previously set |
| 370 | * for the given capture preset |
| 371 | * @param audioSource the audio capture preset whose routing will be affected |
| 372 | * @param role the role of the devices for the capture preset |
| 373 | * @param devices the devices to be removed |
| 374 | * @return BAD_VALUE if 1) the capture preset is invalid, 2) role is invalid or 3) the list of |
| 375 | * devices to be removed are not all present as role for a capture preset |
| 376 | * or NO_ERROR if the devices for this role was removed |
| 377 | */ |
| 378 | virtual status_t removeDevicesRoleForCapturePreset(audio_source_t audioSource, |
| 379 | device_role_t role, const AudioDeviceTypeAddrVector& devices) = 0; |
| 380 | |
| 381 | /** |
| 382 | * @brief clearDevicesRoleForCapturePreset removes the role of all device(s) previously set |
| 383 | * for the given capture preset |
| 384 | * @param audioSource the audio capture preset whose routing will be affected |
| 385 | * @param role the role of the devices for the capture preset |
| 386 | * @return BAD_VALUE if the capture preset or role is invalid, |
| 387 | * or NO_ERROR if the devices for this role was removed |
| 388 | */ |
| 389 | virtual status_t clearDevicesRoleForCapturePreset(audio_source_t audioSource, |
| 390 | device_role_t role); |
| 391 | |
| 392 | /** |
| 393 | * @brief getDevicesForRoleAndCapturePreset queries which devices have the specified role for |
| 394 | * the specified capture preset |
| 395 | * @param audioSource the capture preset to query |
| 396 | * @param role the role of the devices to query |
| 397 | * @param devices returns list of devices with matching role for the specified capture preset. |
| 398 | * DEVICE_ROLE_NONE is invalid as input. |
| 399 | * @return BAD_VALUE if the capture preset or role is invalid, |
| 400 | * or NAME_NOT_FOUND if no device for the role and capture preset was set |
| 401 | * or NO_ERROR if the devices parameter contains a list of devices |
| 402 | */ |
| 403 | virtual status_t getDevicesForRoleAndCapturePreset(audio_source_t audioSource, |
| 404 | device_role_t role, AudioDeviceTypeAddrVector &devices) const = 0; |
| 405 | |
jiabin | 415af49 | 2020-09-17 14:31:20 -0700 | [diff] [blame] | 406 | /** |
| 407 | * @brief getActiveMediaDevices returns which devices will most likely to be used for media |
| 408 | * @param availableDevices all available devices |
| 409 | * @return collection of active devices |
| 410 | */ |
| 411 | virtual DeviceVector getActiveMediaDevices(const DeviceVector& availableDevices) const = 0; |
Jean-Michel Trivi | 3085715 | 2019-11-01 11:04:15 -0700 | [diff] [blame] | 412 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 413 | virtual void dump(String8 *dst) const = 0; |
| 414 | |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 415 | protected: |
Mikhail Naganov | 4783555 | 2019-05-14 10:32:51 -0700 | [diff] [blame] | 416 | virtual ~EngineInterface() {} |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 417 | }; |
| 418 | |
Mikhail Naganov | 4783555 | 2019-05-14 10:32:51 -0700 | [diff] [blame] | 419 | __attribute__((visibility("default"))) |
| 420 | extern "C" EngineInterface* createEngineInstance(); |
| 421 | |
| 422 | __attribute__((visibility("default"))) |
| 423 | extern "C" void destroyEngineInstance(EngineInterface *engine); |
| 424 | |
Mikhail Naganov | 1b2a794 | 2017-12-08 10:18:09 -0800 | [diff] [blame] | 425 | } // namespace android |