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
impl StreamFormat
Sourcepub 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
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.
Sourcepub const fn linear_pcm(
sample: SampleFormat,
sample_rate: f64,
channels: u32,
) -> Self
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.
Sourcepub const fn float32(sample_rate: f64, channels: u32) -> Self
pub const fn float32(sample_rate: f64, channels: u32) -> Self
32-bit IEEE float interleaved linear PCM — the canonical AudioServerPlugin interchange format.
Sourcepub const fn int16(sample_rate: f64, channels: u32) -> Self
pub const fn int16(sample_rate: f64, channels: u32) -> Self
16-bit signed integer interleaved linear PCM.
Sourcepub const fn int24(sample_rate: f64, channels: u32) -> Self
pub const fn int24(sample_rate: f64, channels: u32) -> Self
24-bit signed integer interleaved linear PCM.
Sourcepub const fn int32(sample_rate: f64, channels: u32) -> Self
pub const fn int32(sample_rate: f64, channels: u32) -> Self
32-bit signed integer interleaved linear PCM.
Sourcepub const fn sample_rate(&self) -> f64
pub const fn sample_rate(&self) -> f64
mSampleRate — frames per second.
Sourcepub const fn format_id(&self) -> u32
pub const fn format_id(&self) -> u32
mFormatID — the codec / encoding identifier. Always
FORMAT_LINEAR_PCM for the typed constructors.
Sourcepub const fn format_flags(&self) -> u32
pub const fn format_flags(&self) -> u32
mFormatFlags — the kAudioFormatFlag* bit set.
Sourcepub const fn bytes_per_packet(&self) -> u32
pub const fn bytes_per_packet(&self) -> u32
mBytesPerPacket.
Sourcepub const fn frames_per_packet(&self) -> u32
pub const fn frames_per_packet(&self) -> u32
mFramesPerPacket.
Sourcepub const fn bytes_per_frame(&self) -> u32
pub const fn bytes_per_frame(&self) -> u32
mBytesPerFrame — bytes for one frame across all channels.
Sourcepub const fn bits_per_channel(&self) -> u32
pub const fn bits_per_channel(&self) -> u32
mBitsPerChannel — significant bits per sample.
Sourcepub const fn is_linear_pcm(&self) -> bool
pub const fn is_linear_pcm(&self) -> bool
true iff this is a linear-PCM stream
(FORMAT_LINEAR_PCM).
Sourcepub const fn is_non_interleaved(&self) -> bool
pub const fn is_non_interleaved(&self) -> bool
true iff each channel occupies its own buffer.
Sourcepub fn sample_format(&self) -> Option<SampleFormat>
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.
Sourcepub fn is_canonical(&self) -> bool
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
impl Clone for StreamFormat
Source§fn clone(&self) -> StreamFormat
fn clone(&self) -> StreamFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamFormat
impl Debug for StreamFormat
Source§impl PartialEq for StreamFormat
impl PartialEq for StreamFormat
Source§fn eq(&self, other: &StreamFormat) -> bool
fn eq(&self, other: &StreamFormat) -> bool
self and other values to be equal, and is used by ==.