Skip to main content

StreamFormat

Struct StreamFormat 

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

A cross-platform mirror of AudioStreamBasicDescription.

Constructed with the typed constructors (Self::float32, Self::int16, …) for the standard interleaved linear-PCM streams, or with Self::from_raw for round-tripping an ASBD the framework received over the FFI boundary. The derived per-packet / per-frame byte counts are computed at construction.

Implementations§

Source§

impl StreamFormat

Source

pub const fn from_raw( sample_rate: f64, format_id: u32, format_flags: u32, bytes_per_packet: u32, frames_per_packet: u32, bytes_per_frame: u32, channels_per_frame: u32, bits_per_channel: u32, ) -> Self

Construct a format directly from the nine ASBD fields (mReserved excluded — it is always zero).

Prefer the typed constructors for standard streams; this raw form exists for round-tripping an AudioStreamBasicDescription received from the HAL.

Source

pub const fn linear_pcm( sample: SampleFormat, sample_rate: f64, channels: u32, ) -> Self

Build a packed, interleaved, native-endian linear-PCM format from a SampleFormat.

Source

pub const fn float32(sample_rate: f64, channels: u32) -> Self

32-bit IEEE float interleaved linear PCM — the canonical AudioServerPlugin interchange format.

Source

pub const fn int16(sample_rate: f64, channels: u32) -> Self

16-bit signed integer interleaved linear PCM.

Source

pub const fn int24(sample_rate: f64, channels: u32) -> Self

24-bit signed integer interleaved linear PCM.

Source

pub const fn int32(sample_rate: f64, channels: u32) -> Self

32-bit signed integer interleaved linear PCM.

Source

pub const fn sample_rate(&self) -> f64

mSampleRate — frames per second.

Source

pub const fn format_id(&self) -> u32

mFormatID — the codec / encoding identifier. Always FORMAT_LINEAR_PCM for the typed constructors.

Source

pub const fn format_flags(&self) -> u32

mFormatFlags — the kAudioFormatFlag* bit set.

Source

pub const fn bytes_per_packet(&self) -> u32

mBytesPerPacket.

Source

pub const fn frames_per_packet(&self) -> u32

mFramesPerPacket.

Source

pub const fn bytes_per_frame(&self) -> u32

mBytesPerFrame — bytes for one frame across all channels.

Source

pub const fn channels(&self) -> u32

mChannelsPerFrame — the channel count.

Source

pub const fn bits_per_channel(&self) -> u32

mBitsPerChannel — significant bits per sample.

Source

pub const fn is_linear_pcm(&self) -> bool

true iff this is a linear-PCM stream (FORMAT_LINEAR_PCM).

Source

pub const fn is_float(&self) -> bool

true iff the samples are IEEE floating point.

Source

pub const fn is_packed(&self) -> bool

true iff every bit of the sample word is significant.

Source

pub const fn is_non_interleaved(&self) -> bool

true iff each channel occupies its own buffer.

Source

pub fn sample_format(&self) -> Option<SampleFormat>

Identify the SampleFormat of this stream, or None if it is not one of the four standard packed interleaved layouts.

Source

pub fn is_canonical(&self) -> bool

true iff this is the canonical interchange format: packed, interleaved 32-bit float linear PCM.

Trait Implementations§

Source§

impl Clone for StreamFormat

Source§

fn clone(&self) -> StreamFormat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamFormat

Source§

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

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

impl PartialEq for StreamFormat

Source§

fn eq(&self, other: &StreamFormat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for StreamFormat

Source§

impl StructuralPartialEq for StreamFormat

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.