blob: 789cb1dfd1a042a88da1feccd76ad5714b985eb5 [file] [log] [blame]
Mikhail Naganov60ced762020-07-23 18:08:26 +00001/*
2 * Copyright (C) 2020 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@7.0;
18
19import android.hardware.audio.common@7.0;
20import android.hardware.audio.effect@7.0::IEffect;
21
22interface IStream {
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 /**
Mikhail Naganov60ced762020-07-23 18:08:26 +000047 * Return supported native sampling rates of the stream for a given format.
48 * A supported native sample rate is a sample rate that can be efficiently
49 * played by the hardware (typically without sample-rate conversions).
50 *
51 * This function is only called for dynamic profile. If called for
52 * non-dynamic profile is should return NOT_SUPPORTED or the same list
53 * as in audio_policy_configuration.xml.
54 *
55 * Calling this method is equivalent to getting
56 * AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL.
57 *
58 *
59 * @param format audio format for which the sample rates are supported.
60 * @return retval operation completion status.
61 * Must be OK if the format is supported.
62 * @return sampleRateHz supported sample rates.
63 */
64 getSupportedSampleRates(AudioFormat format)
65 generates (Result retval, vec<uint32_t> sampleRates);
66
67 /**
Mikhail Naganov60ced762020-07-23 18:08:26 +000068 * Return supported channel masks of the stream. Calling this method is
69 * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy
70 * HAL.
71 *
72 * @param format audio format for which the channel masks are supported.
73 * @return retval operation completion status.
74 * Must be OK if the format is supported.
75 * @return masks supported audio masks.
76 */
77 getSupportedChannelMasks(AudioFormat format)
Mikhail Naganovfda20422020-08-04 23:37:05 +000078 generates (Result retval, vec<vec<AudioChannelMask>> masks);
Mikhail Naganov60ced762020-07-23 18:08:26 +000079
80 /**
81 * Return supported audio formats of the stream. Calling this method is
82 * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy
83 * HAL.
84 *
85 * @return retval operation completion status.
86 * @return formats supported audio formats.
87 * Must be non empty if retval is OK.
88 */
89 getSupportedFormats() generates (Result retval, vec<AudioFormat> formats);
90
91 /**
Mikhail Naganovfda20422020-08-04 23:37:05 +000092 * Retrieves basic stream configuration: sample rate, audio format,
93 * channel mask.
Mikhail Naganov60ced762020-07-23 18:08:26 +000094 *
Mikhail Naganovfda20422020-08-04 23:37:05 +000095 * @return config basic stream configuration.
Mikhail Naganov60ced762020-07-23 18:08:26 +000096 */
Mikhail Naganovfda20422020-08-04 23:37:05 +000097 getAudioProperties() generates (AudioBasicConfig config);
Mikhail Naganov60ced762020-07-23 18:08:26 +000098
99 /**
Mikhail Naganovfda20422020-08-04 23:37:05 +0000100 * Sets stream parameters. Only sets parameters that are specified.
101 * See the description of AudioBasicConfig for the details.
Mikhail Naganov60ced762020-07-23 18:08:26 +0000102 *
Mikhail Naganovfda20422020-08-04 23:37:05 +0000103 * Optional method. If implemented, only called on a stopped stream.
104 *
105 * @param config basic stream configuration.
106 * @return retval operation completion status.
Mikhail Naganov60ced762020-07-23 18:08:26 +0000107 */
Mikhail Naganovfda20422020-08-04 23:37:05 +0000108 setAudioProperties(AudioBasicConfig config) generates (Result retval);
Mikhail Naganov60ced762020-07-23 18:08:26 +0000109
110 /**
111 * Applies audio effect to the stream.
112 *
113 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
114 * the effect to apply.
115 * @return retval operation completion status.
116 */
117 addEffect(uint64_t effectId) generates (Result retval);
118
119 /**
120 * Stops application of the effect to the stream.
121 *
122 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
123 * the effect to remove.
124 * @return retval operation completion status.
125 */
126 removeEffect(uint64_t effectId) generates (Result retval);
127
128 /**
129 * Put the audio hardware input/output into standby mode.
130 * Driver must exit from standby mode at the next I/O operation.
131 *
132 * @return retval operation completion status.
133 */
134 standby() generates (Result retval);
135
136 /**
137 * Return the set of devices which this stream is connected to.
138 * Optional method
139 *
140 * @return retval operation completion status: OK or NOT_SUPPORTED.
141 * @return device set of devices which this stream is connected to.
142 */
143 getDevices() generates (Result retval, vec<DeviceAddress> devices);
144
145 /**
146 * Connects the stream to one or multiple devices.
147 *
148 * This method must only be used for HALs that do not support
149 * 'IDevice.createAudioPatch' method. Calling this method is
150 * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceded
151 * with a device address in the legacy HAL interface.
152 *
153 * @param address device to connect the stream to.
154 * @return retval operation completion status.
155 */
156 setDevices(vec<DeviceAddress> devices) generates (Result retval);
157
158 /**
159 * Sets the HW synchronization source. Calling this method is equivalent to
160 * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.
161 * Optional method
162 *
163 * @param hwAvSync HW synchronization source
164 * @return retval operation completion status.
165 */
166 setHwAvSync(AudioHwSync hwAvSync) generates (Result retval);
167
168 /**
169 * Generic method for retrieving vendor-specific parameter values.
170 * The framework does not interpret the parameters, they are passed
171 * in an opaque manner between a vendor application and HAL.
172 *
173 * Multiple parameters can be retrieved at the same time.
174 * The implementation should return as many requested parameters
175 * as possible, even if one or more is not supported
176 *
177 * @param context provides more information about the request
178 * @param keys keys of the requested parameters
179 * @return retval operation completion status.
180 * OK must be returned if keys is empty.
181 * NOT_SUPPORTED must be returned if at least one key is unknown.
182 * @return parameters parameter key value pairs.
183 * Must contain the value of all requested keys if retval == OK
184 */
185 getParameters(vec<ParameterValue> context, vec<string> keys)
186 generates (Result retval, vec<ParameterValue> parameters);
187
188 /**
189 * Generic method for setting vendor-specific parameter values.
190 * The framework does not interpret the parameters, they are passed
191 * in an opaque manner between a vendor application and HAL.
192 *
193 * Multiple parameters can be set at the same time though this is
194 * discouraged as it make failure analysis harder.
195 *
196 * If possible, a failed setParameters should not impact the platform state.
197 *
198 * @param context provides more information about the request
199 * @param parameters parameter key value pairs.
200 * @return retval operation completion status.
201 * All parameters must be successfully set for OK to be returned
202 */
203 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
204 generates (Result retval);
205
206 /**
207 * Called by the framework to start a stream operating in mmap mode.
208 * createMmapBuffer() must be called before calling start().
209 * Function only implemented by streams operating in mmap mode.
210 *
211 * @return retval OK in case the success.
212 * NOT_SUPPORTED on non mmap mode streams
213 * INVALID_STATE if called out of sequence
214 */
215 start() generates (Result retval);
216
217 /**
218 * Called by the framework to stop a stream operating in mmap mode.
219 * Function only implemented by streams operating in mmap mode.
220 *
221 * @return retval OK in case the success.
222 * NOT_SUPPORTED on non mmap mode streams
223 * INVALID_STATE if called out of sequence
224 */
225 stop() generates (Result retval) ;
226
227 /**
228 * Called by the framework to retrieve information on the mmap buffer used for audio
229 * samples transfer.
230 * Function only implemented by streams operating in mmap mode.
231 *
232 * @param minSizeFrames minimum buffer size requested. The actual buffer
233 * size returned in struct MmapBufferInfo can be larger.
234 * The size must be a positive value.
235 * @return retval OK in case the success.
236 * NOT_SUPPORTED on non mmap mode streams
237 * NOT_INITIALIZED in case of memory allocation error
238 * INVALID_ARGUMENTS if the requested buffer size is invalid
239 * INVALID_STATE if called out of sequence
240 * @return info a MmapBufferInfo struct containing information on the MMMAP buffer created.
241 */
242 createMmapBuffer(int32_t minSizeFrames)
243 generates (Result retval, MmapBufferInfo info);
244
245 /**
246 * Called by the framework to read current read/write position in the mmap buffer
247 * with associated time stamp.
248 * Function only implemented by streams operating in mmap mode.
249 *
250 * @return retval OK in case the success.
251 * NOT_SUPPORTED on non mmap mode streams
252 * INVALID_STATE if called out of sequence
253 * @return position a MmapPosition struct containing current HW read/write position in frames
254 * with associated time stamp.
255 */
256 getMmapPosition()
257 generates (Result retval, MmapPosition position);
258
259 /**
260 * Called by the framework to deinitialize the stream and free up
261 * all currently allocated resources. It is recommended to close
262 * the stream on the client side as soon as it is becomes unused.
263 *
264 * The client must ensure that this function is not called while
265 * audio data is being transferred through the stream's message queues.
266 *
267 * @return retval OK in case the success.
268 * NOT_SUPPORTED if called on IStream instead of input or
269 * output stream interface.
270 * INVALID_STATE if the stream was already closed.
271 */
Mikhail Naganov60ced762020-07-23 18:08:26 +0000272 close() generates (Result retval);
273};