Audio
Summary
Typedefs |
|
|---|---|
AAudioPlaybackParameters
|
typedefstruct AAudioPlaybackParameters
Structure for common playback params. |
AAudioStream
|
typedefstruct AAudioStreamStruct
|
AAudioStreamBuilder
|
typedefstruct AAudioStreamBuilderStruct
|
AAudioStream_dataCallback)(AAudioStream *_Nonnull stream, void *_Nullable userData, void *_Nonnull audioData, int32_t numFrames)
|
typedefaaudio_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)
|
typedefvoid(*
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)
|
typedefint32_t(*
Prototype for the data function that is passed to AAudioStreamBuilder_setPartialDataCallback(). |
AAudioStream_presentationEndCallback)(AAudioStream *_Nonnull stream, void *_Null_unspecified userData)
|
typedefvoid(*
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)
|
typedefvoid(*
Prototype for the routing changed function that is passed to AAudioStreamBuilder_setRoutingChangedCallback. |
AAudio_DeviceType
|
typedefenum AAudio_DeviceType
|
AAudio_FallbackMode
|
typedefenum AAudio_FallbackMode
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
|
typedefenum AAudio_StretchMode
Algorithms used for time-stretching (preserving pitch while playing audio content at different speed). |
aaudio_allowed_capture_policy_t
|
typedefint32_t
|
aaudio_channel_mask_t
|
typedefuint32_t
|
aaudio_content_type_t
|
typedefint32_t
|
aaudio_data_callback_result_t
|
typedefint32_t
|
aaudio_direction_t
|
typedefint32_t
|
aaudio_format_t
|
typedefint32_t
|
aaudio_input_preset_t
|
typedefint32_t
|
aaudio_performance_mode_t
|
typedefint32_t
|
aaudio_policy_t
|
typedefint32_t
|
aaudio_result_t
|
typedefint32_t
|
aaudio_session_id_t
|
typedefint32_t
|
aaudio_sharing_mode_t
|
typedefint32_t
|
aaudio_spatialization_behavior_t
|
typedefint32_t
|
aaudio_stream_state_t
|
typedefint32_t
|
aaudio_usage_t
|
typedefint32_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
Identical to 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
Identical to AAudioStream_getChannelCount().
|
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)
|
AAUDIO_API AAudio_FlushFromFrameSupport
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 inaaudio/AAudio.h
Anonymous Enum 0
Anonymous Enum 1
Declared inaaudio/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 inaaudio/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 inaaudio/AAudio.h
Anonymous Enum 11
These may be used with AAudioStreamBuilder_setSessionId().
Added in API level 28.
Anonymous Enum 12
Declared inaaudio/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.
Anonymous Enum 13
Declared inaaudio/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 inaaudio/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.
Anonymous Enum 2
Declared inaaudio/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.
Anonymous Enum 3
Declared inaaudio/AAudio.h
Anonymous Enum 3
AAudio Stream states, for details, refer to Using an Audio Stream
Anonymous Enum 4
Declared inaaudio/AAudio.h
Anonymous Enum 4
Anonymous Enum 5
Declared inaaudio/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 inaaudio/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.
Anonymous Enum 7
Declared inaaudio/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.
Anonymous Enum 8
Declared inaaudio/AAudio.h
Anonymous Enum 8
Anonymous Enum 9
Declared inaaudio/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.
AAudio_DeviceType
Declared inaaudio/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 inaaudio/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 inaaudio/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.
}.
AAudio_FlushFromFrameSupport
Declared inaaudio/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 inaaudio/AAudio.h
AAudio_StretchMode
Typedefs
AAudioPlaybackParameters
Declared inaaudio/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 inaaudio/AAudio.h
struct AAudioStreamStruct AAudioStream
AAudioStreamBuilder
Declared inaaudio/AAudio.h
struct AAudioStreamBuilderStruct AAudioStreamBuilder
AAudioStream_dataCallback
Declared inaaudio/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:
- AAudioStream_get*()
- AAudio_convertResultToText()
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 |
|
||||||||
| Returns |
AAUDIO_CALLBACK_RESULT_*
|
AAudioStream_errorCallback
Declared inaaudio/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:
- AAudioStream_requestStop()
- AAudioStream_requestPause()
- AAudioStream_close()
- AAudioStream_waitForStateChange()
- AAudioStream_read()
- AAudioStream_write()
The following are OK to call from the error callback:
- AAudioStream_get*()
- AAudio_convertResultToText()
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
AAudioStream_partialDataCallback
Declared inaaudio/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:
- AAudioStream_get*()
- AAudio_convertResultToText()
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 |