Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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 | package android.hardware.audio@7.0; |
| 18 | |
| 19 | import android.hardware.audio.common@7.0; |
| 20 | import IStreamIn; |
| 21 | import IStreamOut; |
| 22 | |
| 23 | interface IDevice { |
| 24 | /** |
| 25 | * Returns whether the audio hardware interface has been initialized. |
| 26 | * |
| 27 | * @return retval OK on success, NOT_INITIALIZED on failure. |
| 28 | */ |
| 29 | initCheck() generates (Result retval); |
| 30 | |
| 31 | /** |
| 32 | * Sets the audio volume for all audio activities other than voice call. If |
| 33 | * NOT_SUPPORTED is returned, the software mixer will emulate this |
| 34 | * capability. |
| 35 | * |
| 36 | * @param volume 1.0f means unity, 0.0f is zero. |
| 37 | * @return retval operation completion status. |
| 38 | */ |
| 39 | setMasterVolume(float volume) generates (Result retval); |
| 40 | |
| 41 | /** |
| 42 | * Get the current master volume value for the HAL, if the HAL supports |
| 43 | * master volume control. For example, AudioFlinger will query this value |
| 44 | * from the primary audio HAL when the service starts and use the value for |
| 45 | * setting the initial master volume across all HALs. HALs which do not |
| 46 | * support this method must return NOT_SUPPORTED in 'retval'. |
| 47 | * |
| 48 | * @return retval operation completion status. |
| 49 | * @return volume 1.0f means unity, 0.0f is zero. |
| 50 | */ |
| 51 | getMasterVolume() generates (Result retval, float volume); |
| 52 | |
| 53 | /** |
| 54 | * Sets microphone muting state. |
| 55 | * |
| 56 | * @param mute whether microphone is muted. |
| 57 | * @return retval operation completion status. |
| 58 | */ |
| 59 | setMicMute(bool mute) generates (Result retval); |
| 60 | |
| 61 | /** |
| 62 | * Gets whether microphone is muted. |
| 63 | * |
| 64 | * @return retval operation completion status. |
| 65 | * @return mute whether microphone is muted. |
| 66 | */ |
| 67 | getMicMute() generates (Result retval, bool mute); |
| 68 | |
| 69 | /** |
| 70 | * Set the audio mute status for all audio activities. If the return value |
| 71 | * is NOT_SUPPORTED, the software mixer will emulate this capability. |
| 72 | * |
| 73 | * @param mute whether audio is muted. |
| 74 | * @return retval operation completion status. |
| 75 | */ |
| 76 | setMasterMute(bool mute) generates (Result retval); |
| 77 | |
| 78 | /** |
| 79 | * Get the current master mute status for the HAL, if the HAL supports |
| 80 | * master mute control. AudioFlinger will query this value from the primary |
| 81 | * audio HAL when the service starts and use the value for setting the |
| 82 | * initial master mute across all HALs. HAL must indicate that the feature |
| 83 | * is not supported by returning NOT_SUPPORTED status. |
| 84 | * |
| 85 | * @return retval operation completion status. |
| 86 | * @return mute whether audio is muted. |
| 87 | */ |
| 88 | getMasterMute() generates (Result retval, bool mute); |
| 89 | |
| 90 | /** |
| 91 | * Returns audio input buffer size according to parameters passed or |
| 92 | * INVALID_ARGUMENTS if one of the parameters is not supported. |
| 93 | * |
| 94 | * @param config audio configuration. |
| 95 | * @return retval operation completion status. |
| 96 | * @return bufferSize input buffer size in bytes. |
| 97 | */ |
| 98 | getInputBufferSize(AudioConfig config) |
| 99 | generates (Result retval, uint64_t bufferSize); |
| 100 | |
| 101 | /** |
| 102 | * This method creates and opens the audio hardware output stream. |
| 103 | * If the stream can not be opened with the proposed audio config, |
| 104 | * HAL must provide suggested values for the audio config. |
| 105 | * |
Mikhail Naganov | 3f1457b | 2020-12-17 15:01:54 -0800 | [diff] [blame] | 106 | * Note: INVALID_ARGUMENTS is returned both in the case when the |
| 107 | * HAL can not use the provided config and in the case when |
| 108 | * the value of any argument is invalid. In the latter case the |
| 109 | * HAL must provide a default initialized suggested config. |
| 110 | * |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 111 | * @param ioHandle handle assigned by AudioFlinger. |
| 112 | * @param device device type and (if needed) address. |
| 113 | * @param config stream configuration. |
| 114 | * @param flags additional flags. |
| 115 | * @param sourceMetadata Description of the audio that will be played. |
| 116 | May be used by implementations to configure hardware effects. |
| 117 | * @return retval operation completion status. |
| 118 | * @return outStream created output stream. |
Mikhail Naganov | 3f1457b | 2020-12-17 15:01:54 -0800 | [diff] [blame] | 119 | * @return suggestedConfig in the case of rejection of the proposed config, |
| 120 | * a config suggested by the HAL. |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 121 | */ |
| 122 | openOutputStream( |
| 123 | AudioIoHandle ioHandle, |
| 124 | DeviceAddress device, |
| 125 | AudioConfig config, |
Mikhail Naganov | 355dd06 | 2020-09-24 18:00:44 +0000 | [diff] [blame] | 126 | vec<AudioInOutFlag> flags, |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 127 | SourceMetadata sourceMetadata) generates ( |
| 128 | Result retval, |
| 129 | IStreamOut outStream, |
| 130 | AudioConfig suggestedConfig); |
| 131 | |
| 132 | /** |
| 133 | * This method creates and opens the audio hardware input stream. |
| 134 | * If the stream can not be opened with the proposed audio config, |
| 135 | * HAL must provide suggested values for the audio config. |
| 136 | * |
Mikhail Naganov | 3f1457b | 2020-12-17 15:01:54 -0800 | [diff] [blame] | 137 | * Note: INVALID_ARGUMENTS is returned both in the case when the |
| 138 | * HAL can not use the provided config and in the case when |
| 139 | * the value of any argument is invalid. In the latter case the |
| 140 | * HAL must provide a default initialized suggested config. |
| 141 | * |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 142 | * @param ioHandle handle assigned by AudioFlinger. |
| 143 | * @param device device type and (if needed) address. |
| 144 | * @param config stream configuration. |
| 145 | * @param flags additional flags. |
| 146 | * @param sinkMetadata Description of the audio that is suggested by the client. |
| 147 | * May be used by implementations to configure processing effects. |
| 148 | * @return retval operation completion status. |
| 149 | * @return inStream in case of success, created input stream. |
Mikhail Naganov | 3f1457b | 2020-12-17 15:01:54 -0800 | [diff] [blame] | 150 | * @return suggestedConfig in the case of rejection of the proposed config, |
| 151 | * a config suggested by the HAL. |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 152 | */ |
| 153 | openInputStream( |
| 154 | AudioIoHandle ioHandle, |
| 155 | DeviceAddress device, |
| 156 | AudioConfig config, |
Mikhail Naganov | 355dd06 | 2020-09-24 18:00:44 +0000 | [diff] [blame] | 157 | vec<AudioInOutFlag> flags, |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 158 | SinkMetadata sinkMetadata) generates ( |
| 159 | Result retval, |
| 160 | IStreamIn inStream, |
| 161 | AudioConfig suggestedConfig); |
| 162 | |
| 163 | /** |
| 164 | * Returns whether HAL supports audio patches. Patch represents a connection |
| 165 | * between signal source(s) and signal sink(s). If HAL doesn't support |
| 166 | * patches natively (in hardware) then audio system will need to establish |
| 167 | * them in software. |
| 168 | * |
| 169 | * @return supports true if audio patches are supported. |
| 170 | */ |
| 171 | supportsAudioPatches() generates (bool supports); |
| 172 | |
| 173 | /** |
| 174 | * Creates an audio patch between several source and sink ports. The handle |
| 175 | * is allocated by the HAL and must be unique for this audio HAL module. |
| 176 | * |
Mikhail Naganov | 4ffb092 | 2021-01-11 17:59:10 -0800 | [diff] [blame] | 177 | * Optional method. HAL must support it if 'supportsAudioPatches' returns |
| 178 | * 'true'. |
| 179 | * |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 180 | * @param sources patch sources. |
| 181 | * @param sinks patch sinks. |
| 182 | * @return retval operation completion status. |
| 183 | * @return patch created patch handle. |
| 184 | */ |
| 185 | createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks) |
| 186 | generates (Result retval, AudioPatchHandle patch); |
| 187 | |
| 188 | /** |
| 189 | * Updates an audio patch. |
| 190 | * |
| 191 | * Use of this function is preferred to releasing and re-creating a patch |
| 192 | * as the HAL module can figure out a way of switching the route without |
| 193 | * causing audio disruption. |
| 194 | * |
Mikhail Naganov | 4ffb092 | 2021-01-11 17:59:10 -0800 | [diff] [blame] | 195 | * Optional method. HAL must support it if 'supportsAudioPatches' returns |
| 196 | * 'true'. |
| 197 | * |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 198 | * @param previousPatch handle of the previous patch to update. |
| 199 | * @param sources new patch sources. |
| 200 | * @param sinks new patch sinks. |
| 201 | * @return retval operation completion status. |
| 202 | * @return patch updated patch handle. |
| 203 | */ |
| 204 | updateAudioPatch( |
| 205 | AudioPatchHandle previousPatch, |
| 206 | vec<AudioPortConfig> sources, |
| 207 | vec<AudioPortConfig> sinks) generates ( |
| 208 | Result retval, AudioPatchHandle patch); |
| 209 | |
| 210 | /** |
| 211 | * Release an audio patch. |
| 212 | * |
Mikhail Naganov | 4ffb092 | 2021-01-11 17:59:10 -0800 | [diff] [blame] | 213 | * Optional method. HAL must support it if 'supportsAudioPatches' returns |
| 214 | * 'true'. |
| 215 | * |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 216 | * @param patch patch handle. |
| 217 | * @return retval operation completion status. |
| 218 | */ |
| 219 | releaseAudioPatch(AudioPatchHandle patch) generates (Result retval); |
| 220 | |
| 221 | /** |
| 222 | * Returns the list of supported attributes for a given audio port. |
| 223 | * |
| 224 | * As input, 'port' contains the information (type, role, address etc...) |
| 225 | * needed by the HAL to identify the port. |
| 226 | * |
| 227 | * As output, 'resultPort' contains possible attributes (sampling rates, |
| 228 | * formats, channel masks, gain controllers...) for this port. |
| 229 | * |
| 230 | * @param port port identifier. |
| 231 | * @return retval operation completion status. |
| 232 | * @return resultPort port descriptor with all parameters filled up. |
| 233 | */ |
| 234 | getAudioPort(AudioPort port) |
| 235 | generates (Result retval, AudioPort resultPort); |
| 236 | |
| 237 | /** |
| 238 | * Set audio port configuration. |
| 239 | * |
| 240 | * @param config audio port configuration. |
| 241 | * @return retval operation completion status. |
| 242 | */ |
| 243 | setAudioPortConfig(AudioPortConfig config) generates (Result retval); |
| 244 | |
| 245 | /** |
| 246 | * Gets the HW synchronization source of the device. Calling this method is |
| 247 | * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL. |
Mikhail Naganov | aa88f5b | 2021-03-08 09:20:26 -0800 | [diff] [blame] | 248 | * |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 249 | * Optional method |
| 250 | * |
| 251 | * @return retval operation completion status: OK or NOT_SUPPORTED. |
| 252 | * @return hwAvSync HW synchronization source |
| 253 | */ |
| 254 | getHwAvSync() generates (Result retval, AudioHwSync hwAvSync); |
| 255 | |
| 256 | /** |
| 257 | * Sets whether the screen is on. Calling this method is equivalent to |
| 258 | * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL. |
Mikhail Naganov | aa88f5b | 2021-03-08 09:20:26 -0800 | [diff] [blame] | 259 | * |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 260 | * Optional method |
| 261 | * |
| 262 | * @param turnedOn whether the screen is turned on. |
| 263 | * @return retval operation completion status. |
| 264 | */ |
| 265 | setScreenState(bool turnedOn) generates (Result retval); |
| 266 | |
| 267 | /** |
| 268 | * Generic method for retrieving vendor-specific parameter values. |
| 269 | * The framework does not interpret the parameters, they are passed |
| 270 | * in an opaque manner between a vendor application and HAL. |
| 271 | * |
| 272 | * Multiple parameters can be retrieved at the same time. |
| 273 | * The implementation should return as many requested parameters |
| 274 | * as possible, even if one or more is not supported |
| 275 | * |
| 276 | * @param context provides more information about the request |
| 277 | * @param keys keys of the requested parameters |
| 278 | * @return retval operation completion status. |
| 279 | * OK must be returned if keys is empty. |
| 280 | * NOT_SUPPORTED must be returned if at least one key is unknown. |
| 281 | * @return parameters parameter key value pairs. |
| 282 | * Must contain the value of all requested keys if retval == OK |
| 283 | */ |
| 284 | getParameters(vec<ParameterValue> context, vec<string> keys) |
| 285 | generates (Result retval, vec<ParameterValue> parameters); |
| 286 | |
| 287 | /** |
| 288 | * Generic method for setting vendor-specific parameter values. |
| 289 | * The framework does not interpret the parameters, they are passed |
| 290 | * in an opaque manner between a vendor application and HAL. |
| 291 | * |
| 292 | * Multiple parameters can be set at the same time though this is |
| 293 | * discouraged as it make failure analysis harder. |
| 294 | * |
| 295 | * If possible, a failed setParameters should not impact the platform state. |
| 296 | * |
| 297 | * @param context provides more information about the request |
| 298 | * @param parameters parameter key value pairs. |
| 299 | * @return retval operation completion status. |
| 300 | * All parameters must be successfully set for OK to be returned |
| 301 | */ |
| 302 | setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters) |
| 303 | generates (Result retval); |
| 304 | |
| 305 | /** |
| 306 | * Returns an array with available microphones in device. |
| 307 | * |
| 308 | * @return retval NOT_SUPPORTED if there are no microphones on this device |
| 309 | * INVALID_STATE if the call is not successful, |
| 310 | * OK otherwise. |
| 311 | * |
| 312 | * @return microphones array with microphones info |
| 313 | */ |
| 314 | getMicrophones() |
| 315 | generates(Result retval, vec<MicrophoneInfo> microphones); |
| 316 | |
| 317 | /** |
| 318 | * Notifies the device module about the connection state of an input/output |
| 319 | * device attached to it. Calling this method is equivalent to setting |
| 320 | * AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL. |
| 321 | * |
| 322 | * @param address audio device specification. |
| 323 | * @param connected whether the device is connected. |
| 324 | * @return retval operation completion status. |
| 325 | */ |
| 326 | setConnectedState(DeviceAddress address, bool connected) |
| 327 | generates (Result retval); |
| 328 | |
| 329 | /** |
| 330 | * Called by the framework to deinitialize the device and free up |
| 331 | * all currently allocated resources. It is recommended to close |
| 332 | * the device on the client side as soon as it is becomes unused. |
| 333 | * |
| 334 | * Note that all streams must be closed by the client before |
| 335 | * attempting to close the device they belong to. |
| 336 | * |
| 337 | * @return retval OK in case the success. |
| 338 | * INVALID_STATE if the device was already closed |
| 339 | * or there are streams currently opened. |
| 340 | */ |
Mikhail Naganov | 60ced76 | 2020-07-23 18:08:26 +0000 | [diff] [blame] | 341 | close() generates (Result retval); |
| 342 | |
| 343 | /** |
| 344 | * Applies an audio effect to an audio device. The effect is inserted |
| 345 | * according to its insertion preference specified by INSERT_... EffectFlags |
| 346 | * in the EffectDescriptor. |
| 347 | * |
| 348 | * @param device identifies the sink or source device this effect must be applied to. |
| 349 | * "device" is the AudioPortHandle indicated for the device when the audio |
| 350 | * patch connecting that device was created. |
| 351 | * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of |
| 352 | * the effect to add. |
| 353 | * @return retval operation completion status. |
| 354 | */ |
| 355 | addDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval); |
| 356 | |
| 357 | /** |
| 358 | * Stops applying an audio effect to an audio device. |
| 359 | * |
| 360 | * @param device identifies the sink or source device this effect was applied to. |
| 361 | * "device" is the AudioPortHandle indicated for the device when the audio |
| 362 | * patch is created at the audio HAL. |
| 363 | * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of |
| 364 | * the effect. |
| 365 | * @return retval operation completion status. |
| 366 | */ |
| 367 | removeDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval); |
| 368 | }; |