SoundIoOutStream

Struct SoundIoOutStream 

Source
#[repr(C)]
pub struct SoundIoOutStream {
Show 15 fields pub device: *mut SoundIoDevice, pub format: SoundIoFormat, pub sample_rate: c_int, pub layout: SoundIoChannelLayout, pub software_latency: f64, pub volume: f32, pub userdata: *mut c_void, pub write_callback: Option<unsafe extern "C" fn(arg1: *mut SoundIoOutStream, frame_count_min: c_int, frame_count_max: c_int)>, pub underflow_callback: Option<unsafe extern "C" fn(arg1: *mut SoundIoOutStream)>, pub error_callback: Option<unsafe extern "C" fn(arg1: *mut SoundIoOutStream, err: c_int)>, pub name: *const c_char, pub non_terminal_hint: bool, pub bytes_per_frame: c_int, pub bytes_per_sample: c_int, pub layout_error: c_int,
}
Expand description

The size of this struct is not part of the API or ABI.

Fields§

§device: *mut SoundIoDevice

Populated automatically when you call ::soundio_outstream_create.

§format: SoundIoFormat

Defaults to #SoundIoFormatFloat32NE, followed by the first one supported.

§sample_rate: c_int

Sample rate is the number of frames per second. Defaults to 48000 (and then clamped into range).

§layout: SoundIoChannelLayout

Defaults to Stereo, if available, followed by the first layout supported.

§software_latency: f64

Ignoring hardware latency, this is the number of seconds it takes for the last sample in a full buffer to be played. After you call ::soundio_outstream_open, this value is replaced with the actual software latency, as near to this value as possible. On systems that support clearing the buffer, this defaults to a large latency, potentially upwards of 2 seconds, with the understanding that you will call ::soundio_outstream_clear_buffer when you want to reduce the latency to 0. On systems that do not support clearing the buffer, this defaults to a reasonable lower latency value.

On backends with high latencies (such as 2 seconds), frame_count_min will be 0, meaning you don’t have to fill the entire buffer. In this case, the large buffer is there if you want it; you only have to fill as much as you want. On backends like JACK, frame_count_min will be equal to frame_count_max and if you don’t fill that many frames, you will get glitches.

If the device has unknown software latency min and max values, you may still set this, but you might not get the value you requested. For PulseAudio, if you set this value to non-default, it sets PA_STREAM_ADJUST_LATENCY and is the value used for maxlength and tlength.

For JACK, this value is always equal to SoundIoDevice::software_latency_current of the device.

§volume: f32

Core Audio and WASAPI only: current output Audio Unit volume. Float, 0.0-1.0.

§userdata: *mut c_void

Defaults to NULL. Put whatever you want here.

§write_callback: Option<unsafe extern "C" fn(arg1: *mut SoundIoOutStream, frame_count_min: c_int, frame_count_max: c_int)>

In this callback, you call ::soundio_outstream_begin_write and ::soundio_outstream_end_write as many times as necessary to write at minimum frame_count_min frames and at maximum frame_count_max frames. frame_count_max will always be greater than 0. Note that you should write as many frames as you can; frame_count_min might be 0 and you can still get a buffer underflow if you always write frame_count_min frames.

For Dummy, ALSA, and PulseAudio, frame_count_min will be 0. For JACK and CoreAudio frame_count_min will be equal to frame_count_max.

The code in the supplied function must be suitable for real-time execution. That means that it cannot call functions that might block for a long time. This includes all I/O functions (disk, TTY, network), malloc, free, printf, pthread_mutex_lock, sleep, wait, poll, select, pthread_join, pthread_cond_wait, etc.

§underflow_callback: Option<unsafe extern "C" fn(arg1: *mut SoundIoOutStream)>

This optional callback happens when the sound device runs out of buffered audio data to play. After this occurs, the outstream waits until the buffer is full to resume playback. This is called from the SoundIoOutStream::write_callback thread context.

§error_callback: Option<unsafe extern "C" fn(arg1: *mut SoundIoOutStream, err: c_int)>

Optional callback. err is always SoundIoErrorStreaming. SoundIoErrorStreaming is an unrecoverable error. The stream is in an invalid state and must be destroyed. If you do not supply error_callback, the default callback will print a message to stderr and then call abort. This is called from the SoundIoOutStream::write_callback thread context.

§name: *const c_char

Optional: Name of the stream. Defaults to “SoundIoOutStream” PulseAudio uses this for the stream name. JACK uses this for the client name of the client that connects when you open the stream. WASAPI uses this for the session display name. Must not contain a colon (“:”).

§non_terminal_hint: bool

Optional: Hint that this output stream is nonterminal. This is used by JACK and it means that the output stream data originates from an input stream. Defaults to false.

§bytes_per_frame: c_int

computed automatically when you call ::soundio_outstream_open

§bytes_per_sample: c_int

computed automatically when you call ::soundio_outstream_open

§layout_error: c_int

If setting the channel layout fails for some reason, this field is set to an error code. Possible error codes are:

  • #SoundIoErrorIncompatibleDevice

Trait Implementations§

Source§

impl Clone for SoundIoOutStream

Source§

fn clone(&self) -> SoundIoOutStream

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SoundIoOutStream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for SoundIoOutStream

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.