pub struct ExactPcmAdapter { /* private fields */ }Expand description
A validated, stateless mapping from canonical source integers to bytes.
No source rate, precision, speaker position or normalized sample value is changed. Output integers are full-width PCM: widening shifts source values towards the most significant bit, rather than merely sign-extending them. Float scaling is exact for every source value in the 16/24-bit profile.
Implementations§
Source§impl ExactPcmAdapter
impl ExactPcmAdapter
Sourcepub fn new(
source: IntegerPcmFormat,
output: ExactOutputFormat,
) -> Result<Self, ExactOutputError>
pub fn new( source: IntegerPcmFormat, output: ExactOutputFormat, ) -> Result<Self, ExactOutputError>
Refuse rate/layout conversion and unknown or insufficient precision.
Sourcepub fn source_format(self) -> IntegerPcmFormat
pub fn source_format(self) -> IntegerPcmFormat
Original unscaled signed source format accepted by this adapter.
Sourcepub fn output_format(self) -> ExactOutputFormat
pub fn output_format(self) -> ExactOutputFormat
Software output representation accepted by this adapter.
Sourcepub fn encode_block(
self,
samples: &[i32],
encoded: &mut Vec<u8>,
) -> Result<usize, ExactOutputError>
pub fn encode_block( self, samples: &[i32], encoded: &mut Vec<u8>, ) -> Result<usize, ExactOutputError>
Replace encoded with one bounded, complete interleaved block.
Return the encoded frame count. An empty block produces no bytes. All source samples, frame alignment and capacity are validated before the existing encoded bytes are modified. Allocation is permitted here, so callers must encode outside the output callback and may reuse capacity.
Trait Implementations§
Source§impl Clone for ExactPcmAdapter
impl Clone for ExactPcmAdapter
Source§fn clone(&self) -> ExactPcmAdapter
fn clone(&self) -> ExactPcmAdapter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more