pub struct FrameReaderConfig {
pub time_per_batch: Option<Duration>,
pub frames_per_batch: Option<u32>,
pub no_tap_sleep: Duration,
pub sleep_bias: f32,
pub min_sleep: Duration,
pub max_sleep: Duration,
}Expand description
Configuration shared by FrameReader and [AsyncFrameReader].
FrameReader is the default synchronous reader.
AsyncFrameReader is available behind the async feature for Tokio/async runtimes.
You must specify at least one of time_per_batch or frames_per_batch
Real-time tuning (suggested starting point for very low-latency use cases):
frames_per_batch: Some(64)(equivalent to 128 sample buffer size in stereo)time_per_batch: None(use fixed frame batches)sleep_bias: 0.5(wake earlier to avoid late batch delivery)min_sleep: Duration::from_micros(5)(tiny cooperative sleep)
Fields§
§time_per_batch: Option<Duration>Target batch duration.
Default: Some(Duration::from_millis(10)).
frames_per_batch: Option<u32>Preferred fixed frame count per batch.
If set, this takes precedence over time_per_batch.
Default: None.
no_tap_sleep: DurationSleep duration when there is no active tap.
Default: Duration::from_millis(100).
sleep_bias: f32Pacing bias in the range 0.0 <= sleep_bias <= 1.0.
Used when a batch is partially filled to predict how long to sleep before polling
again: actual_sleep = sleep_bias * predicted_missing_time.
A value of 0.0 means the predicted sleep becomes zero and the reader will
always use min_sleep after clamping.
Tuning guidance:
- Lower values (for example
0.2..0.6) wake up earlier and poll more often. Prefer this for low-latency / real-time-ish processing where callback jitter matters more than CPU efficiency. - Higher values (for example
0.7..1.0) sleep closer to the full predicted time. Prefer this for latency-tolerant workloads where fewer wakeups and better CPU efficiency are more important.
The final sleep is still clamped by min_sleep and max_sleep.
Default: 0.75.
min_sleep: DurationLower clamp for tiny sleeps.
Default: Duration::from_micros(150).
max_sleep: DurationUpper clamp for pacing sleeps.
Default: Duration::from_millis(100).