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::pushfrom RT callbacks in an RT-safe way (no allocation, locks, blocking, or system calls; seeRawSink::pushfor details). -
Make
start/stopidempotent: callingstartwhile running returnsOk(())without doing anything; callingstopbefore startup does nothing.
Required Methods§
Sourcefn native_format(&self) -> (u32, u16)
fn native_format(&self) -> (u32, u16)
Backend native format (sample_rate, channels).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".