Skip to main content

StreamConfig

Struct StreamConfig 

Source
pub struct StreamConfig {
    pub pps: u32,
    pub target_buffer: Duration,
    pub min_buffer: Duration,
    pub underrun: UnderrunPolicy,
    pub drain_timeout: Duration,
    pub color_delay: Duration,
    pub startup_blank: Duration,
}
Expand description

Configuration for starting a stream.

§Buffer-Driven Timing

The streaming API uses pure buffer-driven timing:

  • target_buffer: Target buffer level to maintain (default: 20ms)
  • min_buffer: Minimum buffer before requesting urgent fill (default: 8ms)

The callback is invoked when buffered < target_buffer. The callback receives a ChunkRequest with min_points and target_points calculated from these durations and the current buffer state.

To reduce perceived latency, reduce target_buffer.

Fields§

§pps: u32

Points per second output rate.

§target_buffer: Duration

Target buffer level to maintain (default: 20ms).

The callback’s target_points is calculated to bring the buffer to this level. The callback is invoked when the buffer drops below this level.

§min_buffer: Duration

Minimum buffer before requesting urgent fill (default: 8ms).

When buffer drops below this, min_points in ChunkRequest will be non-zero.

§underrun: UnderrunPolicy

What to do when the producer can’t keep up.

§drain_timeout: Duration

Maximum time to wait for queued points to drain on graceful shutdown (default: 1s).

When the producer returns ChunkResult::End, the stream waits for buffered points to play out before returning. This timeout caps that wait to prevent blocking forever if the DAC stalls or queue depth is unknown.

§color_delay: Duration

Initial color delay for scanner sync compensation (default: disabled).

Delays RGB+intensity channels relative to XY coordinates by this duration, allowing galvo mirrors time to settle before the laser fires. The delay is implemented as a FIFO: output colors lag input colors by ceil(color_delay * pps) points.

Can be changed at runtime via crate::StreamControl::set_color_delay / crate::SessionControl::set_color_delay.

Typical values: 50–200µs depending on scanner speed. Duration::ZERO disables the delay (default).

§startup_blank: Duration

Duration of forced blanking after arming (default: 1ms).

After the stream is armed, the first ceil(startup_blank * pps) points will have their color channels forced to zero, regardless of what the producer writes. This prevents the “flash on start” artifact where the laser fires before mirrors reach position.

Note: when color_delay is also active, the delay line provides color_delay worth of natural startup blanking. This startup_blank setting adds blanking beyond that duration.

Set to Duration::ZERO to disable explicit startup blanking.

Implementations§

Source§

impl StreamConfig

Source

pub fn new(pps: u32) -> Self

Create a new stream configuration with the given PPS.

Source

pub fn with_target_buffer(self, duration: Duration) -> Self

Set the target buffer level to maintain (builder pattern).

Default: 20ms. Higher values provide more safety margin against underruns. Lower values reduce perceived latency.

Source

pub fn with_min_buffer(self, duration: Duration) -> Self

Set the minimum buffer level before urgent fill (builder pattern).

Default: 8ms. When buffer drops below this, min_points will be non-zero.

Source

pub fn with_underrun(self, policy: UnderrunPolicy) -> Self

Set the underrun policy (builder pattern).

Source

pub fn with_drain_timeout(self, timeout: Duration) -> Self

Set the drain timeout for graceful shutdown (builder pattern).

Default: 1 second. Set to Duration::ZERO to skip drain entirely.

Source

pub fn with_color_delay(self, delay: Duration) -> Self

Set the color delay for scanner sync compensation (builder pattern).

Default: Duration::ZERO (disabled). Typical values: 50–200µs.

Source

pub fn with_startup_blank(self, duration: Duration) -> Self

Set the startup blanking duration after arming (builder pattern).

Default: 1ms. Set to Duration::ZERO to disable.

Trait Implementations§

Source§

impl Clone for StreamConfig

Source§

fn clone(&self) -> StreamConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StreamConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,