pub struct BufferedRenderer { /* private fields */ }
Expand description
The helper struct for deferred sample rendering. Helps avoid stutter when the render time is exceding the max time allowed by the audio driver.
Instead, it renders in a separate thread with much smaller sample sizes, causing a minimal impact on latency while allowing more time to render per sample.
Designed to be used in realtime playback only.
Implementations§
Source§impl BufferedRenderer
impl BufferedRenderer
Sourcepub fn new<F: 'static + AudioPipe + Send>(
render: F,
stream_params: AudioStreamParams,
render_size: usize,
) -> Self
pub fn new<F: 'static + AudioPipe + Send>( render: F, stream_params: AudioStreamParams, render_size: usize, ) -> Self
Creates a new instance of BufferedRenderer.
render
: An object implementing the AudioPipe struct for BufferedRenderer to read samples fromstream_params
: Parameters of the output audiorender_size
: The number of samples to render each iteration
Sourcepub fn read(&mut self, dest: &mut [f32])
pub fn read(&mut self, dest: &mut [f32])
Reads samples from the remainder and the output queue into the destination array.
Sourcepub fn set_render_size(&self, size: usize)
pub fn set_render_size(&self, size: usize)
Sets the number of samples that should be rendered each iteration.
Sourcepub fn get_buffer_stats(&self) -> BufferedRendererStatsReader
pub fn get_buffer_stats(&self) -> BufferedRendererStatsReader
Returns a statistics reader.
See the BufferedRendererStatsReader
documentation for more information.
Trait Implementations§
Source§impl AudioPipe for BufferedRenderer
impl AudioPipe for BufferedRenderer
Source§fn stream_params(&self) -> &AudioStreamParams
fn stream_params(&self) -> &AudioStreamParams
The audio stream parameters of the audio pipe.
Source§fn read_samples_unchecked(&mut self, to: &mut [f32])
fn read_samples_unchecked(&mut self, to: &mut [f32])
Reads samples from the pipe without checking the channel count of the output.
Source§fn read_samples(&mut self, to: &mut [f32])
fn read_samples(&mut self, to: &mut [f32])
Reads samples from the pipe. Read more
Auto Trait Implementations§
impl Freeze for BufferedRenderer
impl !RefUnwindSafe for BufferedRenderer
impl Send for BufferedRenderer
impl Sync for BufferedRenderer
impl Unpin for BufferedRenderer
impl !UnwindSafe for BufferedRenderer
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more