Skip to main content

FrameReaderConfig

Struct FrameReaderConfig 

Source
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: Duration

Sleep duration when there is no active tap.

Default: Duration::from_millis(100).

§sleep_bias: f32

Pacing 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: Duration

Lower clamp for tiny sleeps.

Default: Duration::from_micros(150).

§max_sleep: Duration

Upper clamp for pacing sleeps.

Default: Duration::from_millis(100).

Trait Implementations§

Source§

impl Default for FrameReaderConfig

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> 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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

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>,