Audio

Summary

Enumerations

Anonymous Enum 0{
  AAUDIO_DIRECTION_OUTPUT,
  AAUDIO_DIRECTION_INPUT
}
enum
Anonymous Enum 1{
  AAUDIO_FORMAT_INVALID = -1,
  AAUDIO_FORMAT_UNSPECIFIED = 0,
  AAUDIO_FORMAT_PCM_I16,
  AAUDIO_FORMAT_PCM_FLOAT,
  AAUDIO_FORMAT_PCM_I24_PACKED,
  AAUDIO_FORMAT_PCM_I32,
  AAUDIO_FORMAT_IEC61937,
  AAUDIO_FORMAT_MP3,
  AAUDIO_FORMAT_AAC_LC,
  AAUDIO_FORMAT_AAC_HE_V1,
  AAUDIO_FORMAT_AAC_HE_V2,
  AAUDIO_FORMAT_AAC_ELD,
  AAUDIO_FORMAT_AAC_XHE,
  AAUDIO_FORMAT_OPUS
}
enum
Anonymous Enum 10{
  AAUDIO_ALLOW_CAPTURE_BY_ALL = 1,
  AAUDIO_ALLOW_CAPTURE_BY_SYSTEM = 2,
  AAUDIO_ALLOW_CAPTURE_BY_NONE = 3
}
enum
Specifying if audio may or may not be captured by other apps or the system.
Anonymous Enum 11{
  AAUDIO_SESSION_ID_NONE = -1,
  AAUDIO_SESSION_ID_ALLOCATE = 0
}
enum
These may be used with AAudioStreamBuilder_setSessionId().
Anonymous Enum 12{
  AAUDIO_CHANNEL_INVALID = -1,
  AAUDIO_CHANNEL_FRONT_LEFT = 1 << 0,
  AAUDIO_CHANNEL_FRONT_RIGHT = 1 << 1,
  AAUDIO_CHANNEL_FRONT_CENTER = 1 << 2,
  AAUDIO_CHANNEL_LOW_FREQUENCY = 1 << 3,
  AAUDIO_CHANNEL_BACK_LEFT = 1 << 4,
  AAUDIO_CHANNEL_BACK_RIGHT = 1 << 5,
  AAUDIO_CHANNEL_FRONT_LEFT_OF_CENTER = 1 << 6,
  AAUDIO_CHANNEL_FRONT_RIGHT_OF_CENTER = 1 << 7,
  AAUDIO_CHANNEL_BACK_CENTER = 1 << 8,
  AAUDIO_CHANNEL_SIDE_LEFT = 1 << 9,
  AAUDIO_CHANNEL_SIDE_RIGHT = 1 << 10,
  AAUDIO_CHANNEL_TOP_CENTER = 1 << 11,
  AAUDIO_CHANNEL_TOP_FRONT_LEFT = 1 << 12,
  AAUDIO_CHANNEL_TOP_FRONT_CENTER = 1 << 13,
  AAUDIO_CHANNEL_TOP_FRONT_RIGHT = 1 << 14,
  AAUDIO_CHANNEL_TOP_BACK_LEFT = 1 << 15,
  AAUDIO_CHANNEL_TOP_BACK_CENTER = 1 << 16,
  AAUDIO_CHANNEL_TOP_BACK_RIGHT = 1 << 17,
  AAUDIO_CHANNEL_TOP_SIDE_LEFT = 1 << 18,
  AAUDIO_CHANNEL_TOP_SIDE_RIGHT = 1 << 19,
  AAUDIO_CHANNEL_BOTTOM_FRONT_LEFT = 1 << 20,
  AAUDIO_CHANNEL_BOTTOM_FRONT_CENTER = 1 << 21,
  AAUDIO_CHANNEL_BOTTOM_FRONT_RIGHT = 1 << 22,
  AAUDIO_CHANNEL_LOW_FREQUENCY_2 = 1 << 23,
  AAUDIO_CHANNEL_FRONT_WIDE_LEFT = 1 << 24,
  AAUDIO_CHANNEL_FRONT_WIDE_RIGHT = 1 << 25,
  AAUDIO_CHANNEL_MONO = AAUDIO_CHANNEL_FRONT_LEFT,
  AAUDIO_CHANNEL_STEREO = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT,
  AAUDIO_CHANNEL_2POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_LOW_FREQUENCY,
  AAUDIO_CHANNEL_TRI = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER,
  AAUDIO_CHANNEL_TRI_BACK = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_BACK_CENTER,
  AAUDIO_CHANNEL_3POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY,
  AAUDIO_CHANNEL_2POINT0POINT2 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT,
  AAUDIO_CHANNEL_2POINT1POINT2 = AAUDIO_CHANNEL_2POINT0POINT2 | AAUDIO_CHANNEL_LOW_FREQUENCY,
  AAUDIO_CHANNEL_3POINT0POINT2 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT,
  AAUDIO_CHANNEL_3POINT1POINT2 = AAUDIO_CHANNEL_3POINT0POINT2 | AAUDIO_CHANNEL_LOW_FREQUENCY,
  AAUDIO_CHANNEL_QUAD = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT,
  AAUDIO_CHANNEL_QUAD_SIDE = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT,
  AAUDIO_CHANNEL_SURROUND = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_BACK_CENTER,
  AAUDIO_CHANNEL_PENTA = AAUDIO_CHANNEL_QUAD | AAUDIO_CHANNEL_FRONT_CENTER,
  AAUDIO_CHANNEL_5POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT,
  AAUDIO_CHANNEL_5POINT1_SIDE = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT,
  AAUDIO_CHANNEL_6POINT1 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_LOW_FREQUENCY | AAUDIO_CHANNEL_BACK_LEFT | AAUDIO_CHANNEL_BACK_RIGHT | AAUDIO_CHANNEL_BACK_CENTER,
  AAUDIO_CHANNEL_7POINT1 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT,
  AAUDIO_CHANNEL_5POINT1POINT2 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT,
  AAUDIO_CHANNEL_5POINT1POINT4 = AAUDIO_CHANNEL_5POINT1 | AAUDIO_CHANNEL_TOP_FRONT_LEFT | AAUDIO_CHANNEL_TOP_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_BACK_LEFT | AAUDIO_CHANNEL_TOP_BACK_RIGHT,
  AAUDIO_CHANNEL_7POINT1POINT2 = AAUDIO_CHANNEL_7POINT1 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT,
  AAUDIO_CHANNEL_7POINT1POINT4 = AAUDIO_CHANNEL_7POINT1 | AAUDIO_CHANNEL_TOP_FRONT_LEFT | AAUDIO_CHANNEL_TOP_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_BACK_LEFT | AAUDIO_CHANNEL_TOP_BACK_RIGHT,
  AAUDIO_CHANNEL_13POINT0 = AAUDIO_CHANNEL_FRONT_LEFT | AAUDIO_CHANNEL_FRONT_RIGHT | AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_SIDE_LEFT | AAUDIO_CHANNEL_SIDE_RIGHT | AAUDIO_CHANNEL_TOP_FRONT_LEFT | AAUDIO_CHANNEL_TOP_FRONT_RIGHT | AAUDIO_CHANNEL_TOP_FRONT_CENTER | AAUDIO_CHANNEL_TOP_BACK_LEFT | AAUDIO_CHANNEL_TOP_BACK_RIGHT | AAUDIO_CHANNEL_BOTTOM_FRONT_LEFT | AAUDIO_CHANNEL_BOTTOM_FRONT_RIGHT | AAUDIO_CHANNEL_BOTTOM_FRONT_CENTER,
  AAUDIO_CHANNEL_9POINT1POINT4 = AAUDIO_CHANNEL_7POINT1POINT4 | AAUDIO_CHANNEL_FRONT_WIDE_LEFT | AAUDIO_CHANNEL_FRONT_WIDE_RIGHT,
  AAUDIO_CHANNEL_9POINT1POINT6 = AAUDIO_CHANNEL_9POINT1POINT4 | AAUDIO_CHANNEL_TOP_SIDE_LEFT | AAUDIO_CHANNEL_TOP_SIDE_RIGHT,
  AAUDIO_CHANNEL_FRONT_BACK = AAUDIO_CHANNEL_FRONT_CENTER | AAUDIO_CHANNEL_BACK_CENTER
}
enum
Defines the audio channel mask.
Anonymous Enum 13{
  AAUDIO_CALLBACK_RESULT_CONTINUE = 0,
  AAUDIO_CALLBACK_RESULT_STOP
}
enum
Return one of these values from the data callback function.
Anonymous Enum 14{
  AAUDIO_POLICY_NEVER = 1,
  AAUDIO_POLICY_AUTO,
  AAUDIO_POLICY_ALWAYS
}
enum
When the audio is played/recorded via AAudio MMAP data path, the apps can write to/read from a shared memory that will also be accessed directly by hardware.
Anonymous Enum 2{
  AAUDIO_OK,
  AAUDIO_ERROR_BASE = -900,
  AAUDIO_ERROR_DISCONNECTED,
  AAUDIO_ERROR_ILLEGAL_ARGUMENT,
  AAUDIO_ERROR_INTERNAL = AAUDIO_ERROR_ILLEGAL_ARGUMENT + 2,
  AAUDIO_ERROR_INVALID_STATE,
  AAUDIO_ERROR_INVALID_HANDLE = AAUDIO_ERROR_INVALID_STATE + 3,
  AAUDIO_ERROR_UNIMPLEMENTED = AAUDIO_ERROR_INVALID_HANDLE + 2,
  AAUDIO_ERROR_UNAVAILABLE,
  AAUDIO_ERROR_NO_FREE_HANDLES,
  AAUDIO_ERROR_NO_MEMORY,
  AAUDIO_ERROR_NULL,
  AAUDIO_ERROR_TIMEOUT,
  AAUDIO_ERROR_WOULD_BLOCK,
  AAUDIO_ERROR_INVALID_FORMAT,
  AAUDIO_ERROR_OUT_OF_RANGE,
  AAUDIO_ERROR_NO_SERVICE,
  AAUDIO_ERROR_INVALID_RATE
}
enum
These result codes are returned from AAudio functions to indicate success or failure.
Anonymous Enum 3{
  AAUDIO_STREAM_STATE_UNINITIALIZED = 0,
  AAUDIO_STREAM_STATE_UNKNOWN,
  AAUDIO_STREAM_STATE_OPEN,
  AAUDIO_STREAM_STATE_STARTING,
  AAUDIO_STREAM_STATE_STARTED,
  AAUDIO_STREAM_STATE_PAUSING,
  AAUDIO_STREAM_STATE_PAUSED,
  AAUDIO_STREAM_STATE_FLUSHING,
  AAUDIO_STREAM_STATE_FLUSHED,
  AAUDIO_STREAM_STATE_STOPPING,
  AAUDIO_STREAM_STATE_STOPPED,
  AAUDIO_STREAM_STATE_CLOSING,
  AAUDIO_STREAM_STATE_CLOSED,
  AAUDIO_STREAM_STATE_DISCONNECTED
}
enum
AAudio Stream states, for details, refer to Using an Audio Stream
Anonymous Enum 4{
  AAUDIO_SHARING_MODE_EXCLUSIVE,
  AAUDIO_SHARING_MODE_SHARED
}
enum
Anonymous Enum 5{
  AAUDIO_PERFORMANCE_MODE_NONE = 10,
  AAUDIO_PERFORMANCE_MODE_POWER_SAVING,
  AAUDIO_PERFORMANCE_MODE_LOW_LATENCY,
  AAUDIO_PERFORMANCE_MODE_POWER_SAVING_OFFLOADED
}
enum
Anonymous Enum 6{
  AAUDIO_USAGE_MEDIA = 1,
  AAUDIO_USAGE_VOICE_COMMUNICATION = 2,
  AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING = 3,
  AAUDIO_USAGE_ALARM = 4,
  AAUDIO_USAGE_NOTIFICATION = 5,
  AAUDIO_USAGE_NOTIFICATION_RINGTONE = 6,
  AAUDIO_USAGE_NOTIFICATION_EVENT = 10,
  AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY = 11,
  AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE = 12,
  AAUDIO_USAGE_ASSISTANCE_SONIFICATION = 13,
  AAUDIO_USAGE_GAME = 14,
  AAUDIO_USAGE_ASSISTANT = 16,
  AAUDIO_SYSTEM_USAGE_EMERGENCY = AAUDIO_SYSTEM_USAGE_OFFSET,
  AAUDIO_SYSTEM_USAGE_SAFETY = AAUDIO_SYSTEM_USAGE_OFFSET + 1,
  AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS = AAUDIO_SYSTEM_USAGE_OFFSET + 2,
  AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT = AAUDIO_SYSTEM_USAGE_OFFSET + 3
}
enum
The USAGE attribute expresses "why" you are playing a sound, what is this sound used for.
Anonymous Enum 7{
  AAUDIO_CONTENT_TYPE_SPEECH = 1,
  AAUDIO_CONTENT_TYPE_MUSIC = 2,
  AAUDIO_CONTENT_TYPE_MOVIE = 3,
  AAUDIO_CONTENT_TYPE_SONIFICATION = 4
}
enum
The CONTENT_TYPE attribute describes "what" you are playing.
Anonymous Enum 8{
  AAUDIO_SPATIALIZATION_BEHAVIOR_AUTO = 1,
  AAUDIO_SPATIALIZATION_BEHAVIOR_NEVER = 2
}
enum
Anonymous Enum 9{
  AAUDIO_INPUT_PRESET_GENERIC = 1,
  AAUDIO_INPUT_PRESET_CAMCORDER = 5,
  AAUDIO_INPUT_PRESET_VOICE_RECOGNITION = 6,
  AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION = 7,
  AAUDIO_INPUT_PRESET_UNPROCESSED = 9,
  AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE = 10,
  AAUDIO_INPUT_PRESET_SYSTEM_ECHO_REFERENCE = 1997,
  AAUDIO_INPUT_PRESET_SYSTEM_HOTWORD = 1999
}
enum
Defines the audio source.
AAudio_DeviceType{
  AAUDIO_DEVICE_BUILTIN_EARPIECE = 1,
  AAUDIO_DEVICE_BUILTIN_SPEAKER = 2,
  AAUDIO_DEVICE_WIRED_HEADSET = 3,
  AAUDIO_DEVICE_WIRED_HEADPHONES = 4,
  AAUDIO_DEVICE_LINE_ANALOG = 5,
  AAUDIO_DEVICE_LINE_DIGITAL = 6,
  AAUDIO_DEVICE_BLUETOOTH_SCO = 7,
  AAUDIO_DEVICE_BLUETOOTH_A2DP = 8,
  AAUDIO_DEVICE_HDMI = 9,
  AAUDIO_DEVICE_HDMI_ARC = 10,
  AAUDIO_DEVICE_USB_DEVICE = 11,
  AAUDIO_DEVICE_USB_ACCESSORY = 12,
  AAUDIO_DEVICE_DOCK = 13,
  AAUDIO_DEVICE_FM = 14,
  AAUDIO_DEVICE_BUILTIN_MIC = 15,
  AAUDIO_DEVICE_FM_TUNER = 16,
  AAUDIO_DEVICE_TV_TUNER = 17,
  AAUDIO_DEVICE_TELEPHONY = 18,
  AAUDIO_DEVICE_AUX_LINE = 19,
  AAUDIO_DEVICE_IP = 20,
  AAUDIO_DEVICE_BUS = 21,
  AAUDIO_DEVICE_USB_HEADSET = 22,
  AAUDIO_DEVICE_HEARING_AID = 23,
  AAUDIO_DEVICE_BUILTIN_SPEAKER_SAFE = 24,
  AAUDIO_DEVICE_REMOTE_SUBMIX = 25,
  AAUDIO_DEVICE_BLE_HEADSET = 26,
  AAUDIO_DEVICE_BLE_SPEAKER = 27,
  AAUDIO_DEVICE_HDMI_EARC = 29,
  AAUDIO_DEVICE_BLE_BROADCAST = 30,
  AAUDIO_DEVICE_DOCK_ANALOG = 31,
  AAUDIO_DEVICE_BLE_HEARING_AID = 32,
  AAUDIO_DEVICE_BLE_CENTRAL = 33,
  AAUDIO_DEVICE_BLE_CENTRAL_BROADCAST = 34
}
enum
AAudio_FallbackMode{
  AAUDIO_FALLBACK_MODE_DEFAULT = 0,
  AAUDIO_FALLBACK_MODE_MUTE = 1,
  AAUDIO_FALLBACK_MODE_FAIL = 2
}
enum
Behavior when the values for speed and / or pitch are out of the applicable range.
AAudio_FlushFromAccuracy{
  AAUDIO_FLUSH_FROM_ACCURACY_UNDEFINED = 0,
  AAUDIO_FLUSH_FROM_FRAME_ACCURATE = 1
}
enum
The values are defined to be used for the accuracy requirement when calling value to indicate #flushWrittenFramesFromPosition(long, int) is not supported.
AAudio_FlushFromFrameSupport{
  AAUDIO_FLUSH_FROM_FRAME_UNSUPPORTED = 0,
  AAUDIO_FLUSH_FROM_FRAME_SUPPORTED = 1 << 0
}
enum
The constants for the levels of flush from frame support.
AAudio_StretchMode{
  AAUDIO_STRETCH_MODE_DEFAULT = 0,
  AAUDIO_STRETCH_MODE_VOICE = 1
}
enum
Algorithms used for time-stretching (preserving pitch while playing audio content at different speed).

Typedefs

AAudioPlaybackParameters typedef
Structure for common playback params.
AAudioStream typedef
struct AAudioStreamStruct
AAudioStreamBuilder typedef
struct AAudioStreamBuilderStruct
AAudioStream_dataCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, void *_Nonnull audioData, int32_t numFrames) typedef
aaudio_data_callback_result_t(*
Prototype for the data function that is passed to AAudioStreamBuilder_setDataCallback().
AAudioStream_errorCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, aaudio_result_t error) typedef
void(*
Prototype for the callback function that is passed to AAudioStreamBuilder_setErrorCallback().
AAudioStream_partialDataCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, void *_Nonnull audioData, int32_t numFrames) typedef
int32_t(*
Prototype for the data function that is passed to AAudioStreamBuilder_setPartialDataCallback().
AAudioStream_presentationEndCallback)(AAudioStream *_Nonnull stream, void *_Null_unspecified userData) typedef
void(*
Prototype for the callback function that is passed to AAudioStreamBuilder_setPresentationEndCallback().
AAudioStream_routingChangedCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, const int32_t *_Nonnull deviceIds, int32_t numDevices) typedef
void(*
Prototype for the routing changed function that is passed to AAudioStreamBuilder_setRoutingChangedCallback.
AAudio_DeviceType typedef
AAudio_FallbackMode typedef
Behavior when the values for speed and / or pitch are out of the applicable range.
AAudio_FlushFromAccuracy typedef
The values are defined to be used for the accuracy requirement when calling value to indicate #flushWrittenFramesFromPosition(long, int) is not supported.
AAudio_FlushFromFrameSupport typedef
The constants for the levels of flush from frame support.
AAudio_StretchMode typedef
Algorithms used for time-stretching (preserving pitch while playing audio content at different speed).
aaudio_allowed_capture_policy_t typedef
int32_t
aaudio_channel_mask_t typedef
uint32_t
aaudio_content_type_t typedef
int32_t
aaudio_data_callback_result_t typedef
int32_t
aaudio_direction_t typedef
int32_t
aaudio_format_t typedef
int32_t
aaudio_input_preset_t typedef
int32_t
aaudio_performance_mode_t typedef
int32_t
aaudio_policy_t typedef
int32_t
aaudio_result_t typedef
int32_t
aaudio_session_id_t typedef
int32_t
aaudio_sharing_mode_t typedef
int32_t
aaudio_spatialization_behavior_t typedef
int32_t
aaudio_stream_state_t typedef
int32_t
aaudio_usage_t typedef
int32_t

Functions

AAudioStreamBuilder_delete(AAudioStreamBuilder *_Nonnull builder)
AAUDIO_API aaudio_result_t
Delete the resources associated with the StreamBuilder.
AAudioStreamBuilder_openStream(AAudioStreamBuilder *_Nonnull builder, AAudioStream *_Nullable *_Nonnull stream)
AAUDIO_API aaudio_result_t
Open a stream based on the options in the StreamBuilder.
AAudioStreamBuilder_setAllowedCapturePolicy(AAudioStreamBuilder *_Nonnull builder, aaudio_allowed_capture_policy_t capturePolicy)
AAUDIO_API void
Specify whether this stream audio may or may not be captured by other apps or the system.
AAudioStreamBuilder_setAttributionTag(AAudioStreamBuilder *_Nonnull builder, const char *_Nonnull attributionTag)
AAUDIO_API void
Declare the attribution tag of the context creating the stream.
AAudioStreamBuilder_setBufferCapacityInFrames(AAudioStreamBuilder *_Nonnull builder, int32_t numFrames)
AAUDIO_API void
Set the requested buffer capacity in frames.
AAudioStreamBuilder_setChannelCount(AAudioStreamBuilder *_Nonnull builder, int32_t channelCount)
AAUDIO_API void
Request a number of channels for the stream.
AAudioStreamBuilder_setChannelMask(AAudioStreamBuilder *_Nonnull builder, aaudio_channel_mask_t channelMask)
AAUDIO_API void
Set audio channel mask for the stream.
AAudioStreamBuilder_setContentType(AAudioStreamBuilder *_Nonnull builder, aaudio_content_type_t contentType)
AAUDIO_API void
Set the type of audio data that the output stream will carry.
AAudioStreamBuilder_setDataCallback(AAudioStreamBuilder *_Nonnull builder, AAudioStream_dataCallback_Nullable callback, void *_Nullable userData)
AAUDIO_API void
Request that AAudio call this functions when the stream is running.
AAudioStreamBuilder_setDeviceId(AAudioStreamBuilder *_Nonnull builder, int32_t deviceId)
AAUDIO_API void
Request an audio device identified by an ID.
AAudioStreamBuilder_setDirection(AAudioStreamBuilder *_Nonnull builder, aaudio_direction_t direction)
AAUDIO_API void
Request the direction for a stream.
AAudioStreamBuilder_setErrorCallback(AAudioStreamBuilder *_Nonnull builder, AAudioStream_errorCallback_Nullable callback, void *_Nullable userData)
AAUDIO_API void
Request that AAudio call this function if any error occurs or the stream is disconnected.
AAudioStreamBuilder_setFormat(AAudioStreamBuilder *_Nonnull builder, aaudio_format_t format)
AAUDIO_API void
Request a sample data format, for example AAUDIO_FORMAT_PCM_I16.
AAudioStreamBuilder_setFramesPerDataCallback(AAudioStreamBuilder *_Nonnull builder, int32_t numFrames)
AAUDIO_API void
Set the requested data callback buffer size in frames.
AAudioStreamBuilder_setInputPreset(AAudioStreamBuilder *_Nonnull builder, aaudio_input_preset_t inputPreset)
AAUDIO_API void
Set the input (capture) preset for the stream.
AAudioStreamBuilder_setIsContentSpatialized(AAudioStreamBuilder *_Nonnull builder, bool isSpatialized)
AAUDIO_API void
Specifies whether the audio data of this output stream has already been processed for spatialization.
AAudioStreamBuilder_setPackageName(AAudioStreamBuilder *_Nonnull builder, const char *_Nonnull packageName)
AAUDIO_API void
Declare the name of the package creating the stream.
AAudioStreamBuilder_setPartialDataCallback(AAudioStreamBuilder *_Nonnull builder, AAudioStream_partialDataCallback_Nullable callback, void *_Nullable userData)
AAUDIO_API aaudio_result_t
Request that AAudio call this functions when the stream is running.
AAudioStreamBuilder_setPerformanceMode(AAudioStreamBuilder *_Nonnull builder, aaudio_performance_mode_t mode)
AAUDIO_API void
Set the requested performance mode.
AAudioStreamBuilder_setPresentationEndCallback(AAudioStreamBuilder *_Nonnull builder, AAudioStream_presentationEndCallback _Nonnull callback, void *_Nullable userData)
AAUDIO_API void
Request that AAudio call this function when all the buffers of an offloaded stream that were queued in the audio system (e.g.
AAudioStreamBuilder_setPrivacySensitive(AAudioStreamBuilder *_Nonnull builder, bool privacySensitive)
AAUDIO_API void
Indicates whether this input stream must be marked as privacy sensitive or not.
AAudioStreamBuilder_setRoutingChangedCallback(AAudioStreamBuilder *_Nonnull builder, AAudioStream_routingChangedCallback _Nonnull callback, void *_Nullable userData)
AAUDIO_API void
Request that AAudio call this function when the routed devices for the stream are changed.
AAudioStreamBuilder_setSampleRate(AAudioStreamBuilder *_Nonnull builder, int32_t sampleRate)
AAUDIO_API void
Request a sample rate in Hertz.
AAudioStreamBuilder_setSamplesPerFrame(AAudioStreamBuilder *_Nonnull builder, int32_t samplesPerFrame)
AAUDIO_API void
Deprecated. use AAudioStreamBuilder_setChannelCount
AAudioStreamBuilder_setSessionId(AAudioStreamBuilder *_Nonnull builder, aaudio_session_id_t sessionId)
AAUDIO_API void
Set the requested session ID.
AAudioStreamBuilder_setSharingMode(AAudioStreamBuilder *_Nonnull builder, aaudio_sharing_mode_t sharingMode)
AAUDIO_API void
Request a mode for sharing the device.
AAudioStreamBuilder_setSpatializationBehavior(AAudioStreamBuilder *_Nonnull builder, aaudio_spatialization_behavior_t spatializationBehavior)
AAUDIO_API void
Sets the behavior affecting whether spatialization will be used.
AAudioStreamBuilder_setUsage(AAudioStreamBuilder *_Nonnull builder, aaudio_usage_t usage)
AAUDIO_API void
Set the intended use case for the output stream.
AAudioStream_close(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_result_t
Delete the internal data structures associated with the stream created by AAudioStreamBuilder_openStream().
AAudioStream_flushFromFrame(AAudioStream *_Nonnull stream, AAudio_FlushFromAccuracy accuracy, int64_t *_Nonnull inOutPosition)
AAUDIO_API aaudio_result_t
Flush all data from given position.
AAudioStream_getAllowedCapturePolicy(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_allowed_capture_policy_t
Return the policy that determines whether the audio may or may not be captured by other apps or the system.
AAudioStream_getBufferCapacityInFrames(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Query maximum buffer capacity in frames.
AAudioStream_getBufferSizeInFrames(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Query the maximum number of frames that can be filled without blocking.
AAudioStream_getChannelCount(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
A stream has one or more channels of data.
AAudioStream_getChannelMask(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_channel_mask_t
Return the channel mask for the stream.
AAudioStream_getContentType(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_content_type_t
Return the content type for the stream.
AAudioStream_getDeviceId(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Available since API level 26.
AAudioStream_getDeviceIds(AAudioStream *_Nonnull stream, int32_t *_Nullable ids, int32_t *_Nullable numIds)
AAUDIO_API aaudio_result_t
Call this function after AAudioStreamBuilder_openStream().
AAudioStream_getDirection(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_direction_t
Available since API level 26.
AAudioStream_getFormat(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_format_t
Available since API level 26.
AAudioStream_getFramesPerBurst(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Query the number of frames that the application should read or write at one time for optimal performance.
AAudioStream_getFramesPerDataCallback(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Query the size of the buffer that will be passed to the dataProc callback in the numFrames parameter.
AAudioStream_getFramesRead(AAudioStream *_Nonnull stream)
AAUDIO_API int64_t
Passes back the number of frames that have been read since the stream was created.
AAudioStream_getFramesWritten(AAudioStream *_Nonnull stream)
AAUDIO_API int64_t
Passes back the number of frames that have been written since the stream was created.
AAudioStream_getHardwareChannelCount(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
There may be channel conversions in the Audio framework.
AAudioStream_getHardwareFormat(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_format_t
There may be data format conversions in the Audio framework.
AAudioStream_getHardwareSampleRate(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
There may be sample rate conversions in the Audio framework.
AAudioStream_getInputPreset(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_input_preset_t
Return the input preset for the stream.
AAudioStream_getOffloadDelay(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Return the decoder delay of an offloaded stream in frames.
AAudioStream_getOffloadPadding(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Return the decoder padding of an offloaded stream in frames.
AAudioStream_getPerformanceMode(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_performance_mode_t
Get the performance mode used by the stream.
AAudioStream_getPlaybackParameters(AAudioStream *_Nonnull stream, AAudioPlaybackParameters *_Nonnull outParameters)
AAUDIO_API aaudio_result_t
Get current playback parameters for the given stream.
AAudioStream_getSampleRate(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
Available since API level 26.
AAudioStream_getSamplesPerFrame(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
AAudioStream_getSessionId(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_session_id_t
Passes back the session ID associated with this stream.
AAudioStream_getSharingMode(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_sharing_mode_t
Provide actual sharing mode.
AAudioStream_getSpatializationBehavior(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_spatialization_behavior_t
Return the spatialization behavior for the stream.
AAudioStream_getState(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_stream_state_t
Query the current state of the client, eg.
AAudioStream_getTimestamp(AAudioStream *_Nonnull stream, clockid_t clockid, int64_t *_Nonnull framePosition, int64_t *_Nonnull timeNanoseconds)
AAUDIO_API aaudio_result_t
Returns the time at which a particular frame was played on a speaker or headset, or was recorded on a microphone.
AAudioStream_getUsage(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_usage_t
Return the use case for the stream.
AAudioStream_getXRunCount(AAudioStream *_Nonnull stream)
AAUDIO_API int32_t
An XRun is an Underrun or an Overrun.
AAudioStream_isContentSpatialized(AAudioStream *_Nonnull stream)
AAUDIO_API bool
Return whether the content of the stream is spatialized.
AAudioStream_isMMapUsed(AAudioStream *_Nonnull stream)
AAUDIO_API bool
Return true if the stream uses the MMAP data path versus the legacy path.
AAudioStream_isPrivacySensitive(AAudioStream *_Nonnull stream)
AAUDIO_API bool
Return whether this input stream is marked as privacy sensitive or not.
AAudioStream_read(AAudioStream *_Nonnull stream, void *_Nonnull buffer, int32_t numFrames, int64_t timeoutNanoseconds)
AAUDIO_API aaudio_result_t
Read data from the stream.
AAudioStream_release(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_result_t
Free the audio resources associated with a stream created by AAudioStreamBuilder_openStream().
AAudioStream_requestFlush(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_result_t
Asynchronous request for the stream to flush.
AAudioStream_requestPause(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_result_t
Asynchronous request for the stream to pause.
AAudioStream_requestStart(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_result_t
Asynchronously request to start playing the stream.
AAudioStream_requestStop(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_result_t
Asynchronous request for the stream to stop.
AAudioStream_setBufferSizeInFrames(AAudioStream *_Nonnull stream, int32_t numFrames)
AAUDIO_API aaudio_result_t
This can be used to adjust the latency of the buffer by changing the threshold where blocking will occur.
AAudioStream_setOffloadDelayPadding(AAudioStream *_Nonnull stream, int32_t delayInFrames, int32_t paddingInFrames)
AAUDIO_API aaudio_result_t
Configures the delay and padding values for the current stream playing in offload mode.
AAudioStream_setOffloadEndOfStream(AAudioStream *_Nonnull stream)
AAUDIO_API aaudio_result_t
Declares that the last data writing operation on this stream provided the last buffer of this stream.
AAudioStream_setPlaybackParameters(AAudioStream *_Nonnull stream, const AAudioPlaybackParameters *_Nonnull parameters)
AAUDIO_API aaudio_result_t
Set playback parameters for the given stream.
AAudioStream_waitForStateChange(AAudioStream *_Nonnull stream, aaudio_stream_state_t inputState, aaudio_stream_state_t *_Nullable nextState, int64_t timeoutNanoseconds)
AAUDIO_API aaudio_result_t
Wait until the current state no longer matches the input state.
AAudioStream_write(AAudioStream *_Nonnull stream, const void *_Nonnull buffer, int32_t numFrames, int64_t timeoutNanoseconds)
AAUDIO_API aaudio_result_t
Write data to the stream.
AAudio_convertResultToText(aaudio_result_t returnCode)
AAUDIO_API const char *_Nonnull
The text is the ASCII symbol corresponding to the returnCode, or an English message saying the returnCode is unrecognized.
AAudio_convertStreamStateToText(aaudio_stream_state_t state)
AAUDIO_API const char *_Nonnull
The text is the ASCII symbol corresponding to the stream state, or an English message saying the state is unrecognized.
AAudio_createStreamBuilder(AAudioStreamBuilder *_Nullable *_Nonnull builder)
AAUDIO_API aaudio_result_t
Create a StreamBuilder that can be used to open a Stream.
AAudio_getFlushFromFrameSupport(const AAudioStreamBuilder *_Nonnull builder)
Returns a bit mask representing the current feature support for AAudioStream_flushFromFrame for the AudioStream that would be created with the given AAudioStreamBuilder.
AAudio_getMMapPolicy()
AAUDIO_API aaudio_policy_t
Get the current MMAP policy set by AAudio_setMMapPolicy().
AAudio_getPlatformMMapExclusivePolicy(AAudio_DeviceType device, aaudio_direction_t direction)
AAUDIO_API aaudio_policy_t
Query how aaudio exclusive mmap is supported for the given device type.
AAudio_getPlatformMMapPolicy(AAudio_DeviceType device, aaudio_direction_t direction)
AAUDIO_API aaudio_policy_t
Query how aaudio mmap is supported for the given device type.
AAudio_setMMapPolicy(aaudio_policy_t policy)
AAUDIO_API aaudio_result_t
Control whether AAudioStreamBuilder_openStream() will use the new MMAP data path or the older "Legacy" data path.

Structs

AAudioPlaybackParameters

Structure for common playback params.

Enumerations

Anonymous Enum 0

Declared in aaudio/AAudio.h
 Anonymous Enum 0
Properties
AAUDIO_DIRECTION_INPUT

Audio data will travel into the device, for example from a microphone.

AAUDIO_DIRECTION_OUTPUT

Audio data will travel out of the device, for example through a speaker.

Anonymous Enum 1

Declared in aaudio/AAudio.h
 Anonymous Enum 1
Properties
AAUDIO_FORMAT_AAC_ELD

This format is used for audio compressed in AAC ELD format.

Available since API level 36.

AAUDIO_FORMAT_AAC_HE_V1

This format is used for audio compressed in AAC HE V1 format.

Available since API level 36.

AAUDIO_FORMAT_AAC_HE_V2

This format is used for audio compressed in AAC HE V2 format.

Available since API level 36.

AAUDIO_FORMAT_AAC_LC

This format is used for audio compressed in AAC LC format.

Available since API level 36.

AAUDIO_FORMAT_AAC_XHE

This format is used for audio compressed in AAC XHE format.

Available since API level 36.

AAUDIO_FORMAT_IEC61937

This format is used for compressed audio wrapped in IEC61937 for HDMI or S/PDIF passthrough.

Unlike PCM playback, the Android framework is not able to do format conversion for IEC61937. In that case, when IEC61937 is requested, sampling rate and channel count or channel mask must be specified. Otherwise, it may fail when opening the stream. Apps are able to get the correct configuration for the playback by calling AudioManager::getDevices(int).

Available since API level 34.

AAUDIO_FORMAT_INVALID
AAUDIO_FORMAT_MP3

This format is used for audio compressed in MP3 format.

Available since API level 36.

AAUDIO_FORMAT_OPUS

This format is used for audio compressed in OPUS.

Available since API level 36.

AAUDIO_FORMAT_PCM_FLOAT

This format uses the float data type.

The nominal range of the data is [-1.0f, 1.0f). Values outside that range may be clipped.

See also the float Data in write(float[], int, int, int).

AAUDIO_FORMAT_PCM_I16

This format uses the int16_t data type.

The maximum range of the data is -32768 (0x8000) to 32767 (0x7FFF).

AAUDIO_FORMAT_PCM_I24_PACKED

This format uses 24-bit samples packed into 3 bytes.

The bytes are in little-endian order, so the least significant byte comes first in the byte array.

The maximum range of the data is -8388608 (0x800000) to 8388607 (0x7FFFFF).

Note that the lower precision bits may be ignored by the device.

Available since API level 31.

AAUDIO_FORMAT_PCM_I32

This format uses 32-bit samples stored in an int32_t data type.

The maximum range of the data is -2147483648 (0x80000000) to 2147483647 (0x7FFFFFFF).

Note that the lower precision bits may be ignored by the device.

Available since API level 31.

AAUDIO_FORMAT_UNSPECIFIED

Anonymous Enum 10

Declared in aaudio/AAudio.h
 Anonymous Enum 10

Specifying if audio may or may not be captured by other apps or the system.

Note that these match the equivalent values in AudioAttributes in the Android Java API.

Added in API level 29.

Properties
AAUDIO_ALLOW_CAPTURE_BY_ALL

Indicates that the audio may be captured by any app.

For privacy, the following usages can not be recorded: AAUDIO_VOICE_COMMUNICATION*, AAUDIO_USAGE_NOTIFICATION*, AAUDIO_USAGE_ASSISTANCE* and AAUDIO_USAGE_ASSISTANT.

On Q, this means only AAUDIO_USAGE_MEDIA and AAUDIO_USAGE_GAME may be captured.

See ALLOW_CAPTURE_BY_ALL.

AAUDIO_ALLOW_CAPTURE_BY_NONE

Indicates that the audio may not be recorded by any app, even if it is a system app.

It is encouraged to use AAUDIO_ALLOW_CAPTURE_BY_SYSTEM instead of this value as system apps provide significant and useful features for the user (eg. accessibility). See ALLOW_CAPTURE_BY_NONE.

AAUDIO_ALLOW_CAPTURE_BY_SYSTEM

Indicates that the audio may only be captured by system apps.

System apps can capture for many purposes like accessibility, user guidance... but have strong restriction. See ALLOW_CAPTURE_BY_SYSTEM for what the system apps can do with the capture audio.

Anonymous Enum 11

Declared in aaudio/AAudio.h
 Anonymous Enum 11

These may be used with AAudioStreamBuilder_setSessionId().

Added in API level 28.

Properties
AAUDIO_SESSION_ID_ALLOCATE

Allocate a session ID that can be used to attach and control effects using the Java AudioEffects API.

Note that using this may result in higher latency.

Note that this matches the value of AudioManager.AUDIO_SESSION_ID_GENERATE.

Added in API level 28.

AAUDIO_SESSION_ID_NONE

Do not allocate a session ID.

Effects cannot be used with this stream. Default.

Added in API level 28.

Anonymous Enum 12

Declared in aaudio/AAudio.h
 Anonymous Enum 12

Defines the audio channel mask.

Channel masks are used to describe the samples and their arrangement in the audio frame. They are also used in the endpoint (e.g. a USB audio interface, a DAC connected to headphones) to specify allowable configurations of a particular device.

Channel masks are for input only, output only, or both input and output. These channel masks are different than those defined in AudioFormat.java. If an app gets a channel mask from Java API and wants to use it in AAudio, conversion should be done by the app.

Added in API level 32.

Properties
AAUDIO_CHANNEL_13POINT0

Supported for only Output Available since API level 37.

AAUDIO_CHANNEL_2POINT0POINT2

Supported for Input and Output.

AAUDIO_CHANNEL_2POINT1

Supported for only Output.

AAUDIO_CHANNEL_2POINT1POINT2

Supported for Input and Output.

AAUDIO_CHANNEL_3POINT0POINT2

Supported for Input and Output.

AAUDIO_CHANNEL_3POINT1

Supported for only Output.

AAUDIO_CHANNEL_3POINT1POINT2

Supported for Input and Output.

AAUDIO_CHANNEL_5POINT1

Supported for Input and Output.

aka 5POINT1_BACK

AAUDIO_CHANNEL_5POINT1POINT2

Supported for only Output.

AAUDIO_CHANNEL_5POINT1POINT4

Supported for only Output.

AAUDIO_CHANNEL_5POINT1_SIDE

Supported for only Output.

AAUDIO_CHANNEL_6POINT1

Supported for only Output.

AAUDIO_CHANNEL_7POINT1

Supported for only Output.

AAUDIO_CHANNEL_7POINT1POINT2

Supported for only Output.

AAUDIO_CHANNEL_7POINT1POINT4

Supported for only Output.

AAUDIO_CHANNEL_9POINT1POINT4

Supported for only Output.

AAUDIO_CHANNEL_9POINT1POINT6

Supported for only Output.

AAUDIO_CHANNEL_BACK_CENTER
AAUDIO_CHANNEL_BACK_LEFT
AAUDIO_CHANNEL_BACK_RIGHT
AAUDIO_CHANNEL_BOTTOM_FRONT_CENTER
AAUDIO_CHANNEL_BOTTOM_FRONT_LEFT
AAUDIO_CHANNEL_BOTTOM_FRONT_RIGHT
AAUDIO_CHANNEL_FRONT_BACK

Supported for only Input.

AAUDIO_CHANNEL_FRONT_CENTER
AAUDIO_CHANNEL_FRONT_LEFT
AAUDIO_CHANNEL_FRONT_LEFT_OF_CENTER
AAUDIO_CHANNEL_FRONT_RIGHT
AAUDIO_CHANNEL_FRONT_RIGHT_OF_CENTER
AAUDIO_CHANNEL_FRONT_WIDE_LEFT
AAUDIO_CHANNEL_FRONT_WIDE_RIGHT
AAUDIO_CHANNEL_INVALID

Invalid channel mask.

AAUDIO_CHANNEL_LOW_FREQUENCY
AAUDIO_CHANNEL_LOW_FREQUENCY_2
AAUDIO_CHANNEL_MONO

Supported for Input and Output.

AAUDIO_CHANNEL_PENTA

Supported for only Output.

AAUDIO_CHANNEL_QUAD

Supported for only Output.

AAUDIO_CHANNEL_QUAD_SIDE

Supported for only Output.

AAUDIO_CHANNEL_SIDE_LEFT
AAUDIO_CHANNEL_SIDE_RIGHT
AAUDIO_CHANNEL_STEREO

Supported for Input and Output.

AAUDIO_CHANNEL_SURROUND

Supported for only Output.

AAUDIO_CHANNEL_TOP_BACK_CENTER
AAUDIO_CHANNEL_TOP_BACK_LEFT
AAUDIO_CHANNEL_TOP_BACK_RIGHT
AAUDIO_CHANNEL_TOP_CENTER
AAUDIO_CHANNEL_TOP_FRONT_CENTER
AAUDIO_CHANNEL_TOP_FRONT_LEFT
AAUDIO_CHANNEL_TOP_FRONT_RIGHT
AAUDIO_CHANNEL_TOP_SIDE_LEFT
AAUDIO_CHANNEL_TOP_SIDE_RIGHT
AAUDIO_CHANNEL_TRI

Supported for only Output.

AAUDIO_CHANNEL_TRI_BACK

Supported for only Output.

Anonymous Enum 13

Declared in aaudio/AAudio.h
 Anonymous Enum 13

Return one of these values from the data callback function.

Properties
AAUDIO_CALLBACK_RESULT_CONTINUE

Continue calling the callback.

AAUDIO_CALLBACK_RESULT_STOP

Stop calling the callback.

The application will still need to call AAudioStream_requestPause() or AAudioStream_requestStop().

Anonymous Enum 14

Declared in aaudio/AAudio.h
 Anonymous Enum 14

When the audio is played/recorded via AAudio MMAP data path, the apps can write to/read from a shared memory that will also be accessed directly by hardware.

That reduces the audio latency. The following values are used to describe how AAudio MMAP is supported.

Properties
AAUDIO_POLICY_ALWAYS

AAudio MMAP must be used or fail.

AAUDIO_POLICY_AUTO

AAudio MMAP support depends on device's availability.

It will be used when it is possible or fallback to the normal path, where the audio data will be delivered via audio framework data pipeline.

AAUDIO_POLICY_NEVER

AAudio MMAP is disabled and never used.

Anonymous Enum 2

Declared in aaudio/AAudio.h
 Anonymous Enum 2

These result codes are returned from AAudio functions to indicate success or failure.

Note that error return codes may change in the future so applications should generally not rely on specific return codes.

Properties
AAUDIO_ERROR_BASE

Reserved.

This should not be returned.

AAUDIO_ERROR_DISCONNECTED

The audio device was disconnected.

This could occur, for example, when headphones are plugged in or unplugged. The stream cannot be used after the device is disconnected. Applications should stop and close the stream. If this error is received in an error callback then another thread should be used to stop and close the stream.

AAUDIO_ERROR_ILLEGAL_ARGUMENT

An invalid parameter was passed to AAudio.

AAUDIO_ERROR_INTERNAL

An internal error occurred.

AAUDIO_ERROR_INVALID_FORMAT

The requested data format is not supported.

AAUDIO_ERROR_INVALID_HANDLE

The server rejected the handle used to identify the stream.

AAUDIO_ERROR_INVALID_RATE

The requested sample rate was not supported.

AAUDIO_ERROR_INVALID_STATE

The requested operation is not appropriate for the current state of AAudio.

AAUDIO_ERROR_NO_FREE_HANDLES

Reserved.

This should not be returned.

AAUDIO_ERROR_NO_MEMORY

Memory could not be allocated.

AAUDIO_ERROR_NO_SERVICE

The audio service was not available.

AAUDIO_ERROR_NULL

A NULL pointer was passed to AAudio.

Or a NULL pointer was detected internally.

AAUDIO_ERROR_OUT_OF_RANGE

A requested was out of range.

AAUDIO_ERROR_TIMEOUT

An operation took longer than expected.

AAUDIO_ERROR_UNAVAILABLE

A resource or information is unavailable.

This could occur when an application tries to open too many streams, or a timestamp is not available.

AAUDIO_ERROR_UNIMPLEMENTED

The function is not implemented for this stream.

AAUDIO_ERROR_WOULD_BLOCK

A queue is full.

This queue would be blocked.

AAUDIO_OK

The call was successful.

Anonymous Enum 3

Declared in aaudio/AAudio.h
 Anonymous Enum 3

AAudio Stream states, for details, refer to Using an Audio Stream

Properties
AAUDIO_STREAM_STATE_CLOSED

The stream has been closed.

AAUDIO_STREAM_STATE_CLOSING

The stream is closing.

AAUDIO_STREAM_STATE_DISCONNECTED

The stream is disconnected from audio device.

Deprecated.

AAUDIO_STREAM_STATE_FLUSHED

The stream is flushed, ready to be restarted.

AAUDIO_STREAM_STATE_FLUSHING

The stream is being flushed.

AAUDIO_STREAM_STATE_OPEN

The stream is open and ready to use.

AAUDIO_STREAM_STATE_PAUSED

The stream has paused, could be restarted or flushed.

AAUDIO_STREAM_STATE_PAUSING

The stream is pausing.

AAUDIO_STREAM_STATE_STARTED

The stream has started.

AAUDIO_STREAM_STATE_STARTING

The stream is just starting up.

AAUDIO_STREAM_STATE_STOPPED

The stream has been stopped.

AAUDIO_STREAM_STATE_STOPPING

The stream is stopping.

AAUDIO_STREAM_STATE_UNINITIALIZED

The stream is created but not initialized yet.

AAUDIO_STREAM_STATE_UNKNOWN

The stream is in an unrecognized state.

Anonymous Enum 4

Declared in aaudio/AAudio.h
 Anonymous Enum 4
Properties
AAUDIO_SHARING_MODE_EXCLUSIVE

This will be the only stream using a particular source or sink.

This mode will provide the lowest possible latency. You should close EXCLUSIVE streams immediately when you are not using them.

AAUDIO_SHARING_MODE_SHARED

Multiple applications will be mixed by the AAudio Server.

This will have higher latency than the EXCLUSIVE mode.

Anonymous Enum 5

Declared in aaudio/AAudio.h
 Anonymous Enum 5
Properties
AAUDIO_PERFORMANCE_MODE_LOW_LATENCY

Reducing latency is more important than battery life.

AAUDIO_PERFORMANCE_MODE_NONE

No particular performance needs.

Default.

AAUDIO_PERFORMANCE_MODE_POWER_SAVING

Extending battery life is more important than low latency.

This mode is not supported in input streams. For input, mode NONE will be used if this is requested.

AAUDIO_PERFORMANCE_MODE_POWER_SAVING_OFFLOADED

Extending battery life is more important than low latency.

This mode is not supported in input streams. This mode will play through the offloaded audio path to save battery life.

Comparing to mode AAUDIO_PERFORMANCE_MODE_POWER_SAVING, the stream at this mode will be able to write a large amount(several seconds) of data within a short time. The written data will be queued in a hardware buffer. After that, the app can suspend its thread/process that playing audio, the audio framework's data pipe will be suspended automatically and the CPU will be allowed to sleep for power saving. When all queued data are played, the apps will be able to get callback to feed more data.

Available since API level 36.

Anonymous Enum 6

Declared in aaudio/AAudio.h
 Anonymous Enum 6

The USAGE attribute expresses "why" you are playing a sound, what is this sound used for.

This information is used by certain platforms or routing policies to make more refined volume or routing decisions.

Note that these match the equivalent values in AudioAttributes in the Android Java API.

Added in API level 28.

Properties
AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT

Use this for traffic announcements, etc.

Privileged MODIFY_AUDIO_ROUTING permission required.

AAUDIO_SYSTEM_USAGE_EMERGENCY

Use this in case of playing sounds in an emergency.

Privileged MODIFY_AUDIO_ROUTING permission required.

AAUDIO_SYSTEM_USAGE_SAFETY

Use this for safety sounds and alerts, for example backup camera obstacle detection.

Privileged MODIFY_AUDIO_ROUTING permission required.

AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS

Use this for vehicle status alerts and information, for example the check engine light.

Privileged MODIFY_AUDIO_ROUTING permission required.

AAUDIO_USAGE_ALARM

Use this to demand the users attention.

AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY

Use this for screen readers, etcetera.

AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE

Use this for driving or navigation directions.

AAUDIO_USAGE_ASSISTANCE_SONIFICATION

Use this for user interface sounds, beeps, etcetera.

AAUDIO_USAGE_ASSISTANT

Use this for audio responses to user queries, audio instructions or help utterances.

AAUDIO_USAGE_GAME

Use this for game audio and sound effects.

AAUDIO_USAGE_MEDIA

Use this for streaming media, music performance, video, podcasts, etcetera.

AAUDIO_USAGE_NOTIFICATION

Use this for notifying the user when a message has arrived or some other background event has occured.

AAUDIO_USAGE_NOTIFICATION_EVENT

Use this to attract the users attention when, for example, the battery is low.

AAUDIO_USAGE_NOTIFICATION_RINGTONE

Use this when the phone rings.

AAUDIO_USAGE_VOICE_COMMUNICATION

Use this for voice over IP, telephony, etcetera.

AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING

Use this for sounds associated with telephony such as busy tones, DTMF, etcetera.

Anonymous Enum 7

Declared in aaudio/AAudio.h
 Anonymous Enum 7

The CONTENT_TYPE attribute describes "what" you are playing.

It expresses the general category of the content. This information is optional. But in case it is known (for instance AAUDIO_CONTENT_TYPE_MOVIE for a movie streaming service or AAUDIO_CONTENT_TYPE_SPEECH for an audio book application) this information might be used by the audio framework to enforce audio focus.

Note that these match the equivalent values in AudioAttributes in the Android Java API.

Added in API level 28.

Properties
AAUDIO_CONTENT_TYPE_MOVIE

Use this for a movie or video soundtrack.

AAUDIO_CONTENT_TYPE_MUSIC

Use this for pre-recorded or live music.

AAUDIO_CONTENT_TYPE_SONIFICATION

Use this for sound is designed to accompany a user action, such as a click or beep sound made when the user presses a button.

AAUDIO_CONTENT_TYPE_SPEECH

Use this for spoken voice, audio books, etcetera.

Anonymous Enum 8

Declared in aaudio/AAudio.h
 Anonymous Enum 8
Properties
AAUDIO_SPATIALIZATION_BEHAVIOR_AUTO

Constant indicating the audio content associated with these attributes will follow the default platform behavior with regards to which content will be spatialized or not.

AAUDIO_SPATIALIZATION_BEHAVIOR_NEVER

Constant indicating the audio content associated with these attributes should never be spatialized.

Anonymous Enum 9

Declared in aaudio/AAudio.h
 Anonymous Enum 9

Defines the audio source.

An audio source defines both a default physical source of audio signal, and a recording configuration.

Note that these match the equivalent values in MediaRecorder.AudioSource in the Android Java API.

Added in API level 28.

Properties
AAUDIO_INPUT_PRESET_CAMCORDER

Use this preset when recording video.

AAUDIO_INPUT_PRESET_GENERIC

Use this preset when other presets do not apply.

AAUDIO_INPUT_PRESET_SYSTEM_ECHO_REFERENCE

Use this preset for an echo canceller to capture the reference signal.

Reserved for system components. Requires CAPTURE_AUDIO_OUTPUT permission Available since API level 35.

AAUDIO_INPUT_PRESET_SYSTEM_HOTWORD

Use this preset for preemptible, low-priority software hotword detection.

Reserved for system components. Requires CAPTURE_AUDIO_HOTWORD permission. Available since API level 35.

AAUDIO_INPUT_PRESET_UNPROCESSED

Use this preset to obtain an input with no effects.

Note that this input will not have automatic gain control so the recorded volume may be very low.

AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION

Use this preset when doing telephony or voice messaging.

AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE

Use this preset for capturing audio meant to be processed in real time and played back for live performance (e.g karaoke).

The capture path will minimize latency and coupling with playback path. Available since API level 29.

AAUDIO_INPUT_PRESET_VOICE_RECOGNITION

Use this preset when doing speech recognition.

AAudio_DeviceType

Declared in aaudio/AAudio.h
 AAudio_DeviceType
Properties
AAUDIO_DEVICE_AUX_LINE

A device type describing the auxiliary line-level connectors.

AAUDIO_DEVICE_BLE_BROADCAST

A device type describing a Bluetooth Low Energy (BLE) broadcast group.

AAUDIO_DEVICE_BLE_CENTRAL

A device corresponding to the receive or transmit path in an android implementation operating in a Bluetooth LE Audio peripheral mode.

Introduced in API 37.

AAUDIO_DEVICE_BLE_CENTRAL_BROADCAST

A device corresponding to the receive path in an android implementation operating in a Bluetooth LE Audio peripheral mode part of a broadcast group.

Introduced in API 37.

AAUDIO_DEVICE_BLE_HEADSET

A device type describing a Bluetooth Low Energy (BLE) audio headset or headphones.

Headphones are grouped with headsets when the device is a sink: the features of headsets and headphones with regard to playback are the same.

AAUDIO_DEVICE_BLE_HEARING_AID

A Bluetooth LE Hearing Aid Introduced in API 37.

AAUDIO_DEVICE_BLE_SPEAKER

A device type describing a Bluetooth Low Energy (BLE) audio speaker.

AAUDIO_DEVICE_BLUETOOTH_A2DP

A device type describing a Bluetooth device supporting the A2DP profile.

AAUDIO_DEVICE_BLUETOOTH_SCO

A device type describing a Bluetooth device typically used for telephony.

AAUDIO_DEVICE_BUILTIN_EARPIECE

A device type describing the attached earphone speaker.

AAUDIO_DEVICE_BUILTIN_MIC

A device type describing the microphone(s) built in a device.

AAUDIO_DEVICE_BUILTIN_SPEAKER

A device type describing the speaker system (i.e.

a mono speaker or stereo speakers) built in a device.

AAUDIO_DEVICE_BUILTIN_SPEAKER_SAFE

A device type describing the speaker system (i.e.

a mono speaker or stereo speakers) built in a device, that is specifically tuned for outputting sounds like notifications and alarms (i.e. sounds the user couldn't necessarily anticipate).

Note that this physical audio device may be the same as TYPE_BUILTIN_SPEAKER but is driven differently to safely accommodate the different use case.

AAUDIO_DEVICE_BUS

A type-agnostic device used for communication with external audio systems.

AAUDIO_DEVICE_DOCK

A device type describing the audio device associated with a dock.

Starting at API 34, this device type only represents digital docks, while docks with an analog connection are represented with AAUDIO_DEVICE_DOCK_ANALOG.

AAUDIO_DEVICE_DOCK_ANALOG

A device type describing the audio device associated with a dock using an analog connection.

AAUDIO_DEVICE_FM

A device type associated with the transmission of audio signals over FM.

AAUDIO_DEVICE_FM_TUNER

A device type for accessing the audio content transmitted over FM.

AAUDIO_DEVICE_HDMI

A device type describing an HDMI connection .

AAUDIO_DEVICE_HDMI_ARC

A device type describing the Audio Return Channel of an HDMI connection.

AAUDIO_DEVICE_HDMI_EARC

A device type describing an Echo Canceller loopback Reference.

This device is only used when capturing with MediaRecorder.AudioSource.ECHO_REFERENCE, which requires privileged permission android.Manifest.permission#CAPTURE_AUDIO_OUTPUT.

Note that this is not exposed as it is a system API that requires privileged permission. A device type describing the Enhanced Audio Return Channel of an HDMI connection.

AAUDIO_DEVICE_HEARING_AID

A device type describing a Hearing Aid.

AAUDIO_DEVICE_IP

A device type connected over IP.

AAUDIO_DEVICE_LINE_ANALOG

A device type describing an analog line-level connection.

AAUDIO_DEVICE_LINE_DIGITAL

A device type describing a digital line connection (e.g.

SPDIF).

AAUDIO_DEVICE_REMOTE_SUBMIX

A device type for rerouting audio within the Android framework between mixes and system applications.

AAUDIO_DEVICE_TELEPHONY

A device type describing the transmission of audio signals over the telephony network.

AAUDIO_DEVICE_TV_TUNER

A device type for accessing the audio content transmitted over the TV tuner system.

AAUDIO_DEVICE_USB_ACCESSORY

A device type describing a USB audio device in accessory mode.

AAUDIO_DEVICE_USB_DEVICE

A device type describing a USB audio device.

AAUDIO_DEVICE_USB_HEADSET

A device type describing a USB audio headset.

AAUDIO_DEVICE_WIRED_HEADPHONES

A device type describing a pair of wired headphones.

AAUDIO_DEVICE_WIRED_HEADSET

A device type describing a headset, which is the combination of a headphones and microphone.

AAudio_FallbackMode

Declared in aaudio/AAudio.h
 AAudio_FallbackMode

Behavior when the values for speed and / or pitch are out of the applicable range.

Properties
AAUDIO_FALLBACK_MODE_DEFAULT

It is up to the system to choose best handling.

AAUDIO_FALLBACK_MODE_FAIL

When the requested speed and or pitch is out of range, processing will be stopped and AAUDIO_ERROR_ILLEGAL_ARGUMENT will be returned.

AAUDIO_FALLBACK_MODE_MUTE

Play silence for parameter values that are out of range.

AAudio_FlushFromAccuracy

Declared in aaudio/AAudio.h
 AAudio_FlushFromAccuracy

The values are defined to be used for the accuracy requirement when calling value to indicate #flushWrittenFramesFromPosition(long, int) is not supported.

}.

Properties
AAUDIO_FLUSH_FROM_ACCURACY_UNDEFINED

There is not requirement for frame accuracy when flushing, it is up to the framework to select a right position to flush from.

AAUDIO_FLUSH_FROM_FRAME_ACCURATE

The stream must be flushed from the requested position.

If it is not possible to flush from the requested position, the stream must not be flushed.

AAudio_FlushFromFrameSupport

Declared in aaudio/AAudio.h
 AAudio_FlushFromFrameSupport

The constants for the levels of flush from frame support.

Properties
AAUDIO_FLUSH_FROM_FRAME_SUPPORTED

Constant flag value to indicate AAudioStream_flushFromFrame is supported.

AAUDIO_FLUSH_FROM_FRAME_UNSUPPORTED

Constant value to indicate AAudioStream_flushFromFrame is not supported.

AAudio_StretchMode

Declared in aaudio/AAudio.h
 AAudio_StretchMode

Algorithms used for time-stretching (preserving pitch while playing audio content at different speed).

Properties
AAUDIO_STRETCH_MODE_DEFAULT

Time-stretching algorithm is selected by the system.

AAUDIO_STRETCH_MODE_VOICE

Selects time-stretch algorithm best suitable for voice (speech) content.

Typedefs

AAudioPlaybackParameters

Declared in aaudio/AAudio.h
struct AAudioPlaybackParameters AAudioPlaybackParameters

Structure for common playback params.

Call AAudioStream_setPlaybackParameters to control playback behavior. Call AAudioStream_getPlaybackParameters to query current playback parameters.

AAudioStream

Declared in aaudio/AAudio.h
struct AAudioStreamStruct AAudioStream

AAudioStreamBuilder

Declared in aaudio/AAudio.h
struct AAudioStreamBuilderStruct AAudioStreamBuilder

AAudioStream_dataCallback

Declared in aaudio/AAudio.h
aaudio_data_callback_result_t(* AAudioStream_dataCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, void *_Nonnull audioData, int32_t numFrames)

Prototype for the data function that is passed to AAudioStreamBuilder_setDataCallback().

For an output stream, this function should render and write numFrames of data in the streams current data format to the audioData buffer.

For an input stream, this function should read and process numFrames of data from the audioData buffer. The data in the audioData buffer must not be modified directly. Instead, it should be copied to another buffer before doing any modification. In many cases, writing to the audioData buffer of an input stream will result in a native exception.

The audio data is passed through the buffer. So do NOT call AAudioStream_read() or AAudioStream_write() on the stream that is making the callback.

Note that numFrames can vary unless AAudioStreamBuilder_setFramesPerDataCallback() is called.

Also note that this callback function should be considered a "real-time" function. It must not do anything that could cause an unbounded delay because that can cause the audio to glitch or pop.

These are things the function should NOT do:

  • allocate memory using, for example, malloc() or new
  • any file operations such as opening, closing, reading or writing
  • any network operations such as streaming
  • use any mutexes or other synchronization primitives
  • sleep
  • stop or close the stream
  • AAudioStream_read()
  • AAudioStream_write()

The following are OK to call from the data callback:

If you need to move data, eg. MIDI commands, in or out of the callback function then we recommend the use of non-blocking techniques such as an atomic FIFO.

Details
Parameters
stream
reference provided by AAudioStreamBuilder_openStream()
userData
the same address that was passed to AAudioStreamBuilder_setCallback()
audioData
a pointer to the audio data
numFrames
the number of frames to be processed, which can vary
Returns
AAUDIO_CALLBACK_RESULT_*

AAudioStream_errorCallback

Declared in aaudio/AAudio.h
void(* AAudioStream_errorCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, aaudio_result_t error)

Prototype for the callback function that is passed to AAudioStreamBuilder_setErrorCallback().

The following may NOT be called from the error callback:

The following are OK to call from the error callback:

Details
Parameters
stream
reference provided by AAudioStreamBuilder_openStream()
userData
the same address that was passed to AAudioStreamBuilder_setErrorCallback()
error
an AAUDIO_ERROR_* value.

AAudioStream_partialDataCallback

Declared in aaudio/AAudio.h
int32_t(* AAudioStream_partialDataCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, void *_Nonnull audioData, int32_t numFrames)

Prototype for the data function that is passed to AAudioStreamBuilder_setPartialDataCallback().

The main difference between this callback prototype and AAudioStream_dataCallback is the return value. In this method, it returns an integer value to indicate the actual frames of data is processed. In AAudioStream_dataCallback, it can only return AAUDIO_CALLBACK_RESULT_CONTINUE indicating all data is processed or AAUDIO_CALLBACK_RESULT_CONTINUE indicating no data is processed.

For an output stream, this function should render and write at most numFrames of data in the streams current data format to the audioData buffer.

For an input stream, this function should read and process at most numFrames of data from the audioData buffer. The data in the audioData buffer must not be modified directly. Instead, it should be copied to another buffer before doing any modification. In many cases, writing to the audioData buffer of an input stream will result in a native exception.

The audio data is passed through the buffer. So do NOT call AAudioStream_read() or AAudioStream_write() on the stream that is making the callback.

Note that numFrames can vary unless AAudioStreamBuilder_setFramesPerDataCallback() is called.

Also note that this callback function should be considered a "real-time" function. The callback should copy the data to/from the buffer and not do anything that could cause unbounded delay because that can cause the audio to glitch or pop.

These are things the function should NOT do:

  • allocate memory using, for example, malloc() or new
  • any file operations such as opening, closing, reading or writing
  • any network operations such as streaming
  • use any mutexes or other synchronization primitives
  • sleep
  • stop or close the stream
  • AAudioStream_read()
  • AAudioStream_write()

The following are OK to call from the data callback:

We recommend use of non-blocking techniques to copy data furnished by the callback method, for example the non-blocking fifo: system/media/audio_utils/include/audio_utils/fifo.h

Details
Parameters