use maudio_sys::ffi as sys;
use crate::{engine::node_graph::NodeGraph, AsRawRef, MaResult};
pub struct NodeGraphBuilder {
inner: sys::ma_node_graph_config,
}
impl AsRawRef for NodeGraphBuilder {
type Raw = sys::ma_node_graph_config;
fn as_raw(&self) -> &Self::Raw {
&self.inner
}
}
impl NodeGraphBuilder {
pub fn new(channels: u32) -> Self {
let ptr = unsafe { sys::ma_node_graph_config_init(channels) };
NodeGraphBuilder { inner: ptr }
}
pub fn build(&mut self) -> MaResult<NodeGraph> {
NodeGraph::with_alloc_callbacks(self, None)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_node_graph_builder_basic_init() {
let graph = NodeGraphBuilder::new(2).build().unwrap();
drop(graph);
}
}