Struct PcmSession

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

A continuous output processor for successive naturally ending tracks.

Input PCM has already been decoded and optionally downmixed. Compatible tracks share the converter, fractional frame accounting and tone-filter state. Gain is selected separately for each track after rate conversion. Output frame boundaries are ceil(cumulative source frames × rate ratio). A discontinuity, format or tone change requires a new session.

Call end_track only after the source was completely decoded, then start the next compatible track or call finish once at the end of the group. Returned views remain valid until the next mutable session call. Incomplete frames, non-finite input and lifecycle requests leave state unchanged; after a processing, conversion or timeline failure, the driver must discard the session rather than retrying partially consumed PCM.

Implementations§

Source§

impl PcmSession

Source

pub fn new( input: PcmFormat, output_rate: u32, tone: ToneControls, ) -> Result<Self, SessionError>

Prepare a fixed PCM format, optional rate conversion and persistent tone shelves outside the output callback.

Source

pub fn input_format(&self) -> PcmFormat

Source PCM format after any downmix and before rate conversion.

Source

pub fn output_format(&self) -> PcmFormat

Guarded PCM format accepted by the output sink.

Source

pub fn compatible( &self, input: PcmFormat, output_rate: u32, tone: ToneControls, ) -> bool

Whether the next naturally advancing track can share this unfinished processing session. Channel positions are part of compatibility.

Source

pub fn begin_track( &mut self, token: usize, gain_db: f32, ) -> Result<(), SessionError>

Start a new source track using a fixed final gain in dB. The driver includes any normalization and tone headroom reserve in this gain. Pending output from earlier tracks retains their own gains.

Source

pub fn push_source( &mut self, samples: &[f32], ) -> Result<SessionBlock<'_>, SessionError>

Supply complete finite source frames. A converter may retain source frames and return no output until more PCM arrives or the group ends.

Source

pub fn end_track(&mut self) -> Result<SessionBlock<'_>, SessionError>

Seal the active track’s source boundary without flushing the converter or resetting filters. Completion is emitted only once every output frame assigned to this track has been produced.

Source

pub fn finish(&mut self) -> Result<SessionBlock<'_>, SessionError>

Flush the converter once after every source track has been sealed. Repeated calls return an empty block without duplicate completions.

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.

§

impl<S> FromSample<S> for S

§

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.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

fn to_sample_(self) -> U

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

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