Skip to main content

AudioEncoder

Struct AudioEncoder 

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

Stateful deterministic PCM-S16 audio encoder.

Input is interleaved FP32. Complete configured packets are emitted by encode; flush emits a final partial packet. close deliberately discards an unflushed partial packet, matching the donor lifecycle contract. Dropping the encoder only releases host state and never flushes implicitly.

Implementations§

Source§

impl AudioEncoder

Source

pub fn new(profile: AudioEncodeProfile) -> Result<Self>

Create one open encoder with a checked profile.

§Errors

Returns an error unless the profile has a nonzero sample rate, one to eight channels, a nonzero packet size, and an addressable packet shape.

Source

pub fn encode(&mut self, interleaved: &[f32]) -> Result<Vec<EncodedAudioPacket>>

Append complete interleaved frames and emit every full packet now ready.

§Errors

Returns an error when the encoder is closed, the input is empty or does not contain complete frames, buffered allocation fails, or timing exceeds the signed frame domain.

Source

pub fn flush(&mut self) -> Result<Vec<EncodedAudioPacket>>

Emit the final partial packet, if any.

Calling flush on a closed encoder is idempotent and returns no packets.

§Errors

Returns an error when packet allocation fails or timing exceeds the signed frame domain.

Source

pub fn close(&mut self)

Discard any unflushed partial packet and close the encoder.

Source

pub const fn is_open(&self) -> bool

Return whether this encoder still accepts input.

Source

pub fn profile(&self) -> Option<&AudioEncodeProfile>

Return the active profile, or None after close.

Source

pub const fn codec_config(&self) -> &[u8] ⓘ

Return codec initialization bytes.

PCM-S16 has no codec configuration record.

Source

pub const fn priming_frames(&self) -> u32

Return encoder-delay frames.

PCM-S16 introduces no priming delay.

Trait Implementations§

Source§

impl Debug for AudioEncoder

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.