33 lines
925 B
Rust
33 lines
925 B
Rust
use oxforge::mdk::*;
|
|
|
|
pub struct PassthroughModule {}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn create_module(
|
|
config: &GlobalConfig,
|
|
) -> *mut Box<dyn OxideModule> {
|
|
let module = PassthroughModule::new(config);
|
|
let boxed_trait: Box<dyn OxideModule> = Box::new(module);
|
|
let boxed_box = Box::new(boxed_trait);
|
|
Box::into_raw(boxed_box)
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub unsafe extern "C" fn destroy_module(module_ptr: *mut Box<dyn OxideModule>) {
|
|
if !module_ptr.is_null() {
|
|
let _ = unsafe { Box::from_raw(module_ptr) };
|
|
}
|
|
}
|
|
|
|
impl OxideModule for PassthroughModule {
|
|
fn new(_config: &GlobalConfig) -> Self {
|
|
Self {}
|
|
}
|
|
|
|
fn process(&mut self, mut ports: Ports, _context: &ProcessContext) {
|
|
if let (Some(input), Some(mut output)) = (ports.main_audio_in.take(), ports.main_audio_out.take()) {
|
|
output.buffer_mut().copy_from_slice(input.buffer());
|
|
}
|
|
}
|
|
}
|