Kevin Rocard | 20614ba | 2018-11-10 07:20:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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@5.0; |
| 18 | |
| 19 | import android.hardware.audio.common@5.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 | * |
| 106 | * @param ioHandle handle assigned by AudioFlinger. |
| 107 | * @param device device type and (if needed) address. |
| 108 | * @param config stream configuration. |
| 109 | * @param flags additional flags. |
| 110 | * @param sourceMetadata Description of the audio that will be played. |
| 111 | May be used by implementations to configure hardware effects. |
| 112 | * @return retval operation completion status. |
| 113 | * @return outStream created output stream. |
| 114 | * @return suggestedConfig in case of invalid parameters, suggested config. |
| 115 | */ |
| 116 | openOutputStream( |
| 117 | AudioIoHandle ioHandle, |
| 118 | DeviceAddress device, |
| 119 | AudioConfig config, |
| 120 | bitfield<AudioOutputFlag> flags, |
| 121 | SourceMetadata sourceMetadata) generates ( |
| 122 | Result retval, |
| 123 | IStreamOut outStream, |
| 124 | AudioConfig suggestedConfig); |
| 125 | |
| 126 | /** |
| 127 | * This method creates and opens the audio hardware input stream. |
| 128 | * If the stream can not be opened with the proposed audio config, |
| 129 | * HAL must provide suggested values for the audio config. |
| 130 | * |
| 131 | * @param ioHandle handle assigned by AudioFlinger. |
| 132 | * @param device device type and (if needed) address. |
| 133 | * @param config stream configuration. |
| 134 | * @param flags additional flags. |
| 135 | * @param sinkMetadata Description of the audio that is suggested by the client. |
Mikhail Naganov | 1503a98 | 2018-12-11 15:52:14 -0800 | [diff] [blame] | 136 | * May be used by implementations to configure processing effects. |
Kevin Rocard | 20614ba | 2018-11-10 07:20:17 -0800 | [diff] [blame] | 137 | * @return retval operation completion status. |
| 138 | * @return inStream in case of success, created input stream. |
| 139 | * @return suggestedConfig in case of invalid parameters, suggested config. |
| 140 | */ |
| 141 | openInputStream( |
| 142 | AudioIoHandle ioHandle, |
| 143 | DeviceAddress device, |
| 144 | AudioConfig config, |
| 145 | bitfield<AudioInputFlag> flags, |
| 146 | SinkMetadata sinkMetadata) generates ( |
| 147 | Result retval, |
| 148 | IStreamIn inStream, |
| 149 | AudioConfig suggestedConfig); |
| 150 | |
| 151 | /** |
| 152 | * Returns whether HAL supports audio patches. |
| 153 | * |
| 154 | * @return supports true if audio patches are supported. |
| 155 | */ |
| 156 | supportsAudioPatches() generates (bool supports); |
| 157 | |
| 158 | /** |
| 159 | * Creates an audio patch between several source and sink ports. The handle |
| 160 | * is allocated by the HAL and must be unique for this audio HAL module. |
| 161 | * |
| 162 | * @param sources patch sources. |
| 163 | * @param sinks patch sinks. |
| 164 | * @return retval operation completion status. |
| 165 | * @return patch created patch handle. |
| 166 | */ |
| 167 | createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks) |
| 168 | generates (Result retval, AudioPatchHandle patch); |
| 169 | |
| 170 | /** |
| 171 | * Release an audio patch. |
| 172 | * |
| 173 | * @param patch patch handle. |
| 174 | * @return retval operation completion status. |
| 175 | */ |
| 176 | releaseAudioPatch(AudioPatchHandle patch) generates (Result retval); |
| 177 | |
| 178 | /** |
| 179 | * Returns the list of supported attributes for a given audio port. |
| 180 | * |
| 181 | * As input, 'port' contains the information (type, role, address etc...) |
| 182 | * needed by the HAL to identify the port. |
| 183 | * |
| 184 | * As output, 'resultPort' contains possible attributes (sampling rates, |
| 185 | * formats, channel masks, gain controllers...) for this port. |
| 186 | * |
| 187 | * @param port port identifier. |
| 188 | * @return retval operation completion status. |
| 189 | * @return resultPort port descriptor with all parameters filled up. |
| 190 | */ |
| 191 | getAudioPort(AudioPort port) |
| 192 | generates (Result retval, AudioPort resultPort); |
| 193 | |
| 194 | /** |
| 195 | * Set audio port configuration. |
| 196 | * |
| 197 | * @param config audio port configuration. |
| 198 | * @return retval operation completion status. |
| 199 | */ |
| 200 | setAudioPortConfig(AudioPortConfig config) generates (Result retval); |
| 201 | |
| 202 | /** |
| 203 | * Gets the HW synchronization source of the device. Calling this method is |
| 204 | * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL. |
| 205 | * Optional method |
| 206 | * |
| 207 | * @return retval operation completion status: OK or NOT_SUPPORTED. |
| 208 | * @return hwAvSync HW synchronization source |
| 209 | */ |
| 210 | getHwAvSync() generates (Result retval, AudioHwSync hwAvSync); |
| 211 | |
| 212 | /** |
| 213 | * Sets whether the screen is on. Calling this method is equivalent to |
| 214 | * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL. |
| 215 | * Optional method |
| 216 | * |
| 217 | * @param turnedOn whether the screen is turned on. |
| 218 | * @return retval operation completion status. |
| 219 | */ |
| 220 | setScreenState(bool turnedOn) generates (Result retval); |
| 221 | |
| 222 | /** |
| 223 | * Generic method for retrieving vendor-specific parameter values. |
| 224 | * The framework does not interpret the parameters, they are passed |
| 225 | * in an opaque manner between a vendor application and HAL. |
| 226 | * |
| 227 | * Multiple parameters can be retrieved at the same time. |
| 228 | * The implementation should return as many requested parameters |
| 229 | * as possible, even if one or more is not supported |
| 230 | * |
| 231 | * @param context provides more information about the request |
| 232 | * @param keys keys of the requested parameters |
| 233 | * @return retval operation completion status. |
| 234 | * OK must be returned if keys is empty. |
| 235 | * NOT_SUPPORTED must be returned if at least one key is unknown. |
| 236 | * @return parameters parameter key value pairs. |
| 237 | * Must contain the value of all requested keys if retval == OK |
| 238 | */ |
| 239 | getParameters(vec<ParameterValue> context, vec<string> keys) |
| 240 | generates (Result retval, vec<ParameterValue> parameters); |
| 241 | |
| 242 | /** |
| 243 | * Generic method for setting vendor-specific parameter values. |
| 244 | * The framework does not interpret the parameters, they are passed |
| 245 | * in an opaque manner between a vendor application and HAL. |
| 246 | * |
| 247 | * Multiple parameters can be set at the same time though this is |
| 248 | * discouraged as it make failure analysis harder. |
| 249 | * |
| 250 | * If possible, a failed setParameters should not impact the platform state. |
| 251 | * |
| 252 | * @param context provides more information about the request |
| 253 | * @param parameters parameter key value pairs. |
| 254 | * @return retval operation completion status. |
| 255 | * All parameters must be successfully set for OK to be returned |
| 256 | */ |
| 257 | setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters) |
| 258 | generates (Result retval); |
| 259 | |
| 260 | /** |
| 261 | * Returns an array with available microphones in device. |
| 262 | * |
| 263 | * @return retval INVALID_STATE if the call is not successful, |
| 264 | * OK otherwise. |
| 265 | * |
| 266 | * @return microphones array with microphones info |
| 267 | */ |
| 268 | getMicrophones() |
| 269 | generates(Result retval, vec<MicrophoneInfo> microphones); |
| 270 | |
| 271 | /** |
| 272 | * Notifies the device module about the connection state of an input/output |
| 273 | * device attached to it. Calling this method is equivalent to setting |
| 274 | * AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL. |
| 275 | * |
| 276 | * @param address audio device specification. |
| 277 | * @param connected whether the device is connected. |
| 278 | * @return retval operation completion status. |
| 279 | */ |
| 280 | setConnectedState(DeviceAddress address, bool connected) |
| 281 | generates (Result retval); |
| 282 | }; |