blob: 1493b261e29ed83d03baae71c0259536a5b17860 [file] [log] [blame]
Phil Burk5ed503c2017-02-01 09:38:15 -08001/*
2 * Copyright (C) 2016 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
17/**
Phil Burka45be8b2017-04-05 14:45:48 -070018 * @addtogroup Audio
19 * @{
20 */
21
22/**
23 * @file AAudio.h
24 */
25
26/**
27 * This is the 'C' API for AAudio.
Phil Burk5ed503c2017-02-01 09:38:15 -080028 */
29#ifndef AAUDIO_AAUDIO_H
30#define AAUDIO_AAUDIO_H
31
Phil Burk3316d5e2017-02-15 11:23:01 -080032#include <time.h>
Phil Burk5ed503c2017-02-01 09:38:15 -080033
34#ifdef __cplusplus
35extern "C" {
36#endif
37
Phil Burka4eb0d82017-04-12 15:44:06 -070038/**
39 * This is used to represent a value that has not been specified.
40 * For example, an application could use AAUDIO_UNSPECIFIED to indicate
41 * that is did not not care what the specific value of a parameter was
42 * and would accept whatever it was given.
43 */
44#define AAUDIO_UNSPECIFIED 0
Phil Burka4eb0d82017-04-12 15:44:06 -070045
46enum {
Phil Burk8149eed2018-05-24 14:09:46 -070047 /**
48 * Audio data will travel out of the device, for example through a speaker.
49 */
Phil Burka4eb0d82017-04-12 15:44:06 -070050 AAUDIO_DIRECTION_OUTPUT,
Phil Burk8149eed2018-05-24 14:09:46 -070051
52
53 /**
54 * Audio data will travel into the device, for example from a microphone.
55 */
Phil Burka4eb0d82017-04-12 15:44:06 -070056 AAUDIO_DIRECTION_INPUT
57};
58typedef int32_t aaudio_direction_t;
59
60enum {
61 AAUDIO_FORMAT_INVALID = -1,
62 AAUDIO_FORMAT_UNSPECIFIED = 0,
Phil Burk8149eed2018-05-24 14:09:46 -070063
64 /**
65 * This format uses the int16_t data type.
66 * The maximum range of the data is -32768 to 32767.
67 */
Phil Burka4eb0d82017-04-12 15:44:06 -070068 AAUDIO_FORMAT_PCM_I16,
Phil Burk8149eed2018-05-24 14:09:46 -070069
70 /**
71 * This format uses the float data type.
72 * The nominal range of the data is [-1.0f, 1.0f).
73 * Values outside that range may be clipped.
74 *
75 * See also 'floatData' at
76 * https://developer.android.com/reference/android/media/AudioTrack#write(float[],%20int,%20int,%20int)
77 */
Phil Burk74733452017-04-18 19:50:28 -070078 AAUDIO_FORMAT_PCM_FLOAT
Phil Burka4eb0d82017-04-12 15:44:06 -070079};
80typedef int32_t aaudio_format_t;
81
Phil Burk8149eed2018-05-24 14:09:46 -070082/**
83 * These result codes are returned from AAudio functions to indicate success or failure.
84 * Note that error return codes may change in the future so applications should generally
85 * not rely on specific return codes.
86 */
Phil Burka4eb0d82017-04-12 15:44:06 -070087enum {
Phil Burk8149eed2018-05-24 14:09:46 -070088 /**
89 * The call was successful.
90 */
Phil Burka4eb0d82017-04-12 15:44:06 -070091 AAUDIO_OK,
92 AAUDIO_ERROR_BASE = -900, // TODO review
Phil Burk8149eed2018-05-24 14:09:46 -070093
94 /**
95 * The audio device was disconnected. This could occur, for example, when headphones
96 * are plugged in or unplugged. The stream cannot be used after the device is disconnected.
97 * Applications should stop and close the stream.
98 * If this error is received in an error callback then another thread should be
99 * used to stop and close the stream.
100 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700101 AAUDIO_ERROR_DISCONNECTED,
Phil Burk8149eed2018-05-24 14:09:46 -0700102
103 /**
104 * An invalid parameter was passed to AAudio.
105 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700106 AAUDIO_ERROR_ILLEGAL_ARGUMENT,
Phil Burk17fff382017-05-16 14:06:45 -0700107 // reserved
108 AAUDIO_ERROR_INTERNAL = AAUDIO_ERROR_ILLEGAL_ARGUMENT + 2,
Phil Burk8149eed2018-05-24 14:09:46 -0700109
110 /**
111 * The requested operation is not appropriate for the current state of AAudio.
112 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700113 AAUDIO_ERROR_INVALID_STATE,
Phil Burk17fff382017-05-16 14:06:45 -0700114 // reserved
115 // reserved
Phil Burk8149eed2018-05-24 14:09:46 -0700116 /* The server rejected the handle used to identify the stream.
117 */
Phil Burk17fff382017-05-16 14:06:45 -0700118 AAUDIO_ERROR_INVALID_HANDLE = AAUDIO_ERROR_INVALID_STATE + 3,
119 // reserved
Phil Burk8149eed2018-05-24 14:09:46 -0700120
121 /**
122 * The function is not implemented for this stream.
123 */
Phil Burk17fff382017-05-16 14:06:45 -0700124 AAUDIO_ERROR_UNIMPLEMENTED = AAUDIO_ERROR_INVALID_HANDLE + 2,
Phil Burk8149eed2018-05-24 14:09:46 -0700125
126 /**
127 * A resource or information is unavailable.
128 * This could occur when an application tries to open too many streams,
129 * or a timestamp is not available.
130 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700131 AAUDIO_ERROR_UNAVAILABLE,
132 AAUDIO_ERROR_NO_FREE_HANDLES,
Phil Burk8149eed2018-05-24 14:09:46 -0700133
134 /**
135 * Memory could not be allocated.
136 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700137 AAUDIO_ERROR_NO_MEMORY,
Phil Burk8149eed2018-05-24 14:09:46 -0700138
139 /**
140 * A NULL pointer was passed to AAudio.
141 * Or a NULL pointer was detected internally.
142 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700143 AAUDIO_ERROR_NULL,
Phil Burk8149eed2018-05-24 14:09:46 -0700144
145 /**
146 * An operation took longer than expected.
147 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700148 AAUDIO_ERROR_TIMEOUT,
149 AAUDIO_ERROR_WOULD_BLOCK,
Phil Burk8149eed2018-05-24 14:09:46 -0700150
151 /**
152 * The requested data format is not supported.
153 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700154 AAUDIO_ERROR_INVALID_FORMAT,
Phil Burk8149eed2018-05-24 14:09:46 -0700155
156 /**
157 * A requested was out of range.
158 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700159 AAUDIO_ERROR_OUT_OF_RANGE,
Phil Burk8149eed2018-05-24 14:09:46 -0700160
161 /**
162 * The audio service was not available.
163 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700164 AAUDIO_ERROR_NO_SERVICE,
Phil Burk8149eed2018-05-24 14:09:46 -0700165
166 /**
167 * The requested sample rate was not supported.
168 */
Phil Burka4eb0d82017-04-12 15:44:06 -0700169 AAUDIO_ERROR_INVALID_RATE
170};
171typedef int32_t aaudio_result_t;
172
173enum
174{
175 AAUDIO_STREAM_STATE_UNINITIALIZED = 0,
176 AAUDIO_STREAM_STATE_UNKNOWN,
177 AAUDIO_STREAM_STATE_OPEN,
178 AAUDIO_STREAM_STATE_STARTING,
179 AAUDIO_STREAM_STATE_STARTED,
180 AAUDIO_STREAM_STATE_PAUSING,
181 AAUDIO_STREAM_STATE_PAUSED,
182 AAUDIO_STREAM_STATE_FLUSHING,
183 AAUDIO_STREAM_STATE_FLUSHED,
184 AAUDIO_STREAM_STATE_STOPPING,
185 AAUDIO_STREAM_STATE_STOPPED,
186 AAUDIO_STREAM_STATE_CLOSING,
187 AAUDIO_STREAM_STATE_CLOSED,
188 AAUDIO_STREAM_STATE_DISCONNECTED
189};
190typedef int32_t aaudio_stream_state_t;
191
192
193enum {
194 /**
195 * This will be the only stream using a particular source or sink.
196 * This mode will provide the lowest possible latency.
197 * You should close EXCLUSIVE streams immediately when you are not using them.
198 */
199 AAUDIO_SHARING_MODE_EXCLUSIVE,
200 /**
201 * Multiple applications will be mixed by the AAudio Server.
202 * This will have higher latency than the EXCLUSIVE mode.
203 */
204 AAUDIO_SHARING_MODE_SHARED
205};
206typedef int32_t aaudio_sharing_mode_t;
207
Phil Burke2fbb592017-05-01 15:05:52 -0700208
209enum {
210 /**
211 * No particular performance needs. Default.
212 */
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800213 AAUDIO_PERFORMANCE_MODE_NONE = 10,
Phil Burke2fbb592017-05-01 15:05:52 -0700214
215 /**
Phil Burk8149eed2018-05-24 14:09:46 -0700216 * Extending battery life is more important than low latency.
Phil Burked0a3fe2017-12-05 14:27:43 -0800217 *
218 * This mode is not supported in input streams.
Phil Burk8149eed2018-05-24 14:09:46 -0700219 * For input, mode NONE will be used if this is requested.
Phil Burke2fbb592017-05-01 15:05:52 -0700220 */
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800221 AAUDIO_PERFORMANCE_MODE_POWER_SAVING,
Phil Burke2fbb592017-05-01 15:05:52 -0700222
223 /**
Phil Burk8149eed2018-05-24 14:09:46 -0700224 * Reducing latency is more important than battery life.
Phil Burke2fbb592017-05-01 15:05:52 -0700225 */
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800226 AAUDIO_PERFORMANCE_MODE_LOW_LATENCY
Phil Burke2fbb592017-05-01 15:05:52 -0700227};
228typedef int32_t aaudio_performance_mode_t;
229
Phil Burk361b1422017-12-20 14:24:16 -0800230/**
231 * The USAGE attribute expresses "why" you are playing a sound, what is this sound used for.
232 * This information is used by certain platforms or routing policies
233 * to make more refined volume or routing decisions.
234 *
235 * Note that these match the equivalent values in AudioAttributes in the Android Java API.
Phil Burk42452c02018-04-10 12:43:33 -0700236 *
237 * Added in API level 28.
Phil Burk361b1422017-12-20 14:24:16 -0800238 */
239enum {
240 /**
241 * Use this for streaming media, music performance, video, podcasts, etcetera.
242 */
243 AAUDIO_USAGE_MEDIA = 1,
244
245 /**
246 * Use this for voice over IP, telephony, etcetera.
247 */
248 AAUDIO_USAGE_VOICE_COMMUNICATION = 2,
249
250 /**
251 * Use this for sounds associated with telephony such as busy tones, DTMF, etcetera.
252 */
253 AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING = 3,
254
255 /**
256 * Use this to demand the users attention.
257 */
258 AAUDIO_USAGE_ALARM = 4,
259
260 /**
261 * Use this for notifying the user when a message has arrived or some
262 * other background event has occured.
263 */
264 AAUDIO_USAGE_NOTIFICATION = 5,
265
266 /**
267 * Use this when the phone rings.
268 */
269 AAUDIO_USAGE_NOTIFICATION_RINGTONE = 6,
270
271 /**
272 * Use this to attract the users attention when, for example, the battery is low.
273 */
274 AAUDIO_USAGE_NOTIFICATION_EVENT = 10,
275
276 /**
277 * Use this for screen readers, etcetera.
278 */
279 AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY = 11,
280
281 /**
282 * Use this for driving or navigation directions.
283 */
284 AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE = 12,
285
286 /**
287 * Use this for user interface sounds, beeps, etcetera.
288 */
289 AAUDIO_USAGE_ASSISTANCE_SONIFICATION = 13,
290
291 /**
292 * Use this for game audio and sound effects.
293 */
294 AAUDIO_USAGE_GAME = 14,
295
296 /**
297 * Use this for audio responses to user queries, audio instructions or help utterances.
298 */
299 AAUDIO_USAGE_ASSISTANT = 16
300};
301typedef int32_t aaudio_usage_t;
302
303/**
304 * The CONTENT_TYPE attribute describes "what" you are playing.
305 * It expresses the general category of the content. This information is optional.
306 * But in case it is known (for instance {@link #AAUDIO_CONTENT_TYPE_MOVIE} for a
307 * movie streaming service or {@link #AAUDIO_CONTENT_TYPE_SPEECH} for
308 * an audio book application) this information might be used by the audio framework to
309 * enforce audio focus.
310 *
311 * Note that these match the equivalent values in AudioAttributes in the Android Java API.
Phil Burk42452c02018-04-10 12:43:33 -0700312 *
313 * Added in API level 28.
Phil Burk361b1422017-12-20 14:24:16 -0800314 */
315enum {
316
317 /**
318 * Use this for spoken voice, audio books, etcetera.
319 */
320 AAUDIO_CONTENT_TYPE_SPEECH = 1,
321
322 /**
323 * Use this for pre-recorded or live music.
324 */
325 AAUDIO_CONTENT_TYPE_MUSIC = 2,
326
327 /**
328 * Use this for a movie or video soundtrack.
329 */
330 AAUDIO_CONTENT_TYPE_MOVIE = 3,
331
332 /**
333 * Use this for sound is designed to accompany a user action,
334 * such as a click or beep sound made when the user presses a button.
335 */
336 AAUDIO_CONTENT_TYPE_SONIFICATION = 4
337};
338typedef int32_t aaudio_content_type_t;
339
340/**
341 * Defines the audio source.
342 * An audio source defines both a default physical source of audio signal, and a recording
343 * configuration.
344 *
345 * Note that these match the equivalent values in MediaRecorder.AudioSource in the Android Java API.
Phil Burk42452c02018-04-10 12:43:33 -0700346 *
347 * Added in API level 28.
Phil Burk361b1422017-12-20 14:24:16 -0800348 */
349enum {
350 /**
351 * Use this preset when other presets do not apply.
352 */
353 AAUDIO_INPUT_PRESET_GENERIC = 1,
354
355 /**
356 * Use this preset when recording video.
357 */
358 AAUDIO_INPUT_PRESET_CAMCORDER = 5,
359
360 /**
361 * Use this preset when doing speech recognition.
362 */
363 AAUDIO_INPUT_PRESET_VOICE_RECOGNITION = 6,
364
365 /**
366 * Use this preset when doing telephony or voice messaging.
367 */
368 AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION = 7,
369
370 /**
371 * Use this preset to obtain an input with no effects.
372 * Note that this input will not have automatic gain control
373 * so the recorded volume may be very low.
374 */
375 AAUDIO_INPUT_PRESET_UNPROCESSED = 9,
376};
377typedef int32_t aaudio_input_preset_t;
378
Phil Burk8149eed2018-05-24 14:09:46 -0700379/**
380 * These may be used with AAudioStreamBuilder_setSessionId().
381 *
382 * Added in API level 28.
383 */
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800384enum {
385 /**
386 * Do not allocate a session ID.
387 * Effects cannot be used with this stream.
388 * Default.
Phil Burk42452c02018-04-10 12:43:33 -0700389 *
390 * Added in API level 28.
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800391 */
392 AAUDIO_SESSION_ID_NONE = -1,
393
394 /**
395 * Allocate a session ID that can be used to attach and control
396 * effects using the Java AudioEffects API.
Phil Burk8149eed2018-05-24 14:09:46 -0700397 * Note that using this may result in higher latency.
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800398 *
399 * Note that this matches the value of AudioManager.AUDIO_SESSION_ID_GENERATE.
Phil Burk42452c02018-04-10 12:43:33 -0700400 *
401 * Added in API level 28.
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800402 */
403 AAUDIO_SESSION_ID_ALLOCATE = 0,
404};
405typedef int32_t aaudio_session_id_t;
406
Phil Burke2155ef2017-02-24 13:50:29 -0800407typedef struct AAudioStreamStruct AAudioStream;
408typedef struct AAudioStreamBuilderStruct AAudioStreamBuilder;
Phil Burk5ed503c2017-02-01 09:38:15 -0800409
Phil Burk5ed503c2017-02-01 09:38:15 -0800410#ifndef AAUDIO_API
Phil Burk3316d5e2017-02-15 11:23:01 -0800411#define AAUDIO_API /* export this symbol */
Phil Burk5ed503c2017-02-01 09:38:15 -0800412#endif
413
414// ============================================================
415// Audio System
416// ============================================================
417
418/**
Phil Burk5ed503c2017-02-01 09:38:15 -0800419 * The text is the ASCII symbol corresponding to the returnCode,
420 * or an English message saying the returnCode is unrecognized.
421 * This is intended for developers to use when debugging.
422 * It is not for display to users.
423 *
424 * @return pointer to a text representation of an AAudio result code.
425 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700426AAUDIO_API const char * AAudio_convertResultToText(aaudio_result_t returnCode) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800427
428/**
429 * The text is the ASCII symbol corresponding to the stream state,
430 * or an English message saying the state is unrecognized.
431 * This is intended for developers to use when debugging.
432 * It is not for display to users.
433 *
434 * @return pointer to a text representation of an AAudio state.
435 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700436AAUDIO_API const char * AAudio_convertStreamStateToText(aaudio_stream_state_t state)
437 __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800438
439// ============================================================
440// StreamBuilder
441// ============================================================
442
443/**
444 * Create a StreamBuilder that can be used to open a Stream.
445 *
446 * The deviceId is initially unspecified, meaning that the current default device will be used.
447 *
448 * The default direction is AAUDIO_DIRECTION_OUTPUT.
Phil Burk3316d5e2017-02-15 11:23:01 -0800449 * The default sharing mode is AAUDIO_SHARING_MODE_SHARED.
Phil Burk5ed503c2017-02-01 09:38:15 -0800450 * The data format, samplesPerFrames and sampleRate are unspecified and will be
451 * chosen by the device when it is opened.
452 *
453 * AAudioStreamBuilder_delete() must be called when you are done using the builder.
454 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700455AAUDIO_API aaudio_result_t AAudio_createStreamBuilder(AAudioStreamBuilder** builder)
456 __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800457
458/**
459 * Request an audio device identified device using an ID.
Phil Burk5ed503c2017-02-01 09:38:15 -0800460 * On Android, for example, the ID could be obtained from the Java AudioManager.
461 *
Glenn Kasten5f510d22017-05-30 15:52:15 -0700462 * The default, if you do not call this function, is AAUDIO_UNSPECIFIED,
Phil Burke057ca92017-03-28 11:31:34 -0700463 * in which case the primary device will be used.
Phil Burk5ed503c2017-02-01 09:38:15 -0800464 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800465 * @param builder reference provided by AAudio_createStreamBuilder()
Glenn Kasten5f510d22017-05-30 15:52:15 -0700466 * @param deviceId device identifier or AAUDIO_UNSPECIFIED
Phil Burk5ed503c2017-02-01 09:38:15 -0800467 */
Phil Burke2155ef2017-02-24 13:50:29 -0800468AAUDIO_API void AAudioStreamBuilder_setDeviceId(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700469 int32_t deviceId) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800470
471/**
Phil Burke057ca92017-03-28 11:31:34 -0700472 * Request a sample rate in Hertz.
473 *
Phil Burke057ca92017-03-28 11:31:34 -0700474 * The default, if you do not call this function, is AAUDIO_UNSPECIFIED.
Phil Burk8f624892017-05-11 11:44:20 -0700475 * An optimal value will then be chosen when the stream is opened.
476 * After opening a stream with an unspecified value, the application must
477 * query for the actual value, which may vary by device.
478 *
479 * If an exact value is specified then an opened stream will use that value.
480 * If a stream cannot be opened with the specified value then the open will fail.
Phil Burke057ca92017-03-28 11:31:34 -0700481 *
482 * @param builder reference provided by AAudio_createStreamBuilder()
483 * @param sampleRate frames per second. Common rates include 44100 and 48000 Hz.
Phil Burk5ed503c2017-02-01 09:38:15 -0800484 */
Phil Burke2155ef2017-02-24 13:50:29 -0800485AAUDIO_API void AAudioStreamBuilder_setSampleRate(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700486 int32_t sampleRate) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800487
488/**
Phil Burk20523ed2017-04-24 17:04:01 -0700489 * Request a number of channels for the stream.
Phil Burke057ca92017-03-28 11:31:34 -0700490 *
Phil Burke057ca92017-03-28 11:31:34 -0700491 * The default, if you do not call this function, is AAUDIO_UNSPECIFIED.
Phil Burk8f624892017-05-11 11:44:20 -0700492 * An optimal value will then be chosen when the stream is opened.
493 * After opening a stream with an unspecified value, the application must
494 * query for the actual value, which may vary by device.
Phil Burk5ed503c2017-02-01 09:38:15 -0800495 *
Phil Burk8f624892017-05-11 11:44:20 -0700496 * If an exact value is specified then an opened stream will use that value.
497 * If a stream cannot be opened with the specified value then the open will fail.
Phil Burke057ca92017-03-28 11:31:34 -0700498 *
499 * @param builder reference provided by AAudio_createStreamBuilder()
Phil Burk20523ed2017-04-24 17:04:01 -0700500 * @param channelCount Number of channels desired.
Phil Burk5ed503c2017-02-01 09:38:15 -0800501 */
Phil Burk20523ed2017-04-24 17:04:01 -0700502AAUDIO_API void AAudioStreamBuilder_setChannelCount(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700503 int32_t channelCount) __INTRODUCED_IN(26);
Phil Burk20523ed2017-04-24 17:04:01 -0700504
505/**
Phil Burke74240d2017-08-03 15:25:43 -0700506 * Identical to AAudioStreamBuilder_setChannelCount().
507 *
508 * @param builder reference provided by AAudio_createStreamBuilder()
509 * @param samplesPerFrame Number of samples in a frame.
510 */
511AAUDIO_API void AAudioStreamBuilder_setSamplesPerFrame(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700512 int32_t samplesPerFrame) __INTRODUCED_IN(26);
Phil Burke74240d2017-08-03 15:25:43 -0700513
514/**
Phil Burk5ed503c2017-02-01 09:38:15 -0800515 * Request a sample data format, for example AAUDIO_FORMAT_PCM_I16.
Phil Burke057ca92017-03-28 11:31:34 -0700516 *
517 * The default, if you do not call this function, is AAUDIO_UNSPECIFIED.
Phil Burk8f624892017-05-11 11:44:20 -0700518 * An optimal value will then be chosen when the stream is opened.
519 * After opening a stream with an unspecified value, the application must
520 * query for the actual value, which may vary by device.
Phil Burke057ca92017-03-28 11:31:34 -0700521 *
Phil Burk8f624892017-05-11 11:44:20 -0700522 * If an exact value is specified then an opened stream will use that value.
523 * If a stream cannot be opened with the specified value then the open will fail.
Phil Burke057ca92017-03-28 11:31:34 -0700524 *
525 * @param builder reference provided by AAudio_createStreamBuilder()
Phil Burk8f624892017-05-11 11:44:20 -0700526 * @param format common formats are AAUDIO_FORMAT_PCM_FLOAT and AAUDIO_FORMAT_PCM_I16.
Phil Burk5ed503c2017-02-01 09:38:15 -0800527 */
Phil Burke2155ef2017-02-24 13:50:29 -0800528AAUDIO_API void AAudioStreamBuilder_setFormat(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700529 aaudio_format_t format) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800530
531/**
Phil Burk5ed503c2017-02-01 09:38:15 -0800532 * Request a mode for sharing the device.
Phil Burke057ca92017-03-28 11:31:34 -0700533 *
534 * The default, if you do not call this function, is AAUDIO_SHARING_MODE_SHARED.
535 *
Phil Burk5ed503c2017-02-01 09:38:15 -0800536 * The requested sharing mode may not be available.
Phil Burke057ca92017-03-28 11:31:34 -0700537 * The application can query for the actual mode after the stream is opened.
Phil Burk5ed503c2017-02-01 09:38:15 -0800538 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800539 * @param builder reference provided by AAudio_createStreamBuilder()
Phil Burke057ca92017-03-28 11:31:34 -0700540 * @param sharingMode AAUDIO_SHARING_MODE_SHARED or AAUDIO_SHARING_MODE_EXCLUSIVE
Phil Burk5ed503c2017-02-01 09:38:15 -0800541 */
Phil Burke2155ef2017-02-24 13:50:29 -0800542AAUDIO_API void AAudioStreamBuilder_setSharingMode(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700543 aaudio_sharing_mode_t sharingMode) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800544
545/**
Phil Burke057ca92017-03-28 11:31:34 -0700546 * Request the direction for a stream.
547 *
548 * The default, if you do not call this function, is AAUDIO_DIRECTION_OUTPUT.
Phil Burk5ed503c2017-02-01 09:38:15 -0800549 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800550 * @param builder reference provided by AAudio_createStreamBuilder()
Phil Burk5ed503c2017-02-01 09:38:15 -0800551 * @param direction AAUDIO_DIRECTION_OUTPUT or AAUDIO_DIRECTION_INPUT
Phil Burk5ed503c2017-02-01 09:38:15 -0800552 */
Phil Burke2155ef2017-02-24 13:50:29 -0800553AAUDIO_API void AAudioStreamBuilder_setDirection(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700554 aaudio_direction_t direction) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800555
556/**
Phil Burke057ca92017-03-28 11:31:34 -0700557 * Set the requested buffer capacity in frames.
Phil Burk3df348f2017-02-08 11:41:55 -0800558 * The final AAudioStream capacity may differ, but will probably be at least this big.
559 *
Phil Burke057ca92017-03-28 11:31:34 -0700560 * The default, if you do not call this function, is AAUDIO_UNSPECIFIED.
Phil Burk3df348f2017-02-08 11:41:55 -0800561 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800562 * @param builder reference provided by AAudio_createStreamBuilder()
Phil Burke057ca92017-03-28 11:31:34 -0700563 * @param numFrames the desired buffer capacity in frames or AAUDIO_UNSPECIFIED
Phil Burk3df348f2017-02-08 11:41:55 -0800564 */
Phil Burke2155ef2017-02-24 13:50:29 -0800565AAUDIO_API void AAudioStreamBuilder_setBufferCapacityInFrames(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700566 int32_t numFrames) __INTRODUCED_IN(26);
Phil Burke2fbb592017-05-01 15:05:52 -0700567
568/**
569 * Set the requested performance mode.
570 *
Phil Burk8149eed2018-05-24 14:09:46 -0700571 * Supported modes are AAUDIO_PERFORMANCE_MODE_NONE, AAUDIO_PERFORMANCE_MODE_POWER_SAVING
572 * and AAUDIO_PERFORMANCE_MODE_LOW_LATENCY.
573 *
Phil Burke2fbb592017-05-01 15:05:52 -0700574 * The default, if you do not call this function, is AAUDIO_PERFORMANCE_MODE_NONE.
575 *
Phil Burk8149eed2018-05-24 14:09:46 -0700576 * You may not get the mode you requested.
577 * You can call AAudioStream_getPerformanceMode() to find out the final mode for the stream.
578 *
Phil Burke2fbb592017-05-01 15:05:52 -0700579 * @param builder reference provided by AAudio_createStreamBuilder()
580 * @param mode the desired performance mode, eg. AAUDIO_PERFORMANCE_MODE_LOW_LATENCY
581 */
582AAUDIO_API void AAudioStreamBuilder_setPerformanceMode(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700583 aaudio_performance_mode_t mode) __INTRODUCED_IN(26);
Phil Burke2fbb592017-05-01 15:05:52 -0700584
Phil Burke057ca92017-03-28 11:31:34 -0700585/**
Phil Burk361b1422017-12-20 14:24:16 -0800586 * Set the intended use case for the stream.
587 *
588 * The AAudio system will use this information to optimize the
589 * behavior of the stream.
590 * This could, for example, affect how volume and focus is handled for the stream.
591 *
592 * The default, if you do not call this function, is AAUDIO_USAGE_MEDIA.
593 *
Phil Burk42452c02018-04-10 12:43:33 -0700594 * Added in API level 28.
595 *
Phil Burk361b1422017-12-20 14:24:16 -0800596 * @param builder reference provided by AAudio_createStreamBuilder()
597 * @param usage the desired usage, eg. AAUDIO_USAGE_GAME
598 */
599AAUDIO_API void AAudioStreamBuilder_setUsage(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700600 aaudio_usage_t usage) __INTRODUCED_IN(28);
Phil Burk361b1422017-12-20 14:24:16 -0800601
602/**
603 * Set the type of audio data that the stream will carry.
604 *
605 * The AAudio system will use this information to optimize the
606 * behavior of the stream.
607 * This could, for example, affect whether a stream is paused when a notification occurs.
608 *
609 * The default, if you do not call this function, is AAUDIO_CONTENT_TYPE_MUSIC.
610 *
Phil Burk42452c02018-04-10 12:43:33 -0700611 * Added in API level 28.
612 *
Phil Burk361b1422017-12-20 14:24:16 -0800613 * @param builder reference provided by AAudio_createStreamBuilder()
614 * @param contentType the type of audio data, eg. AAUDIO_CONTENT_TYPE_SPEECH
615 */
616AAUDIO_API void AAudioStreamBuilder_setContentType(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700617 aaudio_content_type_t contentType) __INTRODUCED_IN(28);
Phil Burk361b1422017-12-20 14:24:16 -0800618
619/**
620 * Set the input (capture) preset for the stream.
621 *
622 * The AAudio system will use this information to optimize the
623 * behavior of the stream.
624 * This could, for example, affect which microphones are used and how the
625 * recorded data is processed.
626 *
Phil Burkeaef9b92018-01-18 09:09:42 -0800627 * The default, if you do not call this function, is AAUDIO_INPUT_PRESET_VOICE_RECOGNITION.
628 * That is because VOICE_RECOGNITION is the preset with the lowest latency
629 * on many platforms.
Phil Burk361b1422017-12-20 14:24:16 -0800630 *
Phil Burk42452c02018-04-10 12:43:33 -0700631 * Added in API level 28.
632 *
Phil Burk361b1422017-12-20 14:24:16 -0800633 * @param builder reference provided by AAudio_createStreamBuilder()
634 * @param inputPreset the desired configuration for recording
635 */
636AAUDIO_API void AAudioStreamBuilder_setInputPreset(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700637 aaudio_input_preset_t inputPreset) __INTRODUCED_IN(28);
Phil Burk361b1422017-12-20 14:24:16 -0800638
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800639/** Set the requested session ID.
640 *
641 * The session ID can be used to associate a stream with effects processors.
642 * The effects are controlled using the Android AudioEffect Java API.
643 *
644 * The default, if you do not call this function, is AAUDIO_SESSION_ID_NONE.
645 *
646 * If set to AAUDIO_SESSION_ID_ALLOCATE then a session ID will be allocated
647 * when the stream is opened.
648 *
649 * The allocated session ID can be obtained by calling AAudioStream_getSessionId()
650 * and then used with this function when opening another stream.
651 * This allows effects to be shared between streams.
652 *
Phil Burk8149eed2018-05-24 14:09:46 -0700653 * Session IDs from AAudio can be used with the Android Java APIs and vice versa.
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800654 * So a session ID from an AAudio stream can be passed to Java
655 * and effects applied using the Java AudioEffect API.
656 *
Phil Burk8149eed2018-05-24 14:09:46 -0700657 * Note that allocating or setting a session ID may result in a stream with higher latency.
658 *
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800659 * Allocated session IDs will always be positive and nonzero.
660 *
Phil Burk42452c02018-04-10 12:43:33 -0700661 * Added in API level 28.
662 *
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800663 * @param builder reference provided by AAudio_createStreamBuilder()
664 * @param sessionId an allocated sessionID or AAUDIO_SESSION_ID_ALLOCATE
665 */
666AAUDIO_API void AAudioStreamBuilder_setSessionId(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700667 aaudio_session_id_t sessionId) __INTRODUCED_IN(28);
Phil Burk7e7dcaa2018-01-03 15:16:15 -0800668
Phil Burk361b1422017-12-20 14:24:16 -0800669/**
Phil Burke057ca92017-03-28 11:31:34 -0700670 * Return one of these values from the data callback function.
671 */
672enum {
673
674 /**
675 * Continue calling the callback.
676 */
677 AAUDIO_CALLBACK_RESULT_CONTINUE = 0,
678
679 /**
680 * Stop calling the callback.
681 *
682 * The application will still need to call AAudioStream_requestPause()
683 * or AAudioStream_requestStop().
684 */
685 AAUDIO_CALLBACK_RESULT_STOP,
686
687};
688typedef int32_t aaudio_data_callback_result_t;
689
690/**
691 * Prototype for the data function that is passed to AAudioStreamBuilder_setDataCallback().
692 *
693 * For an output stream, this function should render and write numFrames of data
694 * in the streams current data format to the audioData buffer.
695 *
696 * For an input stream, this function should read and process numFrames of data
697 * from the audioData buffer.
698 *
Phil Burked0a3fe2017-12-05 14:27:43 -0800699 * The audio data is passed through the buffer. So do NOT call AAudioStream_read() or
700 * AAudioStream_write() on the stream that is making the callback.
701 *
702 * Note that numFrames can vary unless AAudioStreamBuilder_setFramesPerDataCallback()
703 * is called.
704 *
705 * Also note that this callback function should be considered a "real-time" function.
Phil Burke057ca92017-03-28 11:31:34 -0700706 * It must not do anything that could cause an unbounded delay because that can cause the
707 * audio to glitch or pop.
708 *
709 * These are things the function should NOT do:
710 * <ul>
711 * <li>allocate memory using, for example, malloc() or new</li>
712 * <li>any file operations such as opening, closing, reading or writing</li>
713 * <li>any network operations such as streaming</li>
714 * <li>use any mutexes or other synchronization primitives</li>
715 * <li>sleep</li>
Phil Burked0a3fe2017-12-05 14:27:43 -0800716 * <li>stop or close the stream</li>
Phil Burk8149eed2018-05-24 14:09:46 -0700717 * <li>AAudioStream_read()</li>
718 * <li>AAudioStream_write()</li>
719 * </ul>
720 *
721 * The following are OK to call from the data callback:
722 * <ul>
723 * <li>AAudioStream_get*()</li>
724 * <li>AAudio_convertResultToText()</li>
Phil Burke057ca92017-03-28 11:31:34 -0700725 * </ul>
726 *
727 * If you need to move data, eg. MIDI commands, in or out of the callback function then
728 * we recommend the use of non-blocking techniques such as an atomic FIFO.
729 *
730 * @param stream reference provided by AAudioStreamBuilder_openStream()
731 * @param userData the same address that was passed to AAudioStreamBuilder_setCallback()
732 * @param audioData a pointer to the audio data
Phil Burked0a3fe2017-12-05 14:27:43 -0800733 * @param numFrames the number of frames to be processed, which can vary
Phil Burke057ca92017-03-28 11:31:34 -0700734 * @return AAUDIO_CALLBACK_RESULT_*
735 */
736typedef aaudio_data_callback_result_t (*AAudioStream_dataCallback)(
737 AAudioStream *stream,
738 void *userData,
739 void *audioData,
740 int32_t numFrames);
741
742/**
743 * Request that AAudio call this functions when the stream is running.
744 *
745 * Note that when using this callback, the audio data will be passed in or out
746 * of the function as an argument.
747 * So you cannot call AAudioStream_write() or AAudioStream_read() on the same stream
748 * that has an active data callback.
749 *
750 * The callback function will start being called after AAudioStream_requestStart() is called.
751 * It will stop being called after AAudioStream_requestPause() or
752 * AAudioStream_requestStop() is called.
753 *
754 * This callback function will be called on a real-time thread owned by AAudio. See
Glenn Kasten0d804362017-04-13 09:20:14 -0700755 * {@link AAudioStream_dataCallback} for more information.
Phil Burke057ca92017-03-28 11:31:34 -0700756 *
757 * Note that the AAudio callbacks will never be called simultaneously from multiple threads.
758 *
759 * @param builder reference provided by AAudio_createStreamBuilder()
760 * @param callback pointer to a function that will process audio data.
761 * @param userData pointer to an application data structure that will be passed
762 * to the callback functions.
763 */
764AAUDIO_API void AAudioStreamBuilder_setDataCallback(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700765 AAudioStream_dataCallback callback, void *userData) __INTRODUCED_IN(26);
Phil Burke057ca92017-03-28 11:31:34 -0700766
767/**
768 * Set the requested data callback buffer size in frames.
769 * See {@link AAudioStream_dataCallback}.
770 *
771 * The default, if you do not call this function, is AAUDIO_UNSPECIFIED.
772 *
773 * For the lowest possible latency, do not call this function. AAudio will then
774 * call the dataProc callback function with whatever size is optimal.
775 * That size may vary from one callback to another.
776 *
777 * Only use this function if the application requires a specific number of frames for processing.
778 * The application might, for example, be using an FFT that requires
779 * a specific power-of-two sized buffer.
780 *
781 * AAudio may need to add additional buffering in order to adapt between the internal
782 * buffer size and the requested buffer size.
783 *
784 * If you do call this function then the requested size should be less than
785 * half the buffer capacity, to allow double buffering.
786 *
787 * @param builder reference provided by AAudio_createStreamBuilder()
788 * @param numFrames the desired buffer size in frames or AAUDIO_UNSPECIFIED
789 */
790AAUDIO_API void AAudioStreamBuilder_setFramesPerDataCallback(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700791 int32_t numFrames) __INTRODUCED_IN(26);
Phil Burke057ca92017-03-28 11:31:34 -0700792
793/**
794 * Prototype for the callback function that is passed to
795 * AAudioStreamBuilder_setErrorCallback().
796 *
Phil Burk8149eed2018-05-24 14:09:46 -0700797 * The following may NOT be called from the error callback:
798 * <ul>
799 * <li>AAudioStream_requestStop()</li>
800 * <li>AAudioStream_requestPause()</li>
801 * <li>AAudioStream_close()</li>
802 * <li>AAudioStream_waitForStateChange()</li>
803 * <li>AAudioStream_read()</li>
804 * <li>AAudioStream_write()</li>
805 * </ul>
806 *
807 * The following are OK to call from the error callback:
808 * <ul>
809 * <li>AAudioStream_get*()</li>
810 * <li>AAudio_convertResultToText()</li>
811 * </ul>
812 *
Phil Burke057ca92017-03-28 11:31:34 -0700813 * @param stream reference provided by AAudioStreamBuilder_openStream()
814 * @param userData the same address that was passed to AAudioStreamBuilder_setErrorCallback()
815 * @param error an AAUDIO_ERROR_* value.
816 */
817typedef void (*AAudioStream_errorCallback)(
818 AAudioStream *stream,
819 void *userData,
820 aaudio_result_t error);
821
822/**
Phil Burked0a3fe2017-12-05 14:27:43 -0800823 * Request that AAudio call this function if any error occurs or the stream is disconnected.
Phil Burke057ca92017-03-28 11:31:34 -0700824 *
825 * It will be called, for example, if a headset or a USB device is unplugged causing the stream's
Phil Burked0a3fe2017-12-05 14:27:43 -0800826 * device to be unavailable or "disconnected".
Phil Burke057ca92017-03-28 11:31:34 -0700827 * Another possible cause of error would be a timeout or an unanticipated internal error.
828 *
Phil Burked0a3fe2017-12-05 14:27:43 -0800829 * In response, this function should signal or create another thread to stop
830 * and close this stream. The other thread could then reopen a stream on another device.
831 * Do not stop or close the stream, or reopen the new stream, directly from this callback.
832 *
833 * This callback will not be called because of actions by the application, such as stopping
834 * or closing a stream.
835 *
Phil Burke057ca92017-03-28 11:31:34 -0700836 * Note that the AAudio callbacks will never be called simultaneously from multiple threads.
837 *
838 * @param builder reference provided by AAudio_createStreamBuilder()
839 * @param callback pointer to a function that will be called if an error occurs.
840 * @param userData pointer to an application data structure that will be passed
841 * to the callback functions.
842 */
843AAUDIO_API void AAudioStreamBuilder_setErrorCallback(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700844 AAudioStream_errorCallback callback, void *userData) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800845
846/**
847 * Open a stream based on the options in the StreamBuilder.
848 *
849 * AAudioStream_close must be called when finished with the stream to recover
850 * the memory and to free the associated resources.
851 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800852 * @param builder reference provided by AAudio_createStreamBuilder()
853 * @param stream pointer to a variable to receive the new stream reference
Phil Burk5ed503c2017-02-01 09:38:15 -0800854 * @return AAUDIO_OK or a negative error.
855 */
Phil Burke2155ef2017-02-24 13:50:29 -0800856AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* builder,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700857 AAudioStream** stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800858
859/**
860 * Delete the resources associated with the StreamBuilder.
861 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800862 * @param builder reference provided by AAudio_createStreamBuilder()
Phil Burk5ed503c2017-02-01 09:38:15 -0800863 * @return AAUDIO_OK or a negative error.
864 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700865AAUDIO_API aaudio_result_t AAudioStreamBuilder_delete(AAudioStreamBuilder* builder)
866 __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800867
868// ============================================================
869// Stream Control
870// ============================================================
871
872/**
873 * Free the resources associated with a stream created by AAudioStreamBuilder_openStream()
874 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800875 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burk5ed503c2017-02-01 09:38:15 -0800876 * @return AAUDIO_OK or a negative error.
877 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700878AAUDIO_API aaudio_result_t AAudioStream_close(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800879
880/**
881 * Asynchronously request to start playing the stream. For output streams, one should
882 * write to the stream to fill the buffer before starting.
883 * Otherwise it will underflow.
884 * After this call the state will be in AAUDIO_STREAM_STATE_STARTING or AAUDIO_STREAM_STATE_STARTED.
885 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800886 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burk5ed503c2017-02-01 09:38:15 -0800887 * @return AAUDIO_OK or a negative error.
888 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700889AAUDIO_API aaudio_result_t AAudioStream_requestStart(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800890
891/**
892 * Asynchronous request for the stream to pause.
893 * Pausing a stream will freeze the data flow but not flush any buffers.
894 * Use AAudioStream_Start() to resume playback after a pause.
895 * After this call the state will be in AAUDIO_STREAM_STATE_PAUSING or AAUDIO_STREAM_STATE_PAUSED.
896 *
Phil Burk068c10f2017-05-08 16:36:41 -0700897 * This will return AAUDIO_ERROR_UNIMPLEMENTED for input streams.
898 * For input streams use AAudioStream_requestStop().
899 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800900 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burk5ed503c2017-02-01 09:38:15 -0800901 * @return AAUDIO_OK or a negative error.
902 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700903AAUDIO_API aaudio_result_t AAudioStream_requestPause(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800904
905/**
906 * Asynchronous request for the stream to flush.
907 * Flushing will discard any pending data.
908 * This call only works if the stream is pausing or paused. TODO review
909 * Frame counters are not reset by a flush. They may be advanced.
910 * After this call the state will be in AAUDIO_STREAM_STATE_FLUSHING or AAUDIO_STREAM_STATE_FLUSHED.
911 *
Phil Burk068c10f2017-05-08 16:36:41 -0700912 * This will return AAUDIO_ERROR_UNIMPLEMENTED for input streams.
913 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800914 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burk5ed503c2017-02-01 09:38:15 -0800915 * @return AAUDIO_OK or a negative error.
916 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700917AAUDIO_API aaudio_result_t AAudioStream_requestFlush(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800918
919/**
920 * Asynchronous request for the stream to stop.
921 * The stream will stop after all of the data currently buffered has been played.
922 * After this call the state will be in AAUDIO_STREAM_STATE_STOPPING or AAUDIO_STREAM_STATE_STOPPED.
923 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800924 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burk5ed503c2017-02-01 09:38:15 -0800925 * @return AAUDIO_OK or a negative error.
926 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700927AAUDIO_API aaudio_result_t AAudioStream_requestStop(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800928
929/**
Phil Burk3316d5e2017-02-15 11:23:01 -0800930 * Query the current state of the client, eg. AAUDIO_STREAM_STATE_PAUSING
Phil Burk5ed503c2017-02-01 09:38:15 -0800931 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800932 * This function will immediately return the state without updating the state.
933 * If you want to update the client state based on the server state then
934 * call AAudioStream_waitForStateChange() with currentState
935 * set to AAUDIO_STREAM_STATE_UNKNOWN and a zero timeout.
936 *
937 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burk5ed503c2017-02-01 09:38:15 -0800938 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700939AAUDIO_API aaudio_stream_state_t AAudioStream_getState(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800940
941/**
942 * Wait until the current state no longer matches the input state.
943 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800944 * This will update the current client state.
945 *
Phil Burk5ed503c2017-02-01 09:38:15 -0800946 * <pre><code>
Phil Burked0a3fe2017-12-05 14:27:43 -0800947 * aaudio_result_t result = AAUDIO_OK;
948 * aaudio_stream_state_t currentState = AAudioStream_getState(stream);
949 * aaudio_stream_state_t inputState = currentState;
950 * while (result == AAUDIO_OK && currentState != AAUDIO_STREAM_STATE_PAUSED) {
Phil Burk5ed503c2017-02-01 09:38:15 -0800951 * result = AAudioStream_waitForStateChange(
Phil Burked0a3fe2017-12-05 14:27:43 -0800952 * stream, inputState, &currentState, MY_TIMEOUT_NANOS);
953 * inputState = currentState;
Phil Burk5ed503c2017-02-01 09:38:15 -0800954 * }
955 * </code></pre>
956 *
Phil Burk3316d5e2017-02-15 11:23:01 -0800957 * @param stream A reference provided by AAudioStreamBuilder_openStream()
Phil Burk5ed503c2017-02-01 09:38:15 -0800958 * @param inputState The state we want to avoid.
959 * @param nextState Pointer to a variable that will be set to the new state.
960 * @param timeoutNanoseconds Maximum number of nanoseconds to wait for completion.
961 * @return AAUDIO_OK or a negative error.
962 */
Phil Burke2155ef2017-02-24 13:50:29 -0800963AAUDIO_API aaudio_result_t AAudioStream_waitForStateChange(AAudioStream* stream,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700964 aaudio_stream_state_t inputState, aaudio_stream_state_t *nextState,
965 int64_t timeoutNanoseconds) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800966
967// ============================================================
968// Stream I/O
969// ============================================================
970
971/**
972 * Read data from the stream.
973 *
974 * The call will wait until the read is complete or until it runs out of time.
975 * If timeoutNanos is zero then this call will not wait.
976 *
977 * Note that timeoutNanoseconds is a relative duration in wall clock time.
978 * Time will not stop if the thread is asleep.
979 * So it will be implemented using CLOCK_BOOTTIME.
980 *
981 * This call is "strong non-blocking" unless it has to wait for data.
982 *
Phil Burk8149eed2018-05-24 14:09:46 -0700983 * If the call times out then zero or a partial frame count will be returned.
984 *
Phil Burk5ed503c2017-02-01 09:38:15 -0800985 * @param stream A stream created using AAudioStreamBuilder_openStream().
986 * @param buffer The address of the first sample.
987 * @param numFrames Number of frames to read. Only complete frames will be written.
988 * @param timeoutNanoseconds Maximum number of nanoseconds to wait for completion.
Phil Burk3316d5e2017-02-15 11:23:01 -0800989 * @return The number of frames actually read or a negative error.
Phil Burk5ed503c2017-02-01 09:38:15 -0800990 */
Phil Burke2155ef2017-02-24 13:50:29 -0800991AAUDIO_API aaudio_result_t AAudioStream_read(AAudioStream* stream,
Elliott Hughes233ce1b2018-06-18 13:17:24 -0700992 void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -0800993
994/**
995 * Write data to the stream.
996 *
997 * The call will wait until the write is complete or until it runs out of time.
998 * If timeoutNanos is zero then this call will not wait.
999 *
1000 * Note that timeoutNanoseconds is a relative duration in wall clock time.
1001 * Time will not stop if the thread is asleep.
1002 * So it will be implemented using CLOCK_BOOTTIME.
1003 *
1004 * This call is "strong non-blocking" unless it has to wait for room in the buffer.
1005 *
Phil Burk8149eed2018-05-24 14:09:46 -07001006 * If the call times out then zero or a partial frame count will be returned.
1007 *
Phil Burk5ed503c2017-02-01 09:38:15 -08001008 * @param stream A stream created using AAudioStreamBuilder_openStream().
1009 * @param buffer The address of the first sample.
1010 * @param numFrames Number of frames to write. Only complete frames will be written.
1011 * @param timeoutNanoseconds Maximum number of nanoseconds to wait for completion.
1012 * @return The number of frames actually written or a negative error.
1013 */
Phil Burke2155ef2017-02-24 13:50:29 -08001014AAUDIO_API aaudio_result_t AAudioStream_write(AAudioStream* stream,
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001015 const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001016
Phil Burk5ed503c2017-02-01 09:38:15 -08001017// ============================================================
1018// Stream - queries
1019// ============================================================
1020
Phil Burk5ed503c2017-02-01 09:38:15 -08001021/**
1022 * This can be used to adjust the latency of the buffer by changing
1023 * the threshold where blocking will occur.
Phil Burk3316d5e2017-02-15 11:23:01 -08001024 * By combining this with AAudioStream_getXRunCount(), the latency can be tuned
Phil Burk5ed503c2017-02-01 09:38:15 -08001025 * at run-time for each device.
1026 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001027 * This cannot be set higher than AAudioStream_getBufferCapacityInFrames().
Phil Burk5ed503c2017-02-01 09:38:15 -08001028 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001029 * Note that you will probably not get the exact size you request.
Phil Burk8149eed2018-05-24 14:09:46 -07001030 * You can check the return value or call AAudioStream_getBufferSizeInFrames()
1031 * to see what the actual final size is.
Phil Burk3316d5e2017-02-15 11:23:01 -08001032 *
1033 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burke057ca92017-03-28 11:31:34 -07001034 * @param numFrames requested number of frames that can be filled without blocking
Phil Burk3316d5e2017-02-15 11:23:01 -08001035 * @return actual buffer size in frames or a negative error
Phil Burk5ed503c2017-02-01 09:38:15 -08001036 */
Phil Burke2155ef2017-02-24 13:50:29 -08001037AAUDIO_API aaudio_result_t AAudioStream_setBufferSizeInFrames(AAudioStream* stream,
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001038 int32_t numFrames) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001039
1040/**
1041 * Query the maximum number of frames that can be filled without blocking.
1042 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001043 * @param stream reference provided by AAudioStreamBuilder_openStream()
1044 * @return buffer size in frames.
Phil Burk5ed503c2017-02-01 09:38:15 -08001045 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001046AAUDIO_API int32_t AAudioStream_getBufferSizeInFrames(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001047
1048/**
Phil Burk3316d5e2017-02-15 11:23:01 -08001049 * Query the number of frames that the application should read or write at
1050 * one time for optimal performance. It is OK if an application writes
1051 * a different number of frames. But the buffer size may need to be larger
1052 * in order to avoid underruns or overruns.
Phil Burk5ed503c2017-02-01 09:38:15 -08001053 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001054 * Note that this may or may not match the actual device burst size.
1055 * For some endpoints, the burst size can vary dynamically.
1056 * But these tend to be devices with high latency.
1057 *
1058 * @param stream reference provided by AAudioStreamBuilder_openStream()
1059 * @return burst size
Phil Burk5ed503c2017-02-01 09:38:15 -08001060 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001061AAUDIO_API int32_t AAudioStream_getFramesPerBurst(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001062
1063/**
1064 * Query maximum buffer capacity in frames.
1065 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001066 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burke057ca92017-03-28 11:31:34 -07001067 * @return buffer capacity in frames
Phil Burk5ed503c2017-02-01 09:38:15 -08001068 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001069AAUDIO_API int32_t AAudioStream_getBufferCapacityInFrames(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001070
1071/**
Phil Burke057ca92017-03-28 11:31:34 -07001072 * Query the size of the buffer that will be passed to the dataProc callback
1073 * in the numFrames parameter.
1074 *
1075 * This call can be used if the application needs to know the value of numFrames before
1076 * the stream is started. This is not normally necessary.
1077 *
Phil Burked0a3fe2017-12-05 14:27:43 -08001078 * If a specific size was requested by calling AAudioStreamBuilder_setFramesPerDataCallback()
Phil Burke057ca92017-03-28 11:31:34 -07001079 * then this will be the same size.
1080 *
Phil Burked0a3fe2017-12-05 14:27:43 -08001081 * If AAudioStreamBuilder_setFramesPerDataCallback() was not called then this will
Phil Burke057ca92017-03-28 11:31:34 -07001082 * return the size chosen by AAudio, or AAUDIO_UNSPECIFIED.
1083 *
1084 * AAUDIO_UNSPECIFIED indicates that the callback buffer size for this stream
1085 * may vary from one dataProc callback to the next.
1086 *
1087 * @param stream reference provided by AAudioStreamBuilder_openStream()
1088 * @return callback buffer size in frames or AAUDIO_UNSPECIFIED
1089 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001090AAUDIO_API int32_t AAudioStream_getFramesPerDataCallback(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burke057ca92017-03-28 11:31:34 -07001091
1092/**
Phil Burk5ed503c2017-02-01 09:38:15 -08001093 * An XRun is an Underrun or an Overrun.
1094 * During playing, an underrun will occur if the stream is not written in time
1095 * and the system runs out of valid data.
1096 * During recording, an overrun will occur if the stream is not read in time
1097 * and there is no place to put the incoming data so it is discarded.
1098 *
1099 * An underrun or overrun can cause an audible "pop" or "glitch".
1100 *
Phil Burk068c10f2017-05-08 16:36:41 -07001101 * Note that some INPUT devices may not support this function.
1102 * In that case a 0 will always be returned.
1103 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001104 * @param stream reference provided by AAudioStreamBuilder_openStream()
1105 * @return the underrun or overrun count
Phil Burk5ed503c2017-02-01 09:38:15 -08001106 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001107AAUDIO_API int32_t AAudioStream_getXRunCount(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001108
1109/**
Phil Burk3316d5e2017-02-15 11:23:01 -08001110 * @param stream reference provided by AAudioStreamBuilder_openStream()
1111 * @return actual sample rate
Phil Burk5ed503c2017-02-01 09:38:15 -08001112 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001113AAUDIO_API int32_t AAudioStream_getSampleRate(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001114
1115/**
Phil Burk20523ed2017-04-24 17:04:01 -07001116 * A stream has one or more channels of data.
1117 * A frame will contain one sample for each channel.
1118 *
1119 * @param stream reference provided by AAudioStreamBuilder_openStream()
1120 * @return actual number of channels
1121 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001122AAUDIO_API int32_t AAudioStream_getChannelCount(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk20523ed2017-04-24 17:04:01 -07001123
1124/**
Phil Burke74240d2017-08-03 15:25:43 -07001125 * Identical to AAudioStream_getChannelCount().
1126 *
1127 * @param stream reference provided by AAudioStreamBuilder_openStream()
1128 * @return actual number of samples frame
1129 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001130AAUDIO_API int32_t AAudioStream_getSamplesPerFrame(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burke74240d2017-08-03 15:25:43 -07001131
1132/**
Phil Burk3316d5e2017-02-15 11:23:01 -08001133 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burke2155ef2017-02-24 13:50:29 -08001134 * @return actual device ID
Phil Burk5ed503c2017-02-01 09:38:15 -08001135 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001136AAUDIO_API int32_t AAudioStream_getDeviceId(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001137
1138/**
Phil Burk3316d5e2017-02-15 11:23:01 -08001139 * @param stream reference provided by AAudioStreamBuilder_openStream()
1140 * @return actual data format
Phil Burk5ed503c2017-02-01 09:38:15 -08001141 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001142AAUDIO_API aaudio_format_t AAudioStream_getFormat(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001143
1144/**
1145 * Provide actual sharing mode.
Phil Burk3316d5e2017-02-15 11:23:01 -08001146 * @param stream reference provided by AAudioStreamBuilder_openStream()
1147 * @return actual sharing mode
Phil Burk5ed503c2017-02-01 09:38:15 -08001148 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001149AAUDIO_API aaudio_sharing_mode_t AAudioStream_getSharingMode(AAudioStream* stream)
1150 __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001151
1152/**
Phil Burke2fbb592017-05-01 15:05:52 -07001153 * Get the performance mode used by the stream.
1154 *
1155 * @param stream reference provided by AAudioStreamBuilder_openStream()
1156 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001157AAUDIO_API aaudio_performance_mode_t AAudioStream_getPerformanceMode(AAudioStream* stream)
1158 __INTRODUCED_IN(26);
Phil Burke2fbb592017-05-01 15:05:52 -07001159
1160/**
Phil Burk3316d5e2017-02-15 11:23:01 -08001161 * @param stream reference provided by AAudioStreamBuilder_openStream()
1162 * @return direction
Phil Burk5ed503c2017-02-01 09:38:15 -08001163 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001164AAUDIO_API aaudio_direction_t AAudioStream_getDirection(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001165
1166/**
1167 * Passes back the number of frames that have been written since the stream was created.
Phil Burk8149eed2018-05-24 14:09:46 -07001168 * For an output stream, this will be advanced by the application calling write()
1169 * or by a data callback.
Phil Burk3316d5e2017-02-15 11:23:01 -08001170 * For an input stream, this will be advanced by the endpoint.
Phil Burk5ed503c2017-02-01 09:38:15 -08001171 *
1172 * The frame position is monotonically increasing.
1173 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001174 * @param stream reference provided by AAudioStreamBuilder_openStream()
1175 * @return frames written
Phil Burk5ed503c2017-02-01 09:38:15 -08001176 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001177AAUDIO_API int64_t AAudioStream_getFramesWritten(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001178
1179/**
1180 * Passes back the number of frames that have been read since the stream was created.
Phil Burk3316d5e2017-02-15 11:23:01 -08001181 * For an output stream, this will be advanced by the endpoint.
Phil Burk8149eed2018-05-24 14:09:46 -07001182 * For an input stream, this will be advanced by the application calling read()
1183 * or by a data callback.
Phil Burk5ed503c2017-02-01 09:38:15 -08001184 *
1185 * The frame position is monotonically increasing.
1186 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001187 * @param stream reference provided by AAudioStreamBuilder_openStream()
1188 * @return frames read
Phil Burk5ed503c2017-02-01 09:38:15 -08001189 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001190AAUDIO_API int64_t AAudioStream_getFramesRead(AAudioStream* stream) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001191
1192/**
Phil Burk7e7dcaa2018-01-03 15:16:15 -08001193 * Passes back the session ID associated with this stream.
1194 *
1195 * The session ID can be used to associate a stream with effects processors.
1196 * The effects are controlled using the Android AudioEffect Java API.
1197 *
1198 * If AAudioStreamBuilder_setSessionId() was called with AAUDIO_SESSION_ID_ALLOCATE
1199 * then a new session ID should be allocated once when the stream is opened.
1200 *
1201 * If AAudioStreamBuilder_setSessionId() was called with a previously allocated
1202 * session ID then that value should be returned.
1203 *
1204 * If AAudioStreamBuilder_setSessionId() was not called then this function should
1205 * return AAUDIO_SESSION_ID_NONE.
1206 *
1207 * The sessionID for a stream should not change once the stream has been opened.
1208 *
Phil Burk42452c02018-04-10 12:43:33 -07001209 * Added in API level 28.
1210 *
Phil Burk7e7dcaa2018-01-03 15:16:15 -08001211 * @param stream reference provided by AAudioStreamBuilder_openStream()
1212 * @return session ID or AAUDIO_SESSION_ID_NONE
1213 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001214AAUDIO_API aaudio_session_id_t AAudioStream_getSessionId(AAudioStream* stream) __INTRODUCED_IN(28);
Phil Burk7e7dcaa2018-01-03 15:16:15 -08001215
1216/**
Phil Burk5ed503c2017-02-01 09:38:15 -08001217 * Passes back the time at which a particular frame was presented.
1218 * This can be used to synchronize audio with video or MIDI.
1219 * It can also be used to align a recorded stream with a playback stream.
1220 *
1221 * Timestamps are only valid when the stream is in AAUDIO_STREAM_STATE_STARTED.
1222 * AAUDIO_ERROR_INVALID_STATE will be returned if the stream is not started.
1223 * Note that because requestStart() is asynchronous, timestamps will not be valid until
1224 * a short time after calling requestStart().
1225 * So AAUDIO_ERROR_INVALID_STATE should not be considered a fatal error.
1226 * Just try calling again later.
1227 *
1228 * If an error occurs, then the position and time will not be modified.
1229 *
1230 * The position and time passed back are monotonically increasing.
1231 *
Phil Burk3316d5e2017-02-15 11:23:01 -08001232 * @param stream reference provided by AAudioStreamBuilder_openStream()
Phil Burkec159502017-07-25 17:33:47 -07001233 * @param clockid CLOCK_MONOTONIC or CLOCK_BOOTTIME
Phil Burk5ed503c2017-02-01 09:38:15 -08001234 * @param framePosition pointer to a variable to receive the position
1235 * @param timeNanoseconds pointer to a variable to receive the time
1236 * @return AAUDIO_OK or a negative error
1237 */
Phil Burke2155ef2017-02-24 13:50:29 -08001238AAUDIO_API aaudio_result_t AAudioStream_getTimestamp(AAudioStream* stream,
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001239 clockid_t clockid, int64_t *framePosition, int64_t *timeNanoseconds) __INTRODUCED_IN(26);
Phil Burk5ed503c2017-02-01 09:38:15 -08001240
Phil Burk361b1422017-12-20 14:24:16 -08001241/**
1242 * Return the use case for the stream.
1243 *
Phil Burk42452c02018-04-10 12:43:33 -07001244 * Added in API level 28.
1245 *
Phil Burk361b1422017-12-20 14:24:16 -08001246 * @param stream reference provided by AAudioStreamBuilder_openStream()
1247 * @return frames read
1248 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001249AAUDIO_API aaudio_usage_t AAudioStream_getUsage(AAudioStream* stream) __INTRODUCED_IN(28);
Phil Burk361b1422017-12-20 14:24:16 -08001250
1251/**
1252 * Return the content type for the stream.
1253 *
Phil Burk42452c02018-04-10 12:43:33 -07001254 * Added in API level 28.
1255 *
Phil Burk361b1422017-12-20 14:24:16 -08001256 * @param stream reference provided by AAudioStreamBuilder_openStream()
1257 * @return content type, for example AAUDIO_CONTENT_TYPE_MUSIC
1258 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001259AAUDIO_API aaudio_content_type_t AAudioStream_getContentType(AAudioStream* stream)
1260 __INTRODUCED_IN(28);
Phil Burk361b1422017-12-20 14:24:16 -08001261
1262/**
1263 * Return the input preset for the stream.
1264 *
Phil Burk42452c02018-04-10 12:43:33 -07001265 * Added in API level 28.
1266 *
Phil Burk361b1422017-12-20 14:24:16 -08001267 * @param stream reference provided by AAudioStreamBuilder_openStream()
1268 * @return input preset, for example AAUDIO_INPUT_PRESET_CAMCORDER
1269 */
Elliott Hughes233ce1b2018-06-18 13:17:24 -07001270AAUDIO_API aaudio_input_preset_t AAudioStream_getInputPreset(AAudioStream* stream)
1271 __INTRODUCED_IN(28);
Phil Burk361b1422017-12-20 14:24:16 -08001272
Phil Burk5ed503c2017-02-01 09:38:15 -08001273#ifdef __cplusplus
1274}
1275#endif
1276
1277#endif //AAUDIO_AAUDIO_H
Phil Burka45be8b2017-04-05 14:45:48 -07001278
1279/** @} */