mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
52 lines
1.9 KiB
Rust
52 lines
1.9 KiB
Rust
use crate::*;
|
|
/// Event enum for JACK events.
|
|
#[derive(Debug, Clone, PartialEq)] pub enum JackEvent {
|
|
ThreadInit,
|
|
Shutdown(ClientStatus, Arc<str>),
|
|
Freewheel(bool),
|
|
SampleRate(Frames),
|
|
ClientRegistration(Arc<str>, bool),
|
|
PortRegistration(PortId, bool),
|
|
PortRename(PortId, Arc<str>, Arc<str>),
|
|
PortsConnected(PortId, PortId, bool),
|
|
GraphReorder,
|
|
XRun,
|
|
}
|
|
/// Generic notification handler that emits [JackEvent]
|
|
pub struct Notifications<T: Fn(JackEvent) + Send>(pub T);
|
|
impl<T: Fn(JackEvent) + Send> NotificationHandler for Notifications<T> {
|
|
fn thread_init(&self, _: &Client) {
|
|
self.0(JackEvent::ThreadInit);
|
|
}
|
|
unsafe fn shutdown(&mut self, status: ClientStatus, reason: &str) {
|
|
self.0(JackEvent::Shutdown(status, reason.into()));
|
|
}
|
|
fn freewheel(&mut self, _: &Client, enabled: bool) {
|
|
self.0(JackEvent::Freewheel(enabled));
|
|
}
|
|
fn sample_rate(&mut self, _: &Client, frames: Frames) -> Control {
|
|
self.0(JackEvent::SampleRate(frames));
|
|
Control::Quit
|
|
}
|
|
fn client_registration(&mut self, _: &Client, name: &str, reg: bool) {
|
|
self.0(JackEvent::ClientRegistration(name.into(), reg));
|
|
}
|
|
fn port_registration(&mut self, _: &Client, id: PortId, reg: bool) {
|
|
self.0(JackEvent::PortRegistration(id, reg));
|
|
}
|
|
fn port_rename(&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
|
|
self.0(JackEvent::PortRename(id, old.into(), new.into()));
|
|
Control::Continue
|
|
}
|
|
fn ports_connected(&mut self, _: &Client, a: PortId, b: PortId, are: bool) {
|
|
self.0(JackEvent::PortsConnected(a, b, are));
|
|
}
|
|
fn graph_reorder(&mut self, _: &Client) -> Control {
|
|
self.0(JackEvent::GraphReorder);
|
|
Control::Continue
|
|
}
|
|
fn xrun(&mut self, _: &Client) -> Control {
|
|
self.0(JackEvent::XRun);
|
|
Control::Continue
|
|
}
|
|
}
|