pub struct Client(_, _, _);
Implementations§
source§impl Client
impl Client
sourcepub fn new(
client_name: &str,
options: ClientOptions
) -> Result<(Self, ClientStatus), Error>
pub fn new(
client_name: &str,
options: ClientOptions
) -> Result<(Self, ClientStatus), Error>
Opens a JACK client with the given name and options. If the client is successfully opened,
then Ok(client)
is returned. If the JACK server returned an error, then
Err(Error::ClientError(status))
will be returned. And if the dynamic_loading
feature is
enabled and the JACK library could not be loaded, an Err(Error::LibraryError(message))
is
returned.
Although the client may be successful in opening, there still may be some errors minor
errors when attempting to opening. To access these, check the returned ClientStatus
.
sourcepub fn activate_async<N, P>(
self,
notification_handler: N,
process_handler: P
) -> Result<AsyncClient<N, P>, Error>where
N: 'static + Send + Sync + NotificationHandler,
P: 'static + Send + ProcessHandler,
pub fn activate_async<N, P>(
self,
notification_handler: N,
process_handler: P
) -> Result<AsyncClient<N, P>, Error>where
N: 'static + Send + Sync + NotificationHandler,
P: 'static + Send + ProcessHandler,
Begin processing in real-time using the specified NotificationHandler
and
ProcessHandler
.
sourcepub fn sample_rate(&self) -> usize
pub fn sample_rate(&self) -> usize
The sample rate of the JACK system, as set by the user when jackd was started.
sourcepub fn cpu_load(&self) -> f32
pub fn cpu_load(&self) -> f32
The current CPU load estimated by JACK. It is on a scale of 0.0
to 100.0
.
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.
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Get the name of the current client. This may differ from the name requested by Client::new
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::new
if the ClientStatus
was
NAME_NOT_UNIQUE
.
sourcepub fn buffer_size(&self) -> Frames
pub fn buffer_size(&self) -> Frames
The current maximum size that will every be passed to the process callback.
sourcepub fn set_buffer_size(&self, n_frames: Frames) -> Result<(), Error>
pub fn set_buffer_size(&self, n_frames: Frames) -> Result<(), Error>
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.
sourcepub fn uuid_string(&self) -> String
pub fn uuid_string(&self) -> String
Get a String representation of the uuid
of this client.
Remarks
- Allocates & deallocates, not realtime safe.
sourcepub fn name_by_uuid_str(&self, uuid: &str) -> Option<String>
pub fn name_by_uuid_str(&self, uuid: &str) -> Option<String>
Get the name of a client by its &str
uuid.
sourcepub fn ports(
&self,
port_name_pattern: Option<&str>,
type_name_pattern: Option<&str>,
flags: PortFlags
) -> Vec<String>
pub fn ports(
&self,
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, AudioIn
and AudioOut
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.
sourcepub fn register_port<PS: PortSpec>(
&self,
port_name: &str,
port_spec: PS
) -> Result<Port<PS>, Error>
pub fn register_port<PS: PortSpec>(
&self,
port_name: &str,
port_spec: PS
) -> Result<Port<PS>, Error>
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.
The port_spec
specifies the IO direction and data type. Oftentimes, the built-in types
(AudioIn
, AudioOut
, MidiIn
, MidiOut
) can be used.
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.
sourcepub fn port_by_name(&self, port_name: &str) -> Option<Port<Unowned>>
pub fn port_by_name(&self, port_name: &str) -> Option<Port<Unowned>>
Get a Port
by its port name.
sourcepub fn load_internal_client(
&self,
client_name: &str,
client_bin_name: &str,
client_args: &str
) -> Result<InternalClientID, Error>
pub fn load_internal_client(
&self,
client_name: &str,
client_bin_name: &str,
client_args: &str
) -> Result<InternalClientID, Error>
Load a (server) internal client
This call will load a server-internal jack client. Internal clients run inside the jack server process and are provided as .so files by the jack package. Most internal clients provide low level interfaces, so as such are not expected to be needed by regular applications
client_name
is the name the new client will display as on the graph
client_bin_name
is the name of the internal client to load. This is the same as the .so file
being loaded, without its file extension or path.
client_args
is an arbitrary string of parameters passed to the client. These are client specific
This call will return the ID of the new client, needed to unload it again on success. It returns a ClientError on error.
sourcepub fn unload_internal_client(
&self,
client: InternalClientID
) -> Result<(), Error>
pub fn unload_internal_client(
&self,
client: InternalClientID
) -> Result<(), Error>
Unload a (server) internal client
This call will unload a server-internal jack client with an ID given from load_internal_client.
client
is the ID to unload
This call will return Ok(())
on success.
It returns a ClientError on error.
sourcepub fn frames_since_cycle_start(&self) -> Frames
pub fn frames_since_cycle_start(&self) -> Frames
The estimated time in frames that has passed since the JACK server began the current process cycle.
sourcepub fn frame_time(&self) -> Frames
pub fn frame_time(&self) -> Frames
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
sourcepub fn frames_to_time(&self, n_frames: Frames) -> Time
pub fn frames_to_time(&self, n_frames: Frames) -> Time
sourcepub fn time_to_frames(&self, t: Time) -> Frames
pub fn time_to_frames(&self, t: Time) -> Frames
sourcepub fn is_mine<PS: PortSpec>(&self, port: &Port<PS>) -> bool
pub fn is_mine<PS: PortSpec>(&self, port: &Port<PS>) -> bool
Returns true
if the port port
belongs to this client.
sourcepub fn request_monitor_by_name(
&self,
port_name: &str,
enable_monitor: bool
) -> Result<(), Error>
pub fn request_monitor_by_name(
&self,
port_name: &str,
enable_monitor: bool
) -> Result<(), Error>
Toggle input monitoring for the port with name port_name
.
Err(Error::PortMonitorError)
is returned on failure.
Only works if the port has the CAN_MONITOR
flag, or else nothing happens.
sourcepub fn connect_ports_by_name(
&self,
source_port: &str,
destination_port: &str
) -> Result<(), Error>
pub fn connect_ports_by_name(
&self,
source_port: &str,
destination_port: &str
) -> Result<(), Error>
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.
Panics
Panics if it is not possible to convert source_port
or
destination_port
to a CString
.
sourcepub fn connect_ports<A: PortSpec, B: PortSpec>(
&self,
source_port: &Port<A>,
destination_port: &Port<B>
) -> Result<(), Error>
pub fn connect_ports<A: PortSpec, B: PortSpec>(
&self,
source_port: &Port<A>,
destination_port: &Port<B>
) -> Result<(), Error>
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.
sourcepub fn disconnect<PS>(&self, port: &Port<PS>) -> Result<(), Error>
pub fn disconnect<PS>(&self, port: &Port<PS>) -> Result<(), Error>
Remove all connections to/from the port.
pub fn unregister_port<PS>(&self, port: Port<PS>) -> Result<(), Error>
sourcepub fn disconnect_ports<A: PortSpec, B: PortSpec>(
&self,
source: &Port<A>,
destination: &Port<B>
) -> Result<(), Error>
pub fn disconnect_ports<A: PortSpec, B: PortSpec>(
&self,
source: &Port<A>,
destination: &Port<B>
) -> Result<(), Error>
Remove a connection between two ports.
sourcepub fn disconnect_ports_by_name(
&self,
source_port: &str,
destination_port: &str
) -> Result<(), Error>
pub fn disconnect_ports_by_name(
&self,
source_port: &str,
destination_port: &str
) -> Result<(), Error>
Remove a connection between two ports.
sourcepub unsafe fn type_buffer_size(&self, port_type: &str) -> usize
pub unsafe fn type_buffer_size(&self, port_type: &str) -> usize
sourcepub fn raw(&self) -> *mut jack_client_t
pub fn raw(&self) -> *mut jack_client_t
Expose the underlying ffi pointer.
This is mostly for use within the jack crate itself.
sourcepub unsafe fn from_raw(p: *mut jack_client_t) -> Self
pub unsafe fn from_raw(p: *mut jack_client_t) -> Self
Create a Client
from an ffi pointer.
This is mostly for use within the jack crate itself.
Safety
It is unsafe to create a Client
from a raw pointer.