Struct sqa_jack::JackConnection
source · pub struct JackConnection<T> { /* private fields */ }
Expand description
A connection to a JACK server (known as a “client” in the JACK docs).
Exists in two types: JackConnection<Activated>
when activate()
has been called
(i.e. audio is being processed), and <Deactivated>
when this has not happened,
or deactivate()
has been called.
Implementations
sourceimpl<T> JackConnection<T>
impl<T> JackConnection<T>
pub fn as_ptr(&self) -> *const jack_client_t
sourcepub fn sample_rate(&self) -> jack_nframes_t
pub fn sample_rate(&self) -> jack_nframes_t
Get the sample rate of the JACK server.
sourcepub fn buffer_size(&self) -> jack_nframes_t
pub fn buffer_size(&self) -> jack_nframes_t
Get the buffer size passed to the process()
callback.
sourcepub fn set_buffer_size(&mut self, bufsize: jack_nframes_t) -> JackResult<()>
pub fn set_buffer_size(&mut self, bufsize: jack_nframes_t) -> JackResult<()>
Change the buffer size passed to the process()
callback.
This operation stops the JACK engine process cycle, then calls all registered bufsize_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.
Parameters
- bufsize: new buffer size. Must be a power of two.
Errors
NotPowerOfTwo
: if the new buffer size isn’t a power of twoUnknownErrorCode
sourcepub fn connect_ports(&mut self, from: &JackPort, to: &JackPort) -> JackResult<()>
pub fn connect_ports(&mut self, from: &JackPort, to: &JackPort) -> JackResult<()>
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.
Preconditions
- The port types must be identical.
- The JackPortFlags of the source_port must include
PORT_IS_OUTPUT
. - The JackPortFlags of the destination_port must include
PORT_IS_INPUT
.
Errors
InvalidPortType
: when the types are not identicalInvalidPortFlags
: when the flags do not satisfy the preconditions aboveUnknownErrorCode
sourcepub fn disconnect_ports(
&mut self,
from: &JackPort,
to: &JackPort
) -> JackResult<()>
pub fn disconnect_ports(
&mut self,
from: &JackPort,
to: &JackPort
) -> JackResult<()>
Remove 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.
Preconditions
- The port types must be identical.
- The JackPortFlags of the source_port must include
PORT_IS_OUTPUT
. - The JackPortFlags of the destination_port must include
PORT_IS_INPUT
.
Errors
InvalidPortType
: when the types are not identicalInvalidPortFlags
: when the flags do not satisfy the preconditions aboveUnknownErrorCode
sourcepub fn get_port_by_name(&self, name: &str) -> JackResult<JackPort>
pub fn get_port_by_name(&self, name: &str) -> JackResult<JackPort>
Get a port from the JACK server by its name.
Errors
PortNotFound
: if no port with that name was foundNulError
: if any&str
argument contains a NUL byte (\0
).
sourcepub fn get_ports(
&self,
port_filter: Option<&str>,
type_filter: Option<&str>,
flags_filter: Option<JackPortFlags>
) -> JackResult<Vec<JackPort>>
pub fn get_ports(
&self,
port_filter: Option<&str>,
type_filter: Option<&str>,
flags_filter: Option<JackPortFlags>
) -> JackResult<Vec<JackPort>>
Get all (or a selection of) ports available in the JACK server.
Parameters
- port_filter: A regular expression used to select ports by name. If
None
, no selection based on name will be carried out. - type_filter: A regular expression used to select ports by type. If
None
, no selection based on type will be carried out. - flags_filter: A value used to select ports by their flags. If
None
, no selection based on flags will be carried out.
Errors
NulError
: if any&str
argument contains a NUL byte (\0
).ProgrammerError
: if I’ve made a mistake, or your program is utterly degenerate
sourcepub fn register_port(
&mut self,
name: &str,
ty: JackPortFlags
) -> JackResult<JackPort>
pub fn register_port(
&mut self,
name: &str,
ty: JackPortFlags
) -> JackResult<JackPort>
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. The jack_port_name_size()
is the maximum length of this full name. Exceeding that will cause the port
registration to fail and return ProgrammerError
.
The port_name must be unique among all ports owned by this client. If the name is not unique, the registration will fail.
All ports have a type, which may be any non-NULL and non-zero length string, passed as an argument. Some port types are built into the JACK API, like JACK_DEFAULT_AUDIO_TYPE or JACK_DEFAULT_MIDI_TYPE. [By default, sqa-jack makes a JACK_DEFAULT_AUDIO_TYPE port - this will be changeable in later releases.]
Errors
NulError
: if any&str
argument contains a NUL byte (\0
).PortRegistrationFailed
: if port registration failed (TODO: why could this happen?)
sourcepub fn unregister_port(&mut self, port: JackPort) -> JackResult<()>
pub fn unregister_port(&mut self, port: JackPort) -> JackResult<()>
Remove the port from the client, disconnecting any existing connections.
Errors
PortNotMine
: if you deregister a port that this client doesn’t ownInvalidPort
UnknownErrorCode
sourceimpl JackConnection<Deactivated>
impl JackConnection<Deactivated>
sourcepub fn connect(
client_name: &str,
opts: Option<JackOpenOptions>
) -> JackResult<Self>
pub fn connect(
client_name: &str,
opts: Option<JackOpenOptions>
) -> JackResult<Self>
Open an external client session with a JACK server, optionally specifying
a number of JackOpenOptions
.
Errors
JackOpenFailed(status)
: if the connection could not be opened. Contains aJackStatus
detailing what went wrong.NulError
: if any&str
argument contains a NUL byte (\0
).