Skip to main content

CaptureBackend

Trait CaptureBackend 

Source
pub trait CaptureBackend: Send {
    // Required methods
    fn native_format(&self) -> (u32, u16);
    fn start(&mut self, sink: RawSink) -> Result<()>;
    fn stop(&mut self);
}
Expand description

Trait implemented by OS-specific capture backends.

The facade reads the native format via native_format, configures a Normalizer, then passes a RawSink to start to begin capture. The backend calls sink.push(...) from its RT callback.

Pass a custom backend as Box<dyn CaptureBackend> to Stream::open.

Requirements for custom backends:

  • Never panic on the capture thread / RT callback (a panic can silently stop capture).

  • Call RawSink::push from RT callbacks in an RT-safe way (no allocation, locks, blocking, or system calls; see RawSink::push for details).

  • Make start / stop idempotent: calling start while running returns Ok(()) without doing anything; calling stop before startup does nothing.

Required Methods§

Source

fn native_format(&self) -> (u32, u16)

Backend native format (sample_rate, channels).

Source

fn start(&mut self, sink: RawSink) -> Result<()>

Start sending raw frames to the given sink.

Source

fn stop(&mut self)

Stop capture.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§