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