Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -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@4.0; |
| 18 | |
| 19 | import android.hardware.audio.common@4.0; |
| 20 | import android.hardware.audio.effect@4.0::IEffect; |
| 21 | |
| 22 | interface IStream { |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 23 | /** |
| 24 | * Return the frame size (number of bytes per sample). |
| 25 | * |
| 26 | * @return frameSize frame size in bytes. |
| 27 | */ |
| 28 | getFrameSize() generates (uint64_t frameSize); |
| 29 | |
| 30 | /** |
| 31 | * Return the frame count of the buffer. Calling this method is equivalent |
| 32 | * to getting AUDIO_PARAMETER_STREAM_FRAME_COUNT on the legacy HAL. |
| 33 | * |
| 34 | * @return count frame count. |
| 35 | */ |
| 36 | getFrameCount() generates (uint64_t count); |
| 37 | |
| 38 | /** |
| 39 | * Return the size of input/output buffer in bytes for this stream. |
| 40 | * It must be a multiple of the frame size. |
| 41 | * |
| 42 | * @return buffer buffer size in bytes. |
| 43 | */ |
| 44 | getBufferSize() generates (uint64_t bufferSize); |
| 45 | |
| 46 | /** |
| 47 | * Return the sampling rate in Hz. |
| 48 | * |
| 49 | * @return sampleRateHz sample rate in Hz. |
| 50 | */ |
| 51 | getSampleRate() generates (uint32_t sampleRateHz); |
| 52 | |
| 53 | /** |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 54 | * Return supported native sampling rates of the stream for a given format. |
| 55 | * A supported native sample rate is a sample rate that can be efficiently |
| 56 | * played by the hardware (typically without sample-rate conversions). |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 57 | * |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 58 | * This function is only called for dynamic profile. If called for |
| 59 | * non-dynamic profile is should return NOT_SUPPORTED or the same list |
| 60 | * as in audio_policy_configuration.xml. |
| 61 | * |
| 62 | * Calling this method is equivalent to getting |
| 63 | * AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL. |
| 64 | * |
| 65 | * |
| 66 | * @param format audio format for which the sample rates are supported. |
| 67 | * @return retval operation completion status. |
| 68 | * Must be OK if the format is supported. |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 69 | * @return sampleRateHz supported sample rates. |
| 70 | */ |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 71 | getSupportedSampleRates(AudioFormat format) |
| 72 | generates (Result retval, vec<uint32_t> sampleRates); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Sets the sampling rate of the stream. Calling this method is equivalent |
| 76 | * to setting AUDIO_PARAMETER_STREAM_SAMPLING_RATE on the legacy HAL. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 77 | * Optional method. If implemented, only called on a stopped stream. |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 78 | * |
| 79 | * @param sampleRateHz sample rate in Hz. |
| 80 | * @return retval operation completion status. |
| 81 | */ |
| 82 | setSampleRate(uint32_t sampleRateHz) generates (Result retval); |
| 83 | |
| 84 | /** |
| 85 | * Return the channel mask of the stream. |
| 86 | * |
| 87 | * @return mask channel mask. |
| 88 | */ |
Kevin Rocard | 79c5740 | 2018-01-24 10:02:30 -0800 | [diff] [blame] | 89 | getChannelMask() generates (bitfield<AudioChannelMask> mask); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Return supported channel masks of the stream. Calling this method is |
| 93 | * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy |
| 94 | * HAL. |
| 95 | * |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 96 | * @param format audio format for which the channel masks are supported. |
| 97 | * @return retval operation completion status. |
| 98 | * Must be OK if the format is supported. |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 99 | * @return masks supported audio masks. |
| 100 | */ |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 101 | getSupportedChannelMasks(AudioFormat format) |
Kevin Rocard | 79c5740 | 2018-01-24 10:02:30 -0800 | [diff] [blame] | 102 | generates (Result retval, vec<bitfield<AudioChannelMask>> masks); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * Sets the channel mask of the stream. Calling this method is equivalent to |
| 106 | * setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 107 | * Optional method |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 108 | * |
| 109 | * @param format audio format. |
| 110 | * @return retval operation completion status. |
| 111 | */ |
Kevin Rocard | 79c5740 | 2018-01-24 10:02:30 -0800 | [diff] [blame] | 112 | setChannelMask(bitfield<AudioChannelMask> mask) generates (Result retval); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Return the audio format of the stream. |
| 116 | * |
| 117 | * @return format audio format. |
| 118 | */ |
| 119 | getFormat() generates (AudioFormat format); |
| 120 | |
| 121 | /** |
| 122 | * Return supported audio formats of the stream. Calling this method is |
| 123 | * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy |
| 124 | * HAL. |
| 125 | * |
| 126 | * @return formats supported audio formats. |
| 127 | */ |
| 128 | getSupportedFormats() generates (vec<AudioFormat> formats); |
| 129 | |
| 130 | /** |
| 131 | * Sets the audio format of the stream. Calling this method is equivalent to |
| 132 | * setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 133 | * Optional method |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 134 | * |
| 135 | * @param format audio format. |
| 136 | * @return retval operation completion status. |
| 137 | */ |
| 138 | setFormat(AudioFormat format) generates (Result retval); |
| 139 | |
| 140 | /** |
| 141 | * Convenience method for retrieving several stream parameters in |
| 142 | * one transaction. |
| 143 | * |
| 144 | * @return sampleRateHz sample rate in Hz. |
| 145 | * @return mask channel mask. |
| 146 | * @return format audio format. |
| 147 | */ |
| 148 | getAudioProperties() generates ( |
Kevin Rocard | 79c5740 | 2018-01-24 10:02:30 -0800 | [diff] [blame] | 149 | uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 150 | |
| 151 | /** |
| 152 | * Applies audio effect to the stream. |
| 153 | * |
| 154 | * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of |
| 155 | * the effect to apply. |
| 156 | * @return retval operation completion status. |
| 157 | */ |
| 158 | addEffect(uint64_t effectId) generates (Result retval); |
| 159 | |
| 160 | /** |
| 161 | * Stops application of the effect to the stream. |
| 162 | * |
| 163 | * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of |
| 164 | * the effect to remove. |
| 165 | * @return retval operation completion status. |
| 166 | */ |
| 167 | removeEffect(uint64_t effectId) generates (Result retval); |
| 168 | |
| 169 | /** |
| 170 | * Put the audio hardware input/output into standby mode. |
| 171 | * Driver must exit from standby mode at the next I/O operation. |
| 172 | * |
| 173 | * @return retval operation completion status. |
| 174 | */ |
| 175 | standby() generates (Result retval); |
| 176 | |
| 177 | /** |
Mikhail Naganov | b2f1c0f | 2018-02-13 09:13:20 -0800 | [diff] [blame] | 178 | * Return the set of devices which this stream is connected to. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 179 | * Optional method |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 180 | * |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 181 | * @return retval operation completion status: OK or NOT_SUPPORTED. |
Mikhail Naganov | b2f1c0f | 2018-02-13 09:13:20 -0800 | [diff] [blame] | 182 | * @return device set of devices which this stream is connected to. |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 183 | */ |
Mikhail Naganov | b2f1c0f | 2018-02-13 09:13:20 -0800 | [diff] [blame] | 184 | getDevices() generates (Result retval, vec<DeviceAddress> devices); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 185 | |
| 186 | /** |
Mikhail Naganov | b2f1c0f | 2018-02-13 09:13:20 -0800 | [diff] [blame] | 187 | * Connects the stream to one or multiple devices. |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 188 | * |
| 189 | * This method must only be used for HALs that do not support |
| 190 | * 'IDevice.createAudioPatch' method. Calling this method is |
Mikhail Naganov | b2f1c0f | 2018-02-13 09:13:20 -0800 | [diff] [blame] | 191 | * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceeded |
| 192 | * with a device address in the legacy HAL interface. |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 193 | * |
| 194 | * @param address device to connect the stream to. |
| 195 | * @return retval operation completion status. |
| 196 | */ |
Mikhail Naganov | b2f1c0f | 2018-02-13 09:13:20 -0800 | [diff] [blame] | 197 | setDevices(vec<DeviceAddress> devices) generates (Result retval); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 198 | |
| 199 | /** |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 200 | * Sets the HW synchronization source. Calling this method is equivalent to |
| 201 | * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 202 | * Optional method |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 203 | * |
| 204 | * @param hwAvSync HW synchronization source |
| 205 | * @return retval operation completion status. |
| 206 | */ |
| 207 | setHwAvSync(AudioHwSync hwAvSync) generates (Result retval); |
| 208 | |
| 209 | /** |
| 210 | * Generic method for retrieving vendor-specific parameter values. |
| 211 | * The framework does not interpret the parameters, they are passed |
| 212 | * in an opaque manner between a vendor application and HAL. |
| 213 | * |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 214 | * Multiple parameters can be retrieved at the same time. |
| 215 | * The implementation should return as many requested parameters |
| 216 | * as possible, even if one or more is not supported |
| 217 | * |
| 218 | * @param context provides more information about the request |
| 219 | * @param keys keys of the requested parameters |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 220 | * @return retval operation completion status. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 221 | * OK must be returned if keys is empty. |
| 222 | * NOT_SUPPORTED must be returned if at least one key is unknown. |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 223 | * @return parameters parameter key value pairs. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 224 | * Must contain the value of all requested keys if retval == OK |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 225 | */ |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 226 | getParameters(vec<ParameterValue> context, vec<string> keys) |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 227 | generates (Result retval, vec<ParameterValue> parameters); |
| 228 | |
| 229 | /** |
| 230 | * Generic method for setting vendor-specific parameter values. |
| 231 | * The framework does not interpret the parameters, they are passed |
| 232 | * in an opaque manner between a vendor application and HAL. |
| 233 | * |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 234 | * Multiple parameters can be set at the same time though this is |
| 235 | * discouraged as it make failure analysis harder. |
| 236 | * |
| 237 | * If possible, a failed setParameters should not impact the platform state. |
| 238 | * |
| 239 | * @param context provides more information about the request |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 240 | * @param parameters parameter key value pairs. |
| 241 | * @return retval operation completion status. |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 242 | * All parameters must be successfully set for OK to be returned |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 243 | */ |
Kevin Rocard | 74980b5 | 2018-01-20 22:12:57 -0800 | [diff] [blame] | 244 | setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters) |
| 245 | generates (Result retval); |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 246 | |
| 247 | /** |
Kevin Rocard | a4e6d8b | 2018-01-20 21:52:01 -0800 | [diff] [blame] | 248 | * Called by the framework to start a stream operating in mmap mode. |
| 249 | * createMmapBuffer() must be called before calling start(). |
| 250 | * Function only implemented by streams operating in mmap mode. |
| 251 | * |
| 252 | * @return retval OK in case the success. |
| 253 | * NOT_SUPPORTED on non mmap mode streams |
| 254 | * INVALID_STATE if called out of sequence |
| 255 | */ |
| 256 | start() generates (Result retval); |
| 257 | |
| 258 | /** |
| 259 | * Called by the framework to stop a stream operating in mmap mode. |
| 260 | * Function only implemented by streams operating in mmap mode. |
| 261 | * |
| 262 | * @return retval OK in case the succes. |
| 263 | * NOT_SUPPORTED on non mmap mode streams |
| 264 | * INVALID_STATE if called out of sequence |
| 265 | */ |
| 266 | stop() generates (Result retval) ; |
| 267 | |
| 268 | /** |
| 269 | * Called by the framework to retrieve information on the mmap buffer used for audio |
| 270 | * samples transfer. |
| 271 | * Function only implemented by streams operating in mmap mode. |
| 272 | * |
| 273 | * @param minSizeFrames minimum buffer size requested. The actual buffer |
| 274 | * size returned in struct MmapBufferInfo can be larger. |
| 275 | * @return retval OK in case the success. |
| 276 | * NOT_SUPPORTED on non mmap mode streams |
| 277 | * NOT_INITIALIZED in case of memory allocation error |
| 278 | * INVALID_ARGUMENTS if the requested buffer size is too large |
| 279 | * INVALID_STATE if called out of sequence |
| 280 | * @return info a MmapBufferInfo struct containing information on the MMMAP buffer created. |
| 281 | */ |
| 282 | createMmapBuffer(int32_t minSizeFrames) |
| 283 | generates (Result retval, MmapBufferInfo info); |
| 284 | |
| 285 | /** |
| 286 | * Called by the framework to read current read/write position in the mmap buffer |
| 287 | * with associated time stamp. |
| 288 | * Function only implemented by streams operating in mmap mode. |
| 289 | * |
| 290 | * @return retval OK in case the success. |
| 291 | * NOT_SUPPORTED on non mmap mode streams |
| 292 | * INVALID_STATE if called out of sequence |
| 293 | * @return position a MmapPosition struct containing current HW read/write position in frames |
| 294 | * with associated time stamp. |
| 295 | */ |
| 296 | getMmapPosition() |
| 297 | generates (Result retval, MmapPosition position); |
| 298 | |
| 299 | /** |
| 300 | * Called by the framework to deinitialize the stream and free up |
| 301 | * all the currently allocated resources. It is recommended to close |
| 302 | * the stream on the client side as soon as it is becomes unused. |
| 303 | * |
| 304 | * @return retval OK in case the success. |
| 305 | * NOT_SUPPORTED if called on IStream instead of input or |
| 306 | * output stream interface. |
| 307 | * INVALID_STATE if the stream was already closed. |
| 308 | */ |
| 309 | close() generates (Result retval); |
| 310 | }; |