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.

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.

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.

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

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl !Send for Graph

§

impl !Sync for Graph

§

impl Unpin for Graph

§

impl UnwindSafe for Graph

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.