blob: 393e38f6a029f721f420bf5d4061b744878dbbe0 [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 Naganov355dd062020-09-24 18:00:44 +000047 * Return supported audio profiles for this particular stream. This method
48 * is normally called for streams opened on devices that use dynamic
49 * profiles, e.g. HDMI and USB interfaces. Please note that supported
50 * profiles of the stream may differ from the capabilities of the connected
51 * physical device.
Mikhail Naganov60ced762020-07-23 18:08:26 +000052 *
Mikhail Naganov355dd062020-09-24 18:00:44 +000053 * For devices with fixed configurations, e.g. built-in audio devices, all
54 * the profiles are specified in the audio_policy_configuration.xml
55 * file. For such devices, this method must return the configuration from
56 * the config file, or NOT_SUPPORTED retval.
Mikhail Naganov60ced762020-07-23 18:08:26 +000057 *
58 * @return retval operation completion status.
Mikhail Naganov355dd062020-09-24 18:00:44 +000059 * @return formats supported audio profiles.
Mikhail Naganov60ced762020-07-23 18:08:26 +000060 * Must be non empty if retval is OK.
61 */
Mikhail Naganov355dd062020-09-24 18:00:44 +000062 getSupportedProfiles()
63 generates (Result retval, vec<AudioProfile> profiles);
Mikhail Naganov60ced762020-07-23 18:08:26 +000064
65 /**
Mikhail Naganovfda20422020-08-04 23:37:05 +000066 * Retrieves basic stream configuration: sample rate, audio format,
67 * channel mask.
Mikhail Naganov60ced762020-07-23 18:08:26 +000068 *
Mikhail Naganove1a9c8f2020-12-10 17:25:40 -080069 * @return retval operation completion status.
Mikhail Naganovfda20422020-08-04 23:37:05 +000070 * @return config basic stream configuration.
Mikhail Naganov60ced762020-07-23 18:08:26 +000071 */
Mikhail Naganove1a9c8f2020-12-10 17:25:40 -080072 getAudioProperties() generates (Result retval, AudioConfigBase config);
Mikhail Naganov60ced762020-07-23 18:08:26 +000073
74 /**
Mikhail Naganovfda20422020-08-04 23:37:05 +000075 * Sets stream parameters. Only sets parameters that are specified.
Mikhail Naganov60ced762020-07-23 18:08:26 +000076 *
Mikhail Naganovfda20422020-08-04 23:37:05 +000077 * Optional method. If implemented, only called on a stopped stream.
78 *
79 * @param config basic stream configuration.
80 * @return retval operation completion status.
Mikhail Naganov60ced762020-07-23 18:08:26 +000081 */
Mikhail Naganovff611982021-01-27 02:16:53 +000082 setAudioProperties(AudioConfigBaseOptional config)
83 generates (Result retval);
Mikhail Naganov60ced762020-07-23 18:08:26 +000084
85 /**
86 * Applies audio effect to the stream.
87 *
88 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
89 * the effect to apply.
90 * @return retval operation completion status.
91 */
92 addEffect(uint64_t effectId) generates (Result retval);
93
94 /**
95 * Stops application of the effect to the stream.
96 *
97 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
98 * the effect to remove.
99 * @return retval operation completion status.
100 */
101 removeEffect(uint64_t effectId) generates (Result retval);
102
103 /**
104 * Put the audio hardware input/output into standby mode.
105 * Driver must exit from standby mode at the next I/O operation.
106 *
107 * @return retval operation completion status.
108 */
109 standby() generates (Result retval);
110
111 /**
112 * Return the set of devices which this stream is connected to.
113 * Optional method
114 *
115 * @return retval operation completion status: OK or NOT_SUPPORTED.
116 * @return device set of devices which this stream is connected to.
117 */
118 getDevices() generates (Result retval, vec<DeviceAddress> devices);
119
120 /**
121 * Connects the stream to one or multiple devices.
122 *
123 * This method must only be used for HALs that do not support
124 * 'IDevice.createAudioPatch' method. Calling this method is
125 * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceded
126 * with a device address in the legacy HAL interface.
127 *
128 * @param address device to connect the stream to.
129 * @return retval operation completion status.
130 */
131 setDevices(vec<DeviceAddress> devices) generates (Result retval);
132
133 /**
134 * Sets the HW synchronization source. Calling this method is equivalent to
135 * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.
136 * Optional method
137 *
138 * @param hwAvSync HW synchronization source
139 * @return retval operation completion status.
140 */
141 setHwAvSync(AudioHwSync hwAvSync) generates (Result retval);
142
143 /**
144 * Generic method for retrieving vendor-specific parameter values.
145 * The framework does not interpret the parameters, they are passed
146 * in an opaque manner between a vendor application and HAL.
147 *
148 * Multiple parameters can be retrieved at the same time.
149 * The implementation should return as many requested parameters
150 * as possible, even if one or more is not supported
151 *
152 * @param context provides more information about the request
153 * @param keys keys of the requested parameters
154 * @return retval operation completion status.
155 * OK must be returned if keys is empty.
156 * NOT_SUPPORTED must be returned if at least one key is unknown.
157 * @return parameters parameter key value pairs.
158 * Must contain the value of all requested keys if retval == OK
159 */
160 getParameters(vec<ParameterValue> context, vec<string> keys)
161 generates (Result retval, vec<ParameterValue> parameters);
162
163 /**
164 * Generic method for setting vendor-specific parameter values.
165 * The framework does not interpret the parameters, they are passed
166 * in an opaque manner between a vendor application and HAL.
167 *
168 * Multiple parameters can be set at the same time though this is
169 * discouraged as it make failure analysis harder.
170 *
171 * If possible, a failed setParameters should not impact the platform state.
172 *
173 * @param context provides more information about the request
174 * @param parameters parameter key value pairs.
175 * @return retval operation completion status.
176 * All parameters must be successfully set for OK to be returned
177 */
178 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
179 generates (Result retval);
180
181 /**
182 * Called by the framework to start a stream operating in mmap mode.
183 * createMmapBuffer() must be called before calling start().
184 * Function only implemented by streams operating in mmap mode.
185 *
186 * @return retval OK in case the success.
187 * NOT_SUPPORTED on non mmap mode streams
188 * INVALID_STATE if called out of sequence
189 */
190 start() generates (Result retval);
191
192 /**
193 * Called by the framework to stop a stream operating in mmap mode.
194 * Function only implemented by streams operating in mmap mode.
195 *
196 * @return retval OK in case the success.
197 * NOT_SUPPORTED on non mmap mode streams
198 * INVALID_STATE if called out of sequence
199 */
200 stop() generates (Result retval) ;
201
202 /**
203 * Called by the framework to retrieve information on the mmap buffer used for audio
204 * samples transfer.
205 * Function only implemented by streams operating in mmap mode.
206 *
207 * @param minSizeFrames minimum buffer size requested. The actual buffer
208 * size returned in struct MmapBufferInfo can be larger.
209 * The size must be a positive value.
210 * @return retval OK in case the success.
211 * NOT_SUPPORTED on non mmap mode streams
212 * NOT_INITIALIZED in case of memory allocation error
213 * INVALID_ARGUMENTS if the requested buffer size is invalid
214 * INVALID_STATE if called out of sequence
215 * @return info a MmapBufferInfo struct containing information on the MMMAP buffer created.
216 */
217 createMmapBuffer(int32_t minSizeFrames)
218 generates (Result retval, MmapBufferInfo info);
219
220 /**
221 * Called by the framework to read current read/write position in the mmap buffer
222 * with associated time stamp.
223 * Function only implemented by streams operating in mmap mode.
224 *
225 * @return retval OK in case the success.
226 * NOT_SUPPORTED on non mmap mode streams
227 * INVALID_STATE if called out of sequence
228 * @return position a MmapPosition struct containing current HW read/write position in frames
229 * with associated time stamp.
230 */
231 getMmapPosition()
232 generates (Result retval, MmapPosition position);
233
234 /**
235 * Called by the framework to deinitialize the stream and free up
236 * all currently allocated resources. It is recommended to close
237 * the stream on the client side as soon as it is becomes unused.
238 *
239 * The client must ensure that this function is not called while
240 * audio data is being transferred through the stream's message queues.
241 *
242 * @return retval OK in case the success.
243 * NOT_SUPPORTED if called on IStream instead of input or
244 * output stream interface.
245 * INVALID_STATE if the stream was already closed.
246 */
Mikhail Naganov60ced762020-07-23 18:08:26 +0000247 close() generates (Result retval);
248};