pub trait ProcessHandler: Send {
const SLOW_SYNC: bool = false;
// Required method
fn process(&mut self, _: &Client, _process_scope: &ProcessScope) -> Control;
// Provided methods
fn buffer_size(&mut self, _: &Client, _size: Frames) -> Control { ... }
fn sync(
&mut self,
_: &Client,
_state: TransportState,
_pos: &TransportPosition,
) -> bool { ... }
}
Expand description
Specifies real-time processing.
Provided Associated Constants§
Required Methods§
Sourcefn process(&mut self, _: &Client, _process_scope: &ProcessScope) -> Control
fn process(&mut self, _: &Client, _process_scope: &ProcessScope) -> Control
Called whenever there is work to be done.
It needs to 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, etc.
Should return Control::Continue
on success, and
Control::Quit
on error.
Provided Methods§
Sourcefn buffer_size(&mut self, _: &Client, _size: Frames) -> Control
fn buffer_size(&mut self, _: &Client, _size: Frames) -> Control
Called whenever the size of the buffer that will be passed to process
is about to change, and once before the first call to process
.
It is called on the same thread as process
, but as an exception, does
not need to be suitable for real-time execution, so it is allowed to
allocate new buffers to accomodate the buffer size for example.
Sourcefn sync(
&mut self,
_: &Client,
_state: TransportState,
_pos: &TransportPosition,
) -> bool
fn sync( &mut self, _: &Client, _state: TransportState, _pos: &TransportPosition, ) -> bool
For slow-sync clients, called periodically when the transport position is changed. The transport will not start rolling until all clients indicate they are ready, or a timeout occurs.
It should return false
until the handler is ready process audio.
Ignored unless Self::SLOW_SYNC == true.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl ProcessHandler for ()
A trivial handler that does nothing.
impl ProcessHandler for ()
A trivial handler that does nothing.