blob: d9e0ad205f0da8eba28ec836c4af6355b2b0f288 [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 IStreamIn;
21import IStreamOut;
22
23interface IDevice {
24 /**
25 * Returns whether the audio hardware interface has been initialized.
26 *
27 * @return retval OK on success, NOT_INITIALIZED on failure.
28 */
29 initCheck() generates (Result retval);
30
31 /**
32 * Sets the audio volume for all audio activities other than voice call. If
33 * NOT_SUPPORTED is returned, the software mixer will emulate this
34 * capability.
35 *
36 * @param volume 1.0f means unity, 0.0f is zero.
37 * @return retval operation completion status.
38 */
39 setMasterVolume(float volume) generates (Result retval);
40
41 /**
42 * Get the current master volume value for the HAL, if the HAL supports
43 * master volume control. For example, AudioFlinger will query this value
44 * from the primary audio HAL when the service starts and use the value for
45 * setting the initial master volume across all HALs. HALs which do not
46 * support this method must return NOT_SUPPORTED in 'retval'.
47 *
48 * @return retval operation completion status.
49 * @return volume 1.0f means unity, 0.0f is zero.
50 */
51 getMasterVolume() generates (Result retval, float volume);
52
53 /**
54 * Sets microphone muting state.
55 *
56 * @param mute whether microphone is muted.
57 * @return retval operation completion status.
58 */
59 setMicMute(bool mute) generates (Result retval);
60
61 /**
62 * Gets whether microphone is muted.
63 *
64 * @return retval operation completion status.
65 * @return mute whether microphone is muted.
66 */
67 getMicMute() generates (Result retval, bool mute);
68
69 /**
70 * Set the audio mute status for all audio activities. If the return value
71 * is NOT_SUPPORTED, the software mixer will emulate this capability.
72 *
73 * @param mute whether audio is muted.
74 * @return retval operation completion status.
75 */
76 setMasterMute(bool mute) generates (Result retval);
77
78 /**
79 * Get the current master mute status for the HAL, if the HAL supports
80 * master mute control. AudioFlinger will query this value from the primary
81 * audio HAL when the service starts and use the value for setting the
82 * initial master mute across all HALs. HAL must indicate that the feature
83 * is not supported by returning NOT_SUPPORTED status.
84 *
85 * @return retval operation completion status.
86 * @return mute whether audio is muted.
87 */
88 getMasterMute() generates (Result retval, bool mute);
89
90 /**
91 * Returns audio input buffer size according to parameters passed or
92 * INVALID_ARGUMENTS if one of the parameters is not supported.
93 *
94 * @param config audio configuration.
95 * @return retval operation completion status.
96 * @return bufferSize input buffer size in bytes.
97 */
98 getInputBufferSize(AudioConfig config)
99 generates (Result retval, uint64_t bufferSize);
100
101 /**
102 * This method creates and opens the audio hardware output stream.
103 * If the stream can not be opened with the proposed audio config,
104 * HAL must provide suggested values for the audio config.
105 *
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800106 * Note: INVALID_ARGUMENTS is returned both in the case when the
107 * HAL can not use the provided config and in the case when
108 * the value of any argument is invalid. In the latter case the
109 * HAL must provide a default initialized suggested config.
110 *
Mikhail Naganov60ced762020-07-23 18:08:26 +0000111 * @param ioHandle handle assigned by AudioFlinger.
112 * @param device device type and (if needed) address.
113 * @param config stream configuration.
114 * @param flags additional flags.
115 * @param sourceMetadata Description of the audio that will be played.
116 May be used by implementations to configure hardware effects.
117 * @return retval operation completion status.
118 * @return outStream created output stream.
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800119 * @return suggestedConfig in the case of rejection of the proposed config,
120 * a config suggested by the HAL.
Mikhail Naganov60ced762020-07-23 18:08:26 +0000121 */
122 openOutputStream(
123 AudioIoHandle ioHandle,
124 DeviceAddress device,
125 AudioConfig config,
Mikhail Naganov355dd062020-09-24 18:00:44 +0000126 vec<AudioInOutFlag> flags,
Mikhail Naganov60ced762020-07-23 18:08:26 +0000127 SourceMetadata sourceMetadata) generates (
128 Result retval,
129 IStreamOut outStream,
130 AudioConfig suggestedConfig);
131
132 /**
133 * This method creates and opens the audio hardware input stream.
134 * If the stream can not be opened with the proposed audio config,
135 * HAL must provide suggested values for the audio config.
136 *
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800137 * Note: INVALID_ARGUMENTS is returned both in the case when the
138 * HAL can not use the provided config and in the case when
139 * the value of any argument is invalid. In the latter case the
140 * HAL must provide a default initialized suggested config.
141 *
Mikhail Naganov60ced762020-07-23 18:08:26 +0000142 * @param ioHandle handle assigned by AudioFlinger.
143 * @param device device type and (if needed) address.
144 * @param config stream configuration.
145 * @param flags additional flags.
146 * @param sinkMetadata Description of the audio that is suggested by the client.
147 * May be used by implementations to configure processing effects.
148 * @return retval operation completion status.
149 * @return inStream in case of success, created input stream.
Mikhail Naganov3f1457b2020-12-17 15:01:54 -0800150 * @return suggestedConfig in the case of rejection of the proposed config,
151 * a config suggested by the HAL.
Mikhail Naganov60ced762020-07-23 18:08:26 +0000152 */
153 openInputStream(
154 AudioIoHandle ioHandle,
155 DeviceAddress device,
156 AudioConfig config,
Mikhail Naganov355dd062020-09-24 18:00:44 +0000157 vec<AudioInOutFlag> flags,
Mikhail Naganov60ced762020-07-23 18:08:26 +0000158 SinkMetadata sinkMetadata) generates (
159 Result retval,
160 IStreamIn inStream,
161 AudioConfig suggestedConfig);
162
163 /**
164 * Returns whether HAL supports audio patches. Patch represents a connection
165 * between signal source(s) and signal sink(s). If HAL doesn't support
166 * patches natively (in hardware) then audio system will need to establish
167 * them in software.
168 *
169 * @return supports true if audio patches are supported.
170 */
171 supportsAudioPatches() generates (bool supports);
172
173 /**
174 * Creates an audio patch between several source and sink ports. The handle
175 * is allocated by the HAL and must be unique for this audio HAL module.
176 *
177 * @param sources patch sources.
178 * @param sinks patch sinks.
179 * @return retval operation completion status.
180 * @return patch created patch handle.
181 */
182 createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks)
183 generates (Result retval, AudioPatchHandle patch);
184
185 /**
186 * Updates an audio patch.
187 *
188 * Use of this function is preferred to releasing and re-creating a patch
189 * as the HAL module can figure out a way of switching the route without
190 * causing audio disruption.
191 *
192 * @param previousPatch handle of the previous patch to update.
193 * @param sources new patch sources.
194 * @param sinks new patch sinks.
195 * @return retval operation completion status.
196 * @return patch updated patch handle.
197 */
198 updateAudioPatch(
199 AudioPatchHandle previousPatch,
200 vec<AudioPortConfig> sources,
201 vec<AudioPortConfig> sinks) generates (
202 Result retval, AudioPatchHandle patch);
203
204 /**
205 * Release an audio patch.
206 *
207 * @param patch patch handle.
208 * @return retval operation completion status.
209 */
210 releaseAudioPatch(AudioPatchHandle patch) generates (Result retval);
211
212 /**
213 * Returns the list of supported attributes for a given audio port.
214 *
215 * As input, 'port' contains the information (type, role, address etc...)
216 * needed by the HAL to identify the port.
217 *
218 * As output, 'resultPort' contains possible attributes (sampling rates,
219 * formats, channel masks, gain controllers...) for this port.
220 *
221 * @param port port identifier.
222 * @return retval operation completion status.
223 * @return resultPort port descriptor with all parameters filled up.
224 */
225 getAudioPort(AudioPort port)
226 generates (Result retval, AudioPort resultPort);
227
228 /**
229 * Set audio port configuration.
230 *
231 * @param config audio port configuration.
232 * @return retval operation completion status.
233 */
234 setAudioPortConfig(AudioPortConfig config) generates (Result retval);
235
236 /**
237 * Gets the HW synchronization source of the device. Calling this method is
238 * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL.
239 * Optional method
240 *
241 * @return retval operation completion status: OK or NOT_SUPPORTED.
242 * @return hwAvSync HW synchronization source
243 */
244 getHwAvSync() generates (Result retval, AudioHwSync hwAvSync);
245
246 /**
247 * Sets whether the screen is on. Calling this method is equivalent to
248 * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL.
249 * Optional method
250 *
251 * @param turnedOn whether the screen is turned on.
252 * @return retval operation completion status.
253 */
254 setScreenState(bool turnedOn) generates (Result retval);
255
256 /**
257 * Generic method for retrieving vendor-specific parameter values.
258 * The framework does not interpret the parameters, they are passed
259 * in an opaque manner between a vendor application and HAL.
260 *
261 * Multiple parameters can be retrieved at the same time.
262 * The implementation should return as many requested parameters
263 * as possible, even if one or more is not supported
264 *
265 * @param context provides more information about the request
266 * @param keys keys of the requested parameters
267 * @return retval operation completion status.
268 * OK must be returned if keys is empty.
269 * NOT_SUPPORTED must be returned if at least one key is unknown.
270 * @return parameters parameter key value pairs.
271 * Must contain the value of all requested keys if retval == OK
272 */
273 getParameters(vec<ParameterValue> context, vec<string> keys)
274 generates (Result retval, vec<ParameterValue> parameters);
275
276 /**
277 * Generic method for setting vendor-specific parameter values.
278 * The framework does not interpret the parameters, they are passed
279 * in an opaque manner between a vendor application and HAL.
280 *
281 * Multiple parameters can be set at the same time though this is
282 * discouraged as it make failure analysis harder.
283 *
284 * If possible, a failed setParameters should not impact the platform state.
285 *
286 * @param context provides more information about the request
287 * @param parameters parameter key value pairs.
288 * @return retval operation completion status.
289 * All parameters must be successfully set for OK to be returned
290 */
291 setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters)
292 generates (Result retval);
293
294 /**
295 * Returns an array with available microphones in device.
296 *
297 * @return retval NOT_SUPPORTED if there are no microphones on this device
298 * INVALID_STATE if the call is not successful,
299 * OK otherwise.
300 *
301 * @return microphones array with microphones info
302 */
303 getMicrophones()
304 generates(Result retval, vec<MicrophoneInfo> microphones);
305
306 /**
307 * Notifies the device module about the connection state of an input/output
308 * device attached to it. Calling this method is equivalent to setting
309 * AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL.
310 *
311 * @param address audio device specification.
312 * @param connected whether the device is connected.
313 * @return retval operation completion status.
314 */
315 setConnectedState(DeviceAddress address, bool connected)
316 generates (Result retval);
317
318 /**
319 * Called by the framework to deinitialize the device and free up
320 * all currently allocated resources. It is recommended to close
321 * the device on the client side as soon as it is becomes unused.
322 *
323 * Note that all streams must be closed by the client before
324 * attempting to close the device they belong to.
325 *
326 * @return retval OK in case the success.
327 * INVALID_STATE if the device was already closed
328 * or there are streams currently opened.
329 */
Mikhail Naganov60ced762020-07-23 18:08:26 +0000330 close() generates (Result retval);
331
332 /**
333 * Applies an audio effect to an audio device. The effect is inserted
334 * according to its insertion preference specified by INSERT_... EffectFlags
335 * in the EffectDescriptor.
336 *
337 * @param device identifies the sink or source device this effect must be applied to.
338 * "device" is the AudioPortHandle indicated for the device when the audio
339 * patch connecting that device was created.
340 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
341 * the effect to add.
342 * @return retval operation completion status.
343 */
344 addDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval);
345
346 /**
347 * Stops applying an audio effect to an audio device.
348 *
349 * @param device identifies the sink or source device this effect was applied to.
350 * "device" is the AudioPortHandle indicated for the device when the audio
351 * patch is created at the audio HAL.
352 * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
353 * the effect.
354 * @return retval operation completion status.
355 */
356 removeDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval);
357};