mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-01-13 11:36:40 +01:00
64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
use super::*;
|
|
|
|
#[derive(Debug)]
|
|
pub enum JackEvent {
|
|
ThreadInit,
|
|
Shutdown(ClientStatus, String),
|
|
Freewheel(bool),
|
|
SampleRate(Frames),
|
|
ClientRegistration(String, bool),
|
|
PortRegistration(PortId, bool),
|
|
PortRename(PortId, String, String),
|
|
PortsConnected(PortId, PortId, bool),
|
|
GraphReorder,
|
|
XRun,
|
|
}
|
|
|
|
pub struct Notifications<T: Fn(AppEvent) + Send>(pub T);
|
|
|
|
impl<T: Fn(AppEvent) + Send> NotificationHandler for Notifications<T> {
|
|
fn thread_init (&self, _: &Client) {
|
|
self.0(AppEvent::Jack(JackEvent::ThreadInit));
|
|
}
|
|
|
|
fn shutdown (&mut self, status: ClientStatus, reason: &str) {
|
|
self.0(AppEvent::Jack(JackEvent::Shutdown(status, reason.into())));
|
|
}
|
|
|
|
fn freewheel (&mut self, _: &Client, enabled: bool) {
|
|
self.0(AppEvent::Jack(JackEvent::Freewheel(enabled)));
|
|
}
|
|
|
|
fn sample_rate (&mut self, _: &Client, frames: Frames) -> Control {
|
|
self.0(AppEvent::Jack(JackEvent::SampleRate(frames)));
|
|
Control::Quit
|
|
}
|
|
|
|
fn client_registration (&mut self, _: &Client, name: &str, reg: bool) {
|
|
self.0(AppEvent::Jack(JackEvent::ClientRegistration(name.into(), reg)));
|
|
}
|
|
|
|
fn port_registration (&mut self, _: &Client, id: PortId, reg: bool) {
|
|
self.0(AppEvent::Jack(JackEvent::PortRegistration(id, reg)));
|
|
}
|
|
|
|
fn port_rename (&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
|
|
self.0(AppEvent::Jack(JackEvent::PortRename(id, old.into(), new.into())));
|
|
Control::Continue
|
|
}
|
|
|
|
fn ports_connected (&mut self, _: &Client, a: PortId, b: PortId, are: bool) {
|
|
self.0(AppEvent::Jack(JackEvent::PortsConnected(a, b, are)));
|
|
}
|
|
|
|
fn graph_reorder (&mut self, _: &Client) -> Control {
|
|
self.0(AppEvent::Jack(JackEvent::GraphReorder));
|
|
Control::Continue
|
|
}
|
|
|
|
fn xrun (&mut self, _: &Client) -> Control {
|
|
self.0(AppEvent::Jack(JackEvent::XRun));
|
|
Control::Continue
|
|
}
|
|
}
|
|
|