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: u32Points per second output rate.
target_buffer: DurationTarget 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: DurationMinimum buffer before requesting urgent fill (default: 8ms).
When buffer drops below this, min_points in ChunkRequest will be non-zero.
underrun: UnderrunPolicyWhat to do when the producer can’t keep up.
drain_timeout: DurationMaximum 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: DurationInitial 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: DurationDuration 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
impl StreamConfig
Sourcepub fn with_target_buffer(self, duration: Duration) -> Self
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.
Sourcepub fn with_min_buffer(self, duration: Duration) -> Self
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.
Sourcepub fn with_underrun(self, policy: UnderrunPolicy) -> Self
pub fn with_underrun(self, policy: UnderrunPolicy) -> Self
Set the underrun policy (builder pattern).
Sourcepub fn with_drain_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn with_color_delay(self, delay: Duration) -> Self
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.
Sourcepub fn with_startup_blank(self, duration: Duration) -> Self
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
impl Clone for StreamConfig
Source§fn clone(&self) -> StreamConfig
fn clone(&self) -> StreamConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more