mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
26 lines
875 B
Rust
26 lines
875 B
Rust
use crate::*;
|
|
|
|
/// Implement [Audio]: provide JACK callbacks.
|
|
#[macro_export] macro_rules! audio {
|
|
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?,$c:ident,$s:ident|$cb:expr) => {
|
|
impl $(<$($L),*$($T $(: $U)?),*>)? Audio for $Struct $(<$($L),*$($T),*>)? {
|
|
#[inline] fn process (&mut $self, $c: &Client, $s: &ProcessScope) -> Control { $cb }
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Trait for thing that has a JACK process callback.
|
|
pub trait Audio: Send + Sync {
|
|
fn process (&mut self, _: &Client, _: &ProcessScope) -> Control {
|
|
Control::Continue
|
|
}
|
|
fn callback (
|
|
state: &Arc<RwLock<Self>>, client: &Client, scope: &ProcessScope
|
|
) -> Control where Self: Sized {
|
|
if let Ok(mut state) = state.write() {
|
|
state.process(client, scope)
|
|
} else {
|
|
Control::Quit
|
|
}
|
|
}
|
|
}
|