Trait jack::client::JackClient
[−]
[src]
pub unsafe trait JackClient: Sized { fn as_ptr(&self) -> *mut jack_client_t; fn sample_rate(&self) -> usize { ... } fn cpu_load(&self) -> c_float { ... } fn name<'a>(&'a self) -> &'a str { ... } fn buffer_size(&self) -> JackFrames { ... } fn set_buffer_size(&self, n_frames: JackFrames) -> Result<(), JackErr> { ... } fn ports(&self,
port_name_pattern: Option<&str>,
type_name_pattern: Option<&str>,
flags: PortFlags)
-> Vec<String> { ... } fn register_port<PS: PortSpec>(&self,
port_name: &str,
port_spec: PS)
-> Result<Port<PS>, JackErr> { ... } fn port_by_id(&self, port_id: JackPortId) -> Option<UnownedPort> { ... } fn port_by_name(&self, port_name: &str) -> Option<UnownedPort> { ... } fn frames_since_cycle_start(&self) -> JackFrames { ... } fn frame_time(&self) -> JackFrames { ... } fn frames_to_time(&self, n_frames: JackFrames) -> JackTime { ... } fn time_to_frames(&self, t: JackTime) -> JackFrames { ... } fn is_mine<PS: PortSpec>(&self, port: &Port<PS>) -> bool { ... } fn request_monitor_by_name(&self,
port_name: &str,
enable_monitor: bool)
-> Result<(), JackErr> { ... } fn connect_ports_by_name(&self,
source_port: &str,
destination_port: &str)
-> Result<(), JackErr> { ... } fn connect_ports<A: PortSpec, B: PortSpec>(&self,
source_port: &Port<A>,
destination_port: &Port<B>)
-> Result<(), JackErr> { ... } fn disconnect_ports<A: PortSpec, B: PortSpec>(&self,
source: &Port<A>,
destination: &Port<B>)
-> Result<(), JackErr> { ... } fn disconnect_ports_by_name(&self,
source_port: &str,
destination_port: &str)
-> Result<(), JackErr> { ... } unsafe fn type_buffer_size(&self, port_type: &str) -> usize { ... } }
Common JACK client functionality that can be accessed for both inactive and active clients.
Required Methods
fn as_ptr(&self) -> *mut jack_client_t
Expose the underlying ffi pointer.
This is mostly for use within the jack crate itself.
Provided Methods
fn sample_rate(&self) -> usize
The sample rate of the JACK system, as set by the user when jackd was started.
fn cpu_load(&self) -> c_float
The current CPU load estimated by JACK.
This is a running average of the time it takes to execute a full process cycle for all clients as a percentage of the real time available per cycle determined by the buffer size and sample rate.
fn name<'a>(&'a self) -> &'a str
Get the name of the current client. This may differ from the name requested by
Client::open
as JACK will may rename a client if necessary (ie: name collision, name too
long). The name will only the be different than the one passed to Client::open
if the
ClientStatus
was NAME_NOT_UNIQUE
.
fn buffer_size(&self) -> JackFrames
The current maximum size that will every be passed to the process callback.
fn set_buffer_size(&self, n_frames: JackFrames) -> Result<(), JackErr>
Change the buffer size passed to the process callback.
This operation stops the JACK engine process cycle, then calls all registered buffer size callback functions before restarting the process cycle. This will cause a gap in the audio flow, so it should only be done at appropriate stopping points.
fn ports(&self,
port_name_pattern: Option<&str>,
type_name_pattern: Option<&str>,
flags: PortFlags)
-> Vec<String>
port_name_pattern: Option<&str>,
type_name_pattern: Option<&str>,
flags: PortFlags)
-> Vec<String>
Returns a vector of port names that match the specified arguments
port_name_pattern
- A regular expression used to select ports by
name. If None
or zero lengthed, no selection based on name will be
carried out.
type_name_pattern
- A regular expression used to select ports by type. If None
or zero
lengthed, no selection based on type will be carried out. The port type is the same one
returned by PortSpec::jack_port_type()
. For example, AudioInSpec
and AudioOutSpec
are
both of type "32 bit float mono audio"
.
flags
- A value used to select ports by their flags. Use
PortFlags::empty()
for no flag selection.
fn register_port<PS: PortSpec>(&self,
port_name: &str,
port_spec: PS)
-> Result<Port<PS>, JackErr>
port_name: &str,
port_spec: PS)
-> Result<Port<PS>, JackErr>
Create a new port for the client. This is an object used for moving data of any type in or out of the client. Ports may be connected in various ways.
Each port has a short name. The port's full name contains the name of
the client concatenated with a colon (:) followed by its short
name. Port::name_size()
is the maximum length of the full
name. Exceeding that will cause the port registration to fail and return
Err(())
.
The port_name
must be unique among all ports owned by this client. If
the name is not unique, the registration will fail.
fn port_by_id(&self, port_id: JackPortId) -> Option<UnownedPort>
fn port_by_name(&self, port_name: &str) -> Option<UnownedPort>
Get a Port
by its port name.
fn frames_since_cycle_start(&self) -> JackFrames
The estimated time in frames that has passed since the JACK server began the current process cycle.
fn frame_time(&self) -> JackFrames
The estimated current time in frames. This function is intended for use in other threads
(not the process callback). The return value can be compared with the value of
last_frame_time
to relate time in other threads to JACK time. To obtain better time
information from within the process callback, see ProcessScope
.
TODO
- test
fn frames_to_time(&self, n_frames: JackFrames) -> JackTime
fn time_to_frames(&self, t: JackTime) -> JackFrames
fn is_mine<PS: PortSpec>(&self, port: &Port<PS>) -> bool
Returns true
if the port port
belongs to this client.
fn request_monitor_by_name(&self,
port_name: &str,
enable_monitor: bool)
-> Result<(), JackErr>
port_name: &str,
enable_monitor: bool)
-> Result<(), JackErr>
Toggle input monitoring for the port with name port_name
.
Err(JackErr::PortMonitorError)
is returned on failure.
Only works if the port has the CAN_MONITOR
flag, or else nothing
happens.
fn connect_ports_by_name(&self,
source_port: &str,
destination_port: &str)
-> Result<(), JackErr>
source_port: &str,
destination_port: &str)
-> Result<(), JackErr>
Establish a connection between two ports by their full name.
When a connection exists, data written to the source port will be available to be read at the destination port.
On failure, either a PortAlreadyConnected
or PortConnectionError
is returned.
Preconditions
- The port types must be identical
- The port flags of the
source_port
must includeIS_OUTPUT
- The port flags of the
destination_port
must includeIS_INPUT
. - Both ports must be owned by active clients.
fn connect_ports<A: PortSpec, B: PortSpec>(&self,
source_port: &Port<A>,
destination_port: &Port<B>)
-> Result<(), JackErr>
source_port: &Port<A>,
destination_port: &Port<B>)
-> Result<(), JackErr>
Establish a connection between two ports.
When a connection exists, data written to the source port will be available to be read at the destination port.
On failure, either a PortAlreadyConnected
or PortConnectionError
is returned.
Preconditions
- The port types must be identical
- The port flags of the
source_port
must includeIS_OUTPUT
- The port flags of the
destination_port
must includeIS_INPUT
. - Both ports must be owned by active clients.
fn disconnect_ports<A: PortSpec, B: PortSpec>(&self,
source: &Port<A>,
destination: &Port<B>)
-> Result<(), JackErr>
source: &Port<A>,
destination: &Port<B>)
-> Result<(), JackErr>
Remove a connection between two ports.
fn disconnect_ports_by_name(&self,
source_port: &str,
destination_port: &str)
-> Result<(), JackErr>
source_port: &str,
destination_port: &str)
-> Result<(), JackErr>
Remove a connection between two ports.
unsafe fn type_buffer_size(&self, port_type: &str) -> usize
Implementors
impl JackClient for Client
impl<JH: JackHandler> JackClient for ActiveClient<JH>
impl JackClient for WeakClient