AAudioStreamInfo

Struct AAudioStreamInfo 

Source
pub struct AAudioStreamInfo { /* private fields */ }
Expand description

Passed as a callback parameter, providing operations that are safe to perform from callback invocation.

Implementations§

Source§

impl AAudioStreamInfo

Source

pub fn get_sample_rate(&self) -> i32

Returns the actual sample rate.

Available since API level 26.

Source

pub fn get_channel_count(&self) -> i32

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

Available since API level 26.

Source

pub fn get_buffer_size_in_frames(&self) -> i32

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

Available since API level 26.

Source

pub fn get_frames_per_burst(&self) -> i32

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.

Note that this may or may not match the actual device burst size. For some endpoints, the burst size can vary dynamically. But these tend to be devices with high latency.

Available since API level 26.

Source

pub fn get_buffer_capacity_in_frames(&self) -> i32

Query maximum buffer capacity in frames.

Available since API level 26.

Source

pub fn get_frames_per_data_callback(&self) -> i32

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

This call can be used if the application needs to know the value of numFrames before the stream is started. This is not normally necessary.

If a specific size was requested by calling AAudioStreamBuilder::set_frames_per_data_callback() then this will be the same size.

If AAudioStreamBuilder::set_frames_per_data_callback() was not called then this will return the size chosen by AAudio, or 0.

0 indicates that the callback buffer size for this stream may vary from one dataProc callback to the next.

Available since API level 26.

Source

pub fn get_x_run_count(&self) -> i32

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.

An underrun or overrun can cause an audible “pop” or “glitch”.

Note that some INPUT devices may not support this function. In that case a 0 will always be returned.

Available since API level 26.

Source

pub fn get_device_id(&self) -> i32

Returns the actual device ID.

Available since API level 26.

Source

pub fn get_format(&self) -> Format

Returns the actual data format.

Available since API level 26.

Source

pub fn get_sharing_mode(&self) -> SharingMode

Provide actual sharing mode.

Available since API level 26.

Source

pub fn get_performance_mode(&self) -> PerformanceMode

Get the performance mode used by the stream.

Available since API level 26.

Source

pub fn get_direction(&self) -> Direction

Available since API level 26.

Source

pub fn get_frames_written(&self) -> i64

Returns 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.

The frame position is monotonically increasing.

Available since API level 26.

Source

pub fn get_frames_read(&self) -> i64

Returns 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.

The frame position is monotonically increasing.

Available since API level 26.

Source

pub fn get_session_id(&self) -> i32

Passes back the session ID associated with this stream.

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

If AAudioStreamBuilder::set_session_id() was called with 0 then a new session ID should be allocated once when the stream is opened.

If AAudioStreamBuilder::set_session_id() was called with a previously allocated session ID then that value should be returned.

If AAudioStreamBuilder::set_session_id() was not called then this function should return -1.

The sessionID for a stream should not change once the stream has been opened.

Available since API level 28.

Source

pub fn get_timestamp_monotonic(&self) -> Result<Timestamp, Error>

Returns 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.

Timestamps are only valid when the stream is in Started state. InvalidState will be returned if the stream is not started. Note that because request_start() is asynchronous, timestamps will not be valid until a short time after calling request_start(). So InvalidState should not be considered a fatal error. Just try calling again later.

If an error occurs, then the position and time will not be modified.

The position and time passed back are monotonically increasing.

Available since API level 26.

Source

pub fn get_state(&self) -> StreamState

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

This function will immediately return the state without updating the state. If you want to update the client state based on the server state then call AAudioStream::wait_for_state_change() with currentState set to Unknown and a zero timeout.

Available since API level 26.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.