pub trait JackHandler: Send {
    fn process(&mut self, _ctx: &JackCallbackContext) -> JackControl { ... }
    fn buffer_size(&mut self, _new_size: JackNFrames) -> JackControl { ... }
    fn sample_rate(&mut self, _new_rate: JackNFrames) -> JackControl { ... }
    fn thread_init(&mut self) { ... }
    fn shutdown(&mut self, _status: JackStatus, _reason: &str) { ... }
    fn client_registered(&mut self, _name: &str, _registered: bool) { ... }
    fn xrun(&mut self) -> JackControl { ... }
}
Expand description

Trait for an object that implements JACK callbacks.

Most of the default implementations return JackControl::Continue - however, process() does not - you must explicitly override this behaviour if you want to specify nothing for process().

Provided Methods

This function is called by the engine any time there is work to be done. Return JackControl::Stop to stop processing, otherwise return JackControl::Continue to continue.

Realtime safety

The code in the supplied function MUST be suitable for real-time execution. That means that it cannot call functions that might block for a long time. This includes all I/O functions (disk, TTY, network), malloc, free, printf, pthread_mutex_lock, sleep, wait, poll, select, pthread_join, pthread_cond_wait, etc.

Rust-specific things to avoid using: std MPSC channels (use bounded_spsc_queue instead, or similar ringbuffer solution), mutexes, RWLocks, Barriers, Strings, Vecs (use a pre-allocated ArrayVec instead), and anything under std::collections.

This is called whenever the size of the the buffer that will be passed to the process() function is about to change. Clients that depend on knowing the buffer size must implement this callback.

Called whenever the system sample rate changes.

Given that the JACK API exposes no way to change the sample rate, the library author would like you to know that this is a decidedly rare occurence. Still, it’s worth being prepared ;)

Called just once after the creation of the thread in which all other callbacks are handled.

To be called if and when the JACK server shuts down the client thread.

Called whenever a client is registered or unregistered.

Use the registered argument to determine which it is.

Called when an XRUN (over- or under- run) occurs.

Implementors