blob: 62b8d036e48e7798be195c0c1b8594bdafcdde5e [file] [log] [blame]
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -08001/*
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
17package android.hardware.audio@4.0;
18
19import android.hardware.audio.common@4.0;
20import android.hardware.audio.effect@4.0::IEffect;
21
22interface IStream {
23 typedef android.hardware.audio@4.0::Result Result;
24
25 /**
26 * Return the frame size (number of bytes per sample).
27 *
28 * @return frameSize frame size in bytes.
29 */
30 getFrameSize() generates (uint64_t frameSize);
31
32 /**
33 * Return the frame count of the buffer. Calling this method is equivalent
34 * to getting AUDIO_PARAMETER_STREAM_FRAME_COUNT on the legacy HAL.
35 *
36 * @return count frame count.
37 */
38 getFrameCount() generates (uint64_t count);
39
40 /**
41 * Return the size of input/output buffer in bytes for this stream.
42 * It must be a multiple of the frame size.
43 *
44 * @return buffer buffer size in bytes.
45 */
46 getBufferSize() generates (uint64_t bufferSize);
47
48 /**
49 * Return the sampling rate in Hz.
50 *
51 * @return sampleRateHz sample rate in Hz.
52 */
53 getSampleRate() generates (uint32_t sampleRateHz);
54
55 /**
Kevin Rocard74980b52018-01-20 22:12:57 -080056 * Return supported native sampling rates of the stream for a given format.
57 * A supported native sample rate is a sample rate that can be efficiently
58 * played by the hardware (typically without sample-rate conversions).
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080059 *
Kevin Rocard74980b52018-01-20 22:12:57 -080060 * This function is only called for dynamic profile. If called for
61 * non-dynamic profile is should return NOT_SUPPORTED or the same list
62 * as in audio_policy_configuration.xml.
63 *
64 * Calling this method is equivalent to getting
65 * AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL.
66 *
67 *
68 * @param format audio format for which the sample rates are supported.
69 * @return retval operation completion status.
70 * Must be OK if the format is supported.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080071 * @return sampleRateHz supported sample rates.
72 */
Kevin Rocard74980b52018-01-20 22:12:57 -080073 getSupportedSampleRates(AudioFormat format)
74 generates (Result retval, vec<uint32_t> sampleRates);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080075
76 /**
77 * Sets the sampling rate of the stream. Calling this method is equivalent
78 * to setting AUDIO_PARAMETER_STREAM_SAMPLING_RATE on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -080079 * Optional method. If implemented, only called on a stopped stream.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080080 *
81 * @param sampleRateHz sample rate in Hz.
82 * @return retval operation completion status.
83 */
84 setSampleRate(uint32_t sampleRateHz) generates (Result retval);
85
86 /**
87 * Return the channel mask of the stream.
88 *
89 * @return mask channel mask.
90 */
91 getChannelMask() generates (AudioChannelMask mask);
92
93 /**
94 * Return supported channel masks of the stream. Calling this method is
95 * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy
96 * HAL.
97 *
Kevin Rocard74980b52018-01-20 22:12:57 -080098 * @param format audio format for which the channel masks are supported.
99 * @return retval operation completion status.
100 * Must be OK if the format is supported.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800101 * @return masks supported audio masks.
102 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800103 getSupportedChannelMasks(AudioFormat format)
104 generates (Result retval, vec<AudioChannelMask> masks);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800105
106 /**
107 * Sets the channel mask of the stream. Calling this method is equivalent to
108 * setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800109 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800110 *
111 * @param format audio format.
112 * @return retval operation completion status.
113 */
114 setChannelMask(AudioChannelMask mask) generates (Result retval);
115
116 /**
117 * Return the audio format of the stream.
118 *
119 * @return format audio format.
120 */
121 getFormat() generates (AudioFormat format);
122
123 /**
124 * Return supported audio formats of the stream. Calling this method is
125 * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy
126 * HAL.
127 *
128 * @return formats supported audio formats.
129 */
130 getSupportedFormats() generates (vec<AudioFormat> formats);
131
132 /**
133 * Sets the audio format of the stream. Calling this method is equivalent to
134 * setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800135 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800136 *
137 * @param format audio format.
138 * @return retval operation completion status.
139 */
140 setFormat(AudioFormat format) generates (Result retval);
141
142 /**
143 * Convenience method for retrieving several stream parameters in
144 * one transaction.
145 *
146 * @return sampleRateHz sample rate in Hz.
147 * @return mask channel mask.
148 * @return format audio format.
149 */
150 getAudioProperties() generates (
151 uint32_t sampleRateHz, AudioChannelMask mask, AudioFormat format);
152
153 /**
154 * Applies audio effect to the stream.
155 *
156 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
157 * the effect to apply.
158 * @return retval operation completion status.
159 */
160 addEffect(uint64_t effectId) generates (Result retval);
161
162 /**
163 * Stops application of the effect to the stream.
164 *
165 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
166 * the effect to remove.
167 * @return retval operation completion status.
168 */
169 removeEffect(uint64_t effectId) generates (Result retval);
170
171 /**
172 * Put the audio hardware input/output into standby mode.
173 * Driver must exit from standby mode at the next I/O operation.
174 *
175 * @return retval operation completion status.
176 */
177 standby() generates (Result retval);
178
179 /**
180 * Return the set of device(s) which this stream is connected to.
Kevin Rocard74980b52018-01-20 22:12:57 -0800181 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800182 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800183 * @return retval operation completion status: OK or NOT_SUPPORTED.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800184 * @return device set of device(s) which this stream is connected to.
185 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800186 getDevice() generates (Result retval, AudioDevice device);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800187
188 /**
189 * Connects the stream to the device.
190 *
191 * This method must only be used for HALs that do not support
192 * 'IDevice.createAudioPatch' method. Calling this method is
193 * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING in the legacy HAL
194 * interface.
195 *
196 * @param address device to connect the stream to.
197 * @return retval operation completion status.
198 */
199 setDevice(DeviceAddress address) generates (Result retval);
200
201 /**
202 * Notifies the stream about device connection state. Calling this method is
203 * equivalent to setting AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy
204 * HAL.
205 *
206 * @param address audio device specification.
207 * @param connected whether the device is connected.
208 * @return retval operation completion status.
209 */
210 setConnectedState(DeviceAddress address, bool connected)
211 generates (Result retval);
212
213 /**
214 * Sets the HW synchronization source. Calling this method is equivalent to
215 * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800216 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800217 *
218 * @param hwAvSync HW synchronization source
219 * @return retval operation completion status.
220 */
221 setHwAvSync(AudioHwSync hwAvSync) generates (Result retval);
222
223 /**
224 * Generic method for retrieving vendor-specific parameter values.
225 * The framework does not interpret the parameters, they are passed
226 * in an opaque manner between a vendor application and HAL.
227 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800228 * Multiple parameters can be retrieved at the same time.
229 * The implementation should return as many requested parameters
230 * as possible, even if one or more is not supported
231 *
232 * @param context provides more information about the request
233 * @param keys keys of the requested parameters
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800234 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800235 * OK must be returned if keys is empty.
236 * NOT_SUPPORTED must be returned if at least one key is unknown.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800237 * @return parameters parameter key value pairs.
Kevin Rocard74980b52018-01-20 22:12:57 -0800238 * Must contain the value of all requested keys if retval == OK
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800239 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800240 getParameters(vec<ParameterValue> context, vec<string> keys)
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800241 generates (Result retval, vec<ParameterValue> parameters);
242
243 /**
244 * Generic method for setting vendor-specific parameter values.
245 * The framework does not interpret the parameters, they are passed
246 * in an opaque manner between a vendor application and HAL.
247 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800248 * Multiple parameters can be set at the same time though this is
249 * discouraged as it make failure analysis harder.
250 *
251 * If possible, a failed setParameters should not impact the platform state.
252 *
253 * @param context provides more information about the request
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800254 * @param parameters parameter key value pairs.
255 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800256 * All parameters must be successfully set for OK to be returned
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800257 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800258 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
259 generates (Result retval);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800260
261 /**
262 * Dumps information about the stream into the provided file descriptor.
263 * This is used for the dumpsys facility.
Kevin Rocard74980b52018-01-20 22:12:57 -0800264 * The implementation should not block as the caller might have time
265 * constraint on the dump.
266 * A back to back dump of all HAL Device and Stream should take under 100ms.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800267 *
268 * @param fd dump file descriptor.
Kevin Rocard74980b52018-01-20 22:12:57 -0800269 * @return retval operation completion status: OK or NOT_SUPPORTED.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800270 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800271 debugDump(handle fd) generates (Result retval);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800272
273 /**
274 * Called by the framework to start a stream operating in mmap mode.
275 * createMmapBuffer() must be called before calling start().
276 * Function only implemented by streams operating in mmap mode.
277 *
278 * @return retval OK in case the success.
279 * NOT_SUPPORTED on non mmap mode streams
280 * INVALID_STATE if called out of sequence
281 */
282 start() generates (Result retval);
283
284 /**
285 * Called by the framework to stop a stream operating in mmap mode.
286 * Function only implemented by streams operating in mmap mode.
287 *
288 * @return retval OK in case the succes.
289 * NOT_SUPPORTED on non mmap mode streams
290 * INVALID_STATE if called out of sequence
291 */
292 stop() generates (Result retval) ;
293
294 /**
295 * Called by the framework to retrieve information on the mmap buffer used for audio
296 * samples transfer.
297 * Function only implemented by streams operating in mmap mode.
298 *
299 * @param minSizeFrames minimum buffer size requested. The actual buffer
300 * size returned in struct MmapBufferInfo can be larger.
301 * @return retval OK in case the success.
302 * NOT_SUPPORTED on non mmap mode streams
303 * NOT_INITIALIZED in case of memory allocation error
304 * INVALID_ARGUMENTS if the requested buffer size is too large
305 * INVALID_STATE if called out of sequence
306 * @return info a MmapBufferInfo struct containing information on the MMMAP buffer created.
307 */
308 createMmapBuffer(int32_t minSizeFrames)
309 generates (Result retval, MmapBufferInfo info);
310
311 /**
312 * Called by the framework to read current read/write position in the mmap buffer
313 * with associated time stamp.
314 * Function only implemented by streams operating in mmap mode.
315 *
316 * @return retval OK in case the success.
317 * NOT_SUPPORTED on non mmap mode streams
318 * INVALID_STATE if called out of sequence
319 * @return position a MmapPosition struct containing current HW read/write position in frames
320 * with associated time stamp.
321 */
322 getMmapPosition()
323 generates (Result retval, MmapPosition position);
324
325 /**
326 * Called by the framework to deinitialize the stream and free up
327 * all the currently allocated resources. It is recommended to close
328 * the stream on the client side as soon as it is becomes unused.
329 *
330 * @return retval OK in case the success.
331 * NOT_SUPPORTED if called on IStream instead of input or
332 * output stream interface.
333 * INVALID_STATE if the stream was already closed.
334 */
335 close() generates (Result retval);
336};