pub struct PingPongBuffer<T: Clone> { /* private fields */ }Expand description
A double buffer of two block_len-sample blocks.
Implementations§
Source§impl<T: Clone> PingPongBuffer<T>
impl<T: Clone> PingPongBuffer<T>
Sourcepub fn new(block_len: usize) -> Result<Self, ErrorsJSL>
pub fn new(block_len: usize) -> Result<Self, ErrorsJSL>
A buffer with blocks of block_len samples (at least 1).
pub fn block_len(&self) -> usize
Sourcepub fn push(&mut self, samples: &[T]) -> PushOutcome
pub fn push(&mut self, samples: &[T]) -> PushOutcome
Pushes samples; completed blocks swap into the ready slot. While a block is waiting, the filling buffer can complete one more block but then further samples are dropped.
Trait Implementations§
Source§impl<T: Clone> StreamOperator<T, T> for PingPongBuffer<T>
As a stream operator the buffer re-blocks a stream: it emits whole blocks as they complete (so
the output is the input delayed by up to one block) and never overruns because it drains
immediately. flush emits the final partial block as-is.
impl<T: Clone> StreamOperator<T, T> for PingPongBuffer<T>
As a stream operator the buffer re-blocks a stream: it emits whole blocks as they complete (so
the output is the input delayed by up to one block) and never overruns because it drains
immediately. flush emits the final partial block as-is.
Source§fn process(&mut self, data_in: &[T]) -> Result<Option<Vec<T>>, ErrorsJSL>
fn process(&mut self, data_in: &[T]) -> Result<Option<Vec<T>>, ErrorsJSL>
Processes a chunk of input data and produces a corresponding chunk of output data. The input and output types can be defined based on the specific requirements of the application, such as audio samples, video frames, or other types of data.
This method is called repeatedly as new data becomes available in the stream.
Source§fn flush(&mut self) -> Result<Option<Vec<T>>, ErrorsJSL>
fn flush(&mut self) -> Result<Option<Vec<T>>, ErrorsJSL>
Flushes any remaining data in the operator’s internal buffers and produces any final output data. This method is typically called at the end of a stream or when the operator needs to be shut down, allowing it to perform any necessary cleanup or final computations before the stream is terminated.
Source§impl<T: Clone> StreamOperatorManagement for PingPongBuffer<T>
impl<T: Clone> StreamOperatorManagement for PingPongBuffer<T>
Auto Trait Implementations§
impl<T> Freeze for PingPongBuffer<T>
impl<T> RefUnwindSafe for PingPongBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for PingPongBuffer<T>where
T: Send,
impl<T> Sync for PingPongBuffer<T>where
T: Sync,
impl<T> Unpin for PingPongBuffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for PingPongBuffer<T>
impl<T> UnwindSafe for PingPongBuffer<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more