blob: e7a4b7db954093d6b969ffc39164a82da1fa83a3 [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 {
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080023 /**
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 Rocard74980b52018-01-20 22:12:57 -080054 * 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 Rocarda4e6d8b2018-01-20 21:52:01 -080057 *
Kevin Rocard74980b52018-01-20 22:12:57 -080058 * 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 Rocarda4e6d8b2018-01-20 21:52:01 -080069 * @return sampleRateHz supported sample rates.
70 */
Kevin Rocard74980b52018-01-20 22:12:57 -080071 getSupportedSampleRates(AudioFormat format)
72 generates (Result retval, vec<uint32_t> sampleRates);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080073
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 Rocard74980b52018-01-20 22:12:57 -080077 * Optional method. If implemented, only called on a stopped stream.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080078 *
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 Rocard79c57402018-01-24 10:02:30 -080089 getChannelMask() generates (bitfield<AudioChannelMask> mask);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -080090
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 Rocard74980b52018-01-20 22:12:57 -080096 * @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 Rocarda4e6d8b2018-01-20 21:52:01 -080099 * @return masks supported audio masks.
100 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800101 getSupportedChannelMasks(AudioFormat format)
Kevin Rocard79c57402018-01-24 10:02:30 -0800102 generates (Result retval, vec<bitfield<AudioChannelMask>> masks);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800103
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 Rocard74980b52018-01-20 22:12:57 -0800107 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800108 *
109 * @param format audio format.
110 * @return retval operation completion status.
111 */
Kevin Rocard79c57402018-01-24 10:02:30 -0800112 setChannelMask(bitfield<AudioChannelMask> mask) generates (Result retval);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800113
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 Rocard74980b52018-01-20 22:12:57 -0800133 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800134 *
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 Rocard79c57402018-01-24 10:02:30 -0800149 uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800150
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 Naganovb2f1c0f2018-02-13 09:13:20 -0800178 * Return the set of devices which this stream is connected to.
Kevin Rocard74980b52018-01-20 22:12:57 -0800179 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800180 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800181 * @return retval operation completion status: OK or NOT_SUPPORTED.
Mikhail Naganovb2f1c0f2018-02-13 09:13:20 -0800182 * @return device set of devices which this stream is connected to.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800183 */
Mikhail Naganovb2f1c0f2018-02-13 09:13:20 -0800184 getDevices() generates (Result retval, vec<DeviceAddress> devices);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800185
186 /**
Mikhail Naganovb2f1c0f2018-02-13 09:13:20 -0800187 * Connects the stream to one or multiple devices.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800188 *
189 * This method must only be used for HALs that do not support
190 * 'IDevice.createAudioPatch' method. Calling this method is
Mikhail Naganovb2f1c0f2018-02-13 09:13:20 -0800191 * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceeded
192 * with a device address in the legacy HAL interface.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800193 *
194 * @param address device to connect the stream to.
195 * @return retval operation completion status.
196 */
Mikhail Naganovb2f1c0f2018-02-13 09:13:20 -0800197 setDevices(vec<DeviceAddress> devices) generates (Result retval);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800198
199 /**
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800200 * Sets the HW synchronization source. Calling this method is equivalent to
201 * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800202 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800203 *
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 Rocard74980b52018-01-20 22:12:57 -0800214 * 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 Rocarda4e6d8b2018-01-20 21:52:01 -0800220 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800221 * OK must be returned if keys is empty.
222 * NOT_SUPPORTED must be returned if at least one key is unknown.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800223 * @return parameters parameter key value pairs.
Kevin Rocard74980b52018-01-20 22:12:57 -0800224 * Must contain the value of all requested keys if retval == OK
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800225 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800226 getParameters(vec<ParameterValue> context, vec<string> keys)
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800227 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 Rocard74980b52018-01-20 22:12:57 -0800234 * 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 Rocarda4e6d8b2018-01-20 21:52:01 -0800240 * @param parameters parameter key value pairs.
241 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800242 * All parameters must be successfully set for OK to be returned
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800243 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800244 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
245 generates (Result retval);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800246
247 /**
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800248 * 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};