use jack_sys as j;
use std::slice;
use crate::{Port, PortFlags, PortSpec, ProcessScope};
#[derive(Copy, Clone, Debug, Default)]
pub struct AudioIn {
_internal: (),
}
#[derive(Copy, Clone, Debug, Default)]
pub struct AudioOut {
_internal: (),
}
unsafe impl PortSpec for AudioOut {
fn jack_port_type(&self) -> &'static str {
j::FLOAT_MONO_AUDIO
}
fn jack_flags(&self) -> PortFlags {
PortFlags::IS_OUTPUT
}
fn jack_buffer_size(&self) -> libc::c_ulong {
0
}
}
unsafe impl PortSpec for AudioIn {
fn jack_port_type(&self) -> &'static str {
j::FLOAT_MONO_AUDIO
}
fn jack_flags(&self) -> PortFlags {
PortFlags::IS_INPUT
}
fn jack_buffer_size(&self) -> libc::c_ulong {
0
}
}
impl Port<AudioIn> {
pub fn as_slice<'a>(&'a self, ps: &'a ProcessScope) -> &'a [f32] {
assert_eq!(self.client_ptr(), ps.client_ptr());
unsafe {
slice::from_raw_parts(
self.buffer(ps.n_frames()) as *const f32,
ps.n_frames() as usize,
)
}
}
}
impl Port<AudioOut> {
pub fn as_mut_slice<'a>(&'a mut self, ps: &'a ProcessScope) -> &'a mut [f32] {
assert_eq!(self.client_ptr(), ps.client_ptr());
unsafe {
slice::from_raw_parts_mut(
self.buffer(ps.n_frames()) as *mut f32,
ps.n_frames() as usize,
)
}
}
}