pub struct Graph { /* private fields */ }Expand description
Owned audio graph session.
Wraps the C ove_audio_graph in a safe API. All unsafe FFI calls
are encapsulated — application code uses only safe methods.
§Example
let mut g = Graph::new(512)?;
let dev = device_cfg_i2s(16000, 1, 1);
let src = g.device_source(&dev, b"mic\0")?;
let proc = g.add_processor(PROC.get_mut(), b"dsp\0")?;
let sink = g.device_sink(&dev, b"spk\0")?;
g.connect(src, proc)?;
g.connect(proc, sink)?;
g.build()?;
g.start()?;Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new(frames_per_period: u32) -> Result<Self>
pub fn new(frames_per_period: u32) -> Result<Self>
Create and initialize a new audio graph.
Move policy: moves are safe until Graph::build is called.
After build, the C graph stores self-pointers and the wrapper
must stay at a stable address — see Graph::build for details.
Sourcepub fn new_with_storage(
frames_per_period: u32,
storage: &'static mut [u8],
) -> Result<Self>
pub fn new_with_storage( frames_per_period: u32, storage: &'static mut [u8], ) -> Result<Self>
Create and initialize a graph, attaching caller-owned buffer storage.
Required for CONFIG_OVE_ZERO_HEAP builds where build() cannot
calloc inter-node buffers. In heap-mode builds the storage is
unused but harmless. Prefer the crate::audio_graph! macro,
which emits the backing array automatically.
Same move policy as Graph::new.
Sourcepub fn device_source(
&mut self,
cfg: &ove_audio_device_cfg,
name: &[u8],
) -> Result<u32, Error>
pub fn device_source( &mut self, cfg: &ove_audio_device_cfg, name: &[u8], ) -> Result<u32, Error>
Add a hardware audio source node. Returns the node index.
Sourcepub fn device_sink(
&mut self,
cfg: &ove_audio_device_cfg,
name: &[u8],
) -> Result<u32, Error>
pub fn device_sink( &mut self, cfg: &ove_audio_device_cfg, name: &[u8], ) -> Result<u32, Error>
Add a hardware audio sink node. Returns the node index.
Sourcepub fn add_processor<T: AudioProcessor>(
&mut self,
processor: &'static mut T,
name: &[u8],
) -> Result<u32, Error>
pub fn add_processor<T: AudioProcessor>( &mut self, processor: &'static mut T, name: &[u8], ) -> Result<u32, Error>
Register a custom processor node. Returns the node index.
Thin sugar over graph_add_processor — see that function’s
rustdoc for the full lifetime / aliasing / drop-semantics
contract. The &'static mut T bound is load-bearing and must
not be satisfied by lifetime-laundering through unsafe.
Sourcepub fn connect(&mut self, from: u32, to: u32) -> Result<()>
pub fn connect(&mut self, from: u32, to: u32) -> Result<()>
Connect two nodes. from feeds into to.
Sourcepub fn build(&mut self) -> Result<()>
pub fn build(&mut self) -> Result<()>
Validate formats, resolve execution order, allocate buffers.
Pinning: this call records the wrapper’s current address in
the debug-only tracker. After build, the C side stores
self-pointers (buffers[i].fmt -> &nodes[i].out_fmt) which
reference this address. Moving the Graph after build will be
caught by Graph::start / Graph::stop / Graph::process
with a panic in debug builds; in release the move silently
dangles those pointers, so callers must keep the wrapper in a
stable location (e.g. an InitCell, Box::leak, or
&'static mut).