use crate::*; /// Wraps [JackState], and through it [jack::Client] when connected. /// /// ``` /// let jack: tek_engine::Jack = Default::default(); /// ``` #[derive(Clone, Debug, Default)] pub struct Jack<'j> (pub(crate) Arc>>); /// This is a connection which may be [Inactive], [Activating], or [Active]. /// In the [Active] and [Inactive] states, [JackState::client] returns a /// [jack::Client], which you can use to talk to the JACK API. /// /// ``` /// let state: tek_engine::JackState = Default::default(); /// ``` #[derive(Debug, Default)] pub enum JackState<'j> { /// Unused #[default] Inert, /// Before activation. Inactive(Client), /// During activation. Activating, /// After activation. Must not be dropped for JACK thread to persist. Active(DynamicAsyncClient<'j>), } /// Event enum for JACK events. /// /// ``` /// let event: tek_engine::JackState = JackEvent::XRun; /// ``` #[derive(Debug, Clone, PartialEq)] pub enum JackEvent { ThreadInit, Shutdown(ClientStatus, Arc), Freewheel(bool), SampleRate(Frames), ClientRegistration(Arc, bool), PortRegistration(PortId, bool), PortRename(PortId, Arc, Arc), PortsConnected(PortId, PortId, bool), GraphReorder, XRun, } /// Generic notification handler that emits [JackEvent] /// /// ``` /// let notify = tek_engine::JackNotify(|_: JackEvent|{}); /// ``` pub struct JackNotify(pub T);