blob: f05d7b04faa9a07f17a8733406c9308e4a978ca3 [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 /**
178 * Return the set of device(s) 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.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800182 * @return device set of device(s) which this stream is connected to.
183 */
Kevin Rocard79c57402018-01-24 10:02:30 -0800184 getDevice() generates (Result retval, bitfield<AudioDevice> device);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800185
186 /**
187 * Connects the stream to the device.
188 *
189 * This method must only be used for HALs that do not support
190 * 'IDevice.createAudioPatch' method. Calling this method is
191 * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING in the legacy HAL
192 * interface.
193 *
194 * @param address device to connect the stream to.
195 * @return retval operation completion status.
196 */
197 setDevice(DeviceAddress address) generates (Result retval);
198
199 /**
200 * Notifies the stream about device connection state. Calling this method is
201 * equivalent to setting AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy
202 * HAL.
203 *
204 * @param address audio device specification.
205 * @param connected whether the device is connected.
206 * @return retval operation completion status.
207 */
208 setConnectedState(DeviceAddress address, bool connected)
209 generates (Result retval);
210
211 /**
212 * Sets the HW synchronization source. Calling this method is equivalent to
213 * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.
Kevin Rocard74980b52018-01-20 22:12:57 -0800214 * Optional method
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800215 *
216 * @param hwAvSync HW synchronization source
217 * @return retval operation completion status.
218 */
219 setHwAvSync(AudioHwSync hwAvSync) generates (Result retval);
220
221 /**
222 * Generic method for retrieving vendor-specific parameter values.
223 * The framework does not interpret the parameters, they are passed
224 * in an opaque manner between a vendor application and HAL.
225 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800226 * Multiple parameters can be retrieved at the same time.
227 * The implementation should return as many requested parameters
228 * as possible, even if one or more is not supported
229 *
230 * @param context provides more information about the request
231 * @param keys keys of the requested parameters
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800232 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800233 * OK must be returned if keys is empty.
234 * NOT_SUPPORTED must be returned if at least one key is unknown.
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800235 * @return parameters parameter key value pairs.
Kevin Rocard74980b52018-01-20 22:12:57 -0800236 * Must contain the value of all requested keys if retval == OK
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800237 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800238 getParameters(vec<ParameterValue> context, vec<string> keys)
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800239 generates (Result retval, vec<ParameterValue> parameters);
240
241 /**
242 * Generic method for setting vendor-specific parameter values.
243 * The framework does not interpret the parameters, they are passed
244 * in an opaque manner between a vendor application and HAL.
245 *
Kevin Rocard74980b52018-01-20 22:12:57 -0800246 * Multiple parameters can be set at the same time though this is
247 * discouraged as it make failure analysis harder.
248 *
249 * If possible, a failed setParameters should not impact the platform state.
250 *
251 * @param context provides more information about the request
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800252 * @param parameters parameter key value pairs.
253 * @return retval operation completion status.
Kevin Rocard74980b52018-01-20 22:12:57 -0800254 * All parameters must be successfully set for OK to be returned
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800255 */
Kevin Rocard74980b52018-01-20 22:12:57 -0800256 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
257 generates (Result retval);
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800258
259 /**
Kevin Rocarda4e6d8b2018-01-20 21:52:01 -0800260 * Called by the framework to start a stream operating in mmap mode.
261 * createMmapBuffer() must be called before calling start().
262 * Function only implemented by streams operating in mmap mode.
263 *
264 * @return retval OK in case the success.
265 * NOT_SUPPORTED on non mmap mode streams
266 * INVALID_STATE if called out of sequence
267 */
268 start() generates (Result retval);
269
270 /**
271 * Called by the framework to stop a stream operating in mmap mode.
272 * Function only implemented by streams operating in mmap mode.
273 *
274 * @return retval OK in case the succes.
275 * NOT_SUPPORTED on non mmap mode streams
276 * INVALID_STATE if called out of sequence
277 */
278 stop() generates (Result retval) ;
279
280 /**
281 * Called by the framework to retrieve information on the mmap buffer used for audio
282 * samples transfer.
283 * Function only implemented by streams operating in mmap mode.
284 *
285 * @param minSizeFrames minimum buffer size requested. The actual buffer
286 * size returned in struct MmapBufferInfo can be larger.
287 * @return retval OK in case the success.
288 * NOT_SUPPORTED on non mmap mode streams
289 * NOT_INITIALIZED in case of memory allocation error
290 * INVALID_ARGUMENTS if the requested buffer size is too large
291 * INVALID_STATE if called out of sequence
292 * @return info a MmapBufferInfo struct containing information on the MMMAP buffer created.
293 */
294 createMmapBuffer(int32_t minSizeFrames)
295 generates (Result retval, MmapBufferInfo info);
296
297 /**
298 * Called by the framework to read current read/write position in the mmap buffer
299 * with associated time stamp.
300 * Function only implemented by streams operating in mmap mode.
301 *
302 * @return retval OK in case the success.
303 * NOT_SUPPORTED on non mmap mode streams
304 * INVALID_STATE if called out of sequence
305 * @return position a MmapPosition struct containing current HW read/write position in frames
306 * with associated time stamp.
307 */
308 getMmapPosition()
309 generates (Result retval, MmapPosition position);
310
311 /**
312 * Called by the framework to deinitialize the stream and free up
313 * all the currently allocated resources. It is recommended to close
314 * the stream on the client side as soon as it is becomes unused.
315 *
316 * @return retval OK in case the success.
317 * NOT_SUPPORTED if called on IStream instead of input or
318 * output stream interface.
319 * INVALID_STATE if the stream was already closed.
320 */
321 close() generates (Result retval);
322};