pub struct Backpressure { /* private fields */ }Expand description
Decides when Consumer::read decodes a packet, which is how a
player splits its playout delay between decoded PCM in its playback ring and encoded
media held in the consumer.
The ring holds the floor as PCM. The rest of the delay, the hold, stays encoded, so
memory follows the bytes actually received rather than the delay. The consumer keeps
reading packets as they arrive, so its delay estimate still times each one, and
decodes a packet at timestamp:
- once the media queued behind it covers the hold, or nothing more continues it (a gap, a declared end, or the track’s end is queued after it). A backlog past the delay still reaches the ring this way, to be caught up;
- while the playhead is known, also once it is within the floor of where the packet’s output ends, keeping the ring on its floor when the network runs late.
With no hold every packet decodes at once and the ring bounds itself. The playhead is
unknown until the first observe, and again after each gap or end
the consumer hands over, until an observation lands past it.
Dropping the handle stops the gating, decoding every packet as it arrives.
Implementations§
Source§impl Backpressure
impl Backpressure
Sourcepub fn set_latency(&self, floor: Duration, hold: Duration)
pub fn set_latency(&self, floor: Duration, hold: Duration)
Split the playout delay: up to floor decoded in the ring, and hold past it encoded.