[][src]Crate aaudio_sys

Enums

AAudioStream

Low-level wrappers for AAudio API.

AAudioStreamBuilder

Constants

ALLOW_CAPTURE_BY_ALL
ALLOW_CAPTURE_BY_NONE
ALLOW_CAPTURE_BY_SYSTEM
CALLBACK_CONTINUE
CALLBACK_STOP
CONTENT_TYPE_MOVIE
CONTENT_TYPE_MUSIC
CONTENT_TYPE_SONIFICATION
CONTENT_TYPE_SPEECH
DIRECTION_INPUT
DIRECTION_OUTPUT
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.

ERROR_ILLEGAL_ARGUMENT

An invalid parameter was passed to AAudio.

ERROR_INTERNAL
ERROR_INVALID_FORMAT

The requested data format is not supported.

ERROR_INVALID_HANDLE

The server rejected the handle used to identify the stream.

ERROR_INVALID_RATE

The requested sample rate was not supported.

ERROR_INVALID_STATE

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

ERROR_NO_FREE_HANDLES
ERROR_NO_MEMORY

Memory could not be allocated.

ERROR_NO_SERVICE

The audio service was not available.

ERROR_NULL

A NULL pointer was passed to AAudio. Or a NULL pointer was detected internally.

ERROR_OUT_OF_RANGE

A requested was out of range.

ERROR_TIMEOUT

An operation took longer than expected.

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.

ERROR_UNIMPLEMENTED

The function is not implemented for this stream.

ERROR_WOULD_BLOCK
FORMAT_INVALID
FORMAT_PCM_FLOAT
FORMAT_PCM_I16
INPUT_PRESET_CAMCORDER
INPUT_PRESET_GENERIC
INPUT_PRESET_UNPROCESSED
INPUT_PRESET_VOICE_COMMUNICATION
INPUT_PRESET_VOICE_PERFORMANCE
INPUT_PRESET_VOICE_RECOGNITION
OK
PERFORMANCE_MODE_LOW_LATENCY
PERFORMANCE_MODE_NONE
PERFORMANCE_MODE_POWER_SAVING
SESSION_ID_ALLOCATE
SESSION_ID_NONE
SHARING_EXCLUSIVE
SHARING_SHARED
STREAM_STATE_CLOSED
STREAM_STATE_CLOSING
STREAM_STATE_DISCONNECTED
STREAM_STATE_FLUSHED
STREAM_STATE_FLUSHING
STREAM_STATE_OPEN
STREAM_STATE_PAUSED
STREAM_STATE_PAUSING
STREAM_STATE_STARTED
STREAM_STATE_STARTING
STREAM_STATE_STOPPED
STREAM_STATE_STOPPING
STREAM_STATE_UNINITIALIZED
STREAM_STATE_UNKNOWN
UNSPECIFIED

This is used to represent a value that has not been specified. For example, an application could use UNSPECIFIED to indicate that is did not not care what the specific value of a parameter was and would accept whatever it was given.

USAGE_ALARM
USAGE_ANNOUNCEMENT
USAGE_ASSISTANCE_ACCESSIBILITY
USAGE_ASSISTANCE_NAVIGATION_GUIDANCE
USAGE_ASSISTANCE_SONIFICATION
USAGE_ASSISTANT
USAGE_EMERGENCY
USAGE_GAME
USAGE_MEDIA
USAGE_NOTIFICATION
USAGE_NOTIFICATION_EVENT
USAGE_NOTIFICATION_RINGTONE
USAGE_SAFETY
USAGE_VEHICLE_STATUS
USAGE_VOICE_COMMUNICATION
USAGE_VOICE_COMMUNICATION_SIGNALLING

Functions

AAudioStreamBuilder_delete

Delete the resources associated with the StreamBuilder. Returns 0 for OK or a negative error.

AAudioStreamBuilder_openStream

Open a stream based on the options in the StreamBuilder. Returns 0 for OK or a negative error.

AAudioStreamBuilder_setAllowedCapturePolicy

Specify whether this stream audio may or may not be captured by other apps or the system.

AAudioStreamBuilder_setBufferCapacityInFrames

Set the requested buffer capacity in frames. The final AAudioStream capacity may differ, but will probably be at least this big.

AAudioStreamBuilder_setChannelCount

Request a number of channels for the stream.

AAudioStreamBuilder_setContentType

Set the type of audio data that the stream will carry.

AAudioStreamBuilder_setDataCallback

Request that AAudio call this functions when the stream is running.

AAudioStreamBuilder_setDeviceId

Request an audio device identified device using an ID. On Android, for example, the ID could be obtained from the Java AudioManager.

AAudioStreamBuilder_setDirection

Request the direction for a stream.

AAudioStreamBuilder_setErrorCallback

Request that AAudio call this function if any error occurs or the stream is disconnected.

AAudioStreamBuilder_setFormat

Request a sample data format, for example FORMAT_PCM_I16.

AAudioStreamBuilder_setFramesPerDataCallback

Set the requested data callback buffer size in frames. See DataCallback.

AAudioStreamBuilder_setInputPreset

Set the input (capture) preset for the stream.

AAudioStreamBuilder_setPerformanceMode

Set the requested performance mode.

AAudioStreamBuilder_setPrivacySensitive

Indicates whether this input stream must be marked as privacy sensitive or not.

AAudioStreamBuilder_setSampleRate

Request a sample rate in Hertz.

AAudioStreamBuilder_setSessionId

The session ID can be used to associate a stream with effects processors. The effects are controlled using the Android AudioEffect Java API.

AAudioStreamBuilder_setSharingMode

Request a mode for sharing the device.

AAudioStreamBuilder_setUsage

Set the intended use case for the stream.

AAudioStream_close

Delete the internal data structures associated with the stream created by AAudioStreamBuilder_openStream().

AAudioStream_getBufferCapacityInFrames

Query maximum buffer capacity in frames.

AAudioStream_getBufferSizeInFrames

Query the maximum number of frames that can be filled without blocking.

AAudioStream_getChannelCount

A stream has one or more channels of data. A frame will contain one sample for each channel.

AAudioStream_getDeviceId

Available since API level 26. Returns the actual device ID.

AAudioStream_getDirection

Available since API level 26.

AAudioStream_getFormat

Available since API level 26. Returns the actual data format.

AAudioStream_getFramesPerBurst

Query the number of frames that the application should read or write at one time for optimal performance. It is OK if an application writes a different number of frames. But the buffer size may need to be larger in order to avoid underruns or overruns.

AAudioStream_getFramesPerDataCallback

Query the size of the buffer that will be passed to the dataProc callback in the numFrames parameter.

AAudioStream_getFramesRead

Passes back the number of frames that have been read since the stream was created. For an output stream, this will be advanced by the endpoint. For an input stream, this will be advanced by the application calling read() or by a data callback.

AAudioStream_getFramesWritten

Passes back the number of frames that have been written since the stream was created. For an output stream, this will be advanced by the application calling write() or by a data callback. For an input stream, this will be advanced by the endpoint.

AAudioStream_getPerformanceMode

Get the performance mode used by the stream.

AAudioStream_getSampleRate

Available since API level 26. Returns the actual sample rate.

AAudioStream_getSessionId

Passes back the session ID associated with this stream.

AAudioStream_getSharingMode

Provide actual sharing mode.

AAudioStream_getState

Query the current state of the client, eg. Pausing.

AAudioStream_getTimestamp

Passes back the time at which a particular frame was presented. This can be used to synchronize audio with video or MIDI. It can also be used to align a recorded stream with a playback stream. Returns 0 for OK or a negative error.

AAudioStream_getXRunCount

An XRun is an Underrun or an Overrun. During playing, an underrun will occur if the stream is not written in time and the system runs out of valid data. During recording, an overrun will occur if the stream is not read in time and there is no place to put the incoming data so it is discarded.

AAudioStream_read

Read data from the stream. Returns the number of frames actually read or a negative error.

AAudioStream_release

Free the audio resources associated with a stream created by AAudioStreamBuilder_openStream(). AAudioStream_close() should be called at some point after calling this function.

AAudioStream_requestFlush

Asynchronous request for the stream to flush. Flushing will discard any pending data. This call only works if the stream is pausing or paused. Frame counters are not reset by a flush. They may be advanced. After this call the state will be in Flushing or Flushed.

AAudioStream_requestPause

Asynchronous request for the stream to pause. Pausing a stream will freeze the data flow but not flush any buffers. Use AAudioStream_requestStart() to resume playback after a pause. After this call the state will be in Pausing or Paused.

AAudioStream_requestStart

Asynchronously request to start playing the stream. For output streams, one should write to the stream to fill the buffer before starting. Otherwise it will underflow. After this call the state will be in Starting or Started.

AAudioStream_requestStop

Asynchronous request for the stream to stop. The stream will stop after all of the data currently buffered has been played. After this call the state will be in Stopping or Stopped.

AAudioStream_setBufferSizeInFrames

This can be used to adjust the latency of the buffer by changing the threshold where blocking will occur. By combining this with AAudioStream_getXRunCount(), the latency can be tuned at run-time for each device. Returns actual buffer size in frames or a negative error.

AAudioStream_waitForStateChange

Wait until the current state no longer matches the input state.

AAudioStream_write

Write data to the stream. Returns the number of frames actually written or a negative error.

AAudio_createStreamBuilder

Create a StreamBuilder that can be used to open a Stream.

Type Definitions

DataCallback

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

ErrorCallback

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