From c51bcbfaa8a998d242193457818b4f1522bbff26 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Mon, 17 Jun 2024 19:46:18 +0300 Subject: [PATCH] add JackEvent parameters --- src/device.rs | 51 ++++++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/src/device.rs b/src/device.rs index d9bfa3eb..3d8d7139 100644 --- a/src/device.rs +++ b/src/device.rs @@ -200,13 +200,13 @@ fn panic_hook (info: &std::panic::PanicInfo) { #[derive(Debug)] pub enum JackEvent { ThreadInit, - Shutdown, - Freewheel, - SampleRate, - ClientRegistration, - PortRegistration, - PortRename, - PortsConnected, + Shutdown(ClientStatus, String), + Freewheel(bool), + SampleRate(Frames), + ClientRegistration(String, bool), + PortRegistration(PortId, bool), + PortRename(PortId, String, String), + PortsConnected(PortId, PortId, bool), GraphReorder, XRun, } @@ -215,60 +215,45 @@ pub struct Notifications(T); impl NotificationHandler for Notifications { fn thread_init (&self, _: &Client) { - //println!("JACK: thread init"); self.0(AppEvent::Jack(JackEvent::ThreadInit)); } fn shutdown (&mut self, status: ClientStatus, reason: &str) { - //println!("JACK: shutdown with status {:?} because \"{}\"", status, reason); - self.0(AppEvent::Jack(JackEvent::Shutdown)); + self.0(AppEvent::Jack(JackEvent::Shutdown(status, reason.into()))); } - fn freewheel (&mut self, _: &Client, is_enabled: bool) { - //println!("JACK: freewheel mode is {}", if is_enabled { "on" } else { "off" }); - self.0(AppEvent::Jack(JackEvent::Freewheel)); + fn freewheel (&mut self, _: &Client, enabled: bool) { + self.0(AppEvent::Jack(JackEvent::Freewheel(enabled))); } - fn sample_rate (&mut self, _: &Client, _: Frames) -> Control { - self.0(AppEvent::Jack(JackEvent::SampleRate)); + 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, is_reg: bool) { - //println!("JACK: {} client with name \"{name}\"", - //if is_reg { "registered" } else { "unregistered" }); - self.0(AppEvent::Jack(JackEvent::ClientRegistration)); + 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, port_id: PortId, is_reg: bool) { - //println!("JACK: {} port with id {port_id}", - //if is_reg { "registered" } else { "unregistered" }); - self.0(AppEvent::Jack(JackEvent::PortRegistration)); + 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 { - //println!("JACK: port with id {id} renamed from {old} to {new}",); - self.0(AppEvent::Jack(JackEvent::PortRename)); + 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) { - //println!("JACK: ports with id {a} and {b} are {}", if are { - //"connected" - //} else { - //"disconnected" - //}); - self.0(AppEvent::Jack(JackEvent::PortsConnected)); + self.0(AppEvent::Jack(JackEvent::PortsConnected(a, b, are))); } fn graph_reorder (&mut self, _: &Client) -> Control { - //println!("JACK: graph reordered"); self.0(AppEvent::Jack(JackEvent::GraphReorder)); Control::Continue } fn xrun (&mut self, _: &Client) -> Control { - //println!("JACK: xrun occurred"); self.0(AppEvent::Jack(JackEvent::XRun)); Control::Continue }