Skip to main content

Graph

Struct Graph 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn connect(&mut self, from: u32, to: u32) -> Result<()>

Connect two nodes. from feeds into to.

Source

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).

Source

pub fn start(&mut self) -> Result<()>

Start the graph (sink-driven mode).

Source

pub fn stop(&mut self) -> Result<()>

Stop the graph.

Source

pub fn process(&mut self) -> Result<()>

Process one cycle (app-driven mode).

Trait Implementations§

Source§

impl Drop for Graph

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Graph

Source§

impl Sync for Graph

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