Skip to main content

StandingDepth

Struct StandingDepth 

Source
pub(crate) struct StandingDepth {
    pub(crate) window: usize,
    pub(crate) keep: usize,
    pub(crate) min_cut: usize,
    pub(crate) frame_bytes: usize,
    pub(crate) written: usize,
    pub(crate) min_left: usize,
}
Expand description

The playback queue’s standing depth, and when to cut it.

The bytes left queued after each drain are tracked at their minimum over a window of one second of written audio. What stayed queued at every drain of a whole window was never needed to ride out the uplink’s jitter, which the sink’s own buffer covers, so it is pure delay: a burst after a network stall or a stalled tab, a client clock running fast of the sink, or a sink that resumed late leaves it there, and with the drain rate equal to the arrival rate it would stay for the rest of the session. A window that closes with at least min_cut of it above keep cuts down to keep, the length of the splice’s crossfade; smaller excess waits, so drift is shed in a few cuts rather than a splice every window.

Fields§

§window: usize§keep: usize§min_cut: usize§frame_bytes: usize§written: usize§min_left: usize

Implementations§

Source§

impl StandingDepth

Source

pub(crate) fn new(bytes_per_sec: usize, frame_bytes: usize) -> Self

Size the window, the crossfade kept, and the least cut for a stream of bytes_per_sec in frames of frame_bytes: one second, 2 ms, and 10 ms.

Source

pub(crate) fn reset(&mut self)

Start a fresh window, as after the queue was cleared.

Source

pub(crate) fn after_drain( &mut self, written: usize, left: usize, ) -> Option<usize>

Record one drain that wrote written bytes and left left queued; returns the bytes to cut when this drain closes a window over a standing excess.

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.

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<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<T> Ungil for T
where T: Send,