rill-core 0.6.0-M2

Core foundation for the Rill ecosystem — traits, math, buffers, queues, time, macros
Documentation
//! # BufferView — backend-specific accessor for I/O ring buffers
//!
//! A `BufferView` encapsulates per-backend rules (interleave/deinterleave,
//! stride, alignment) for reading input samples from and writing output
//! samples to cross-thread ring buffers or DMA windows.
//!
//! Used internally by `rill-io` backends (`DirectView`, `DeinterleavedView`).
//! Graph nodes access I/O through `IoCapture::read_input()` and
//! `IoPlayback::write_output()` — they do not use `BufferView` directly.

/// Backend-specific accessor for I/O ring buffers.
///
/// Encapsulates per-backend rules (interleave/deinterleave) for reading
/// input samples from and writing output samples to cross-thread ring buffers.
/// Each backend provides its own implementation.
pub trait BufferView: Send + Sync {
    /// Number of input (capture) channels.
    fn num_input_channels(&self) -> usize;

    /// Number of output (playback) channels.
    fn num_output_channels(&self) -> usize;

    /// Read available input samples for one channel into `dst`.
    ///
    /// Returns the number of samples actually read (may be less than `dst.len()`
    /// if insufficient data is available).
    fn read_input(&self, channel: usize, dst: &mut [f32]) -> usize;

    /// Write output samples for one channel from `src`.
    ///
    /// Returns the number of samples actually written (may be less than `src.len()`
    /// if insufficient space is available).
    fn write_output(&self, channel: usize, src: &[f32]) -> usize;
}