Struct sqa_engine::jack::JackConnection
[−]
[src]
pub struct JackConnection<T> { /* fields omitted */ }
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.
Methods
impl<T> JackConnection<T>
[src]
fn as_ptr(&self) -> *const Struct__jack_client
fn sample_rate(&self) -> u32
Get the sample rate of the JACK server.
fn cpu_load(&self) -> f32
Get the CPU load of the JACK server.
fn buffer_size(&self) -> u32
Get the buffer size passed to the process()
callback.
fn set_buffer_size(&mut self, bufsize: u32) -> Result<(), Error>
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
fn connect_ports(&mut self, from: &JackPort, to: &JackPort) -> 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.
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
fn disconnect_ports(
&mut self,
from: &JackPort,
to: &JackPort
) -> Result<(), Error>
&mut self,
from: &JackPort,
to: &JackPort
) -> Result<(), Error>
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
fn get_port_by_name(&self, name: &str) -> Result<JackPort, Error>
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
).
fn get_ports(
&self,
port_filter: Option<&str>,
type_filter: Option<&str>,
flags_filter: Option<JackPortFlags>
) -> Result<Vec<JackPort>, Error>
&self,
port_filter: Option<&str>,
type_filter: Option<&str>,
flags_filter: Option<JackPortFlags>
) -> Result<Vec<JackPort>, Error>
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
fn register_port(
&mut self,
name: &str,
ty: JackPortFlags
) -> Result<JackPort, Error>
&mut self,
name: &str,
ty: JackPortFlags
) -> Result<JackPort, 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.
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?)
fn unregister_port(&mut self, port: JackPort) -> Result<(), Error>
Remove the port from the client, disconnecting any existing connections.
Errors
PortNotMine
: if you deregister a port that this client doesn't ownInvalidPort
UnknownErrorCode
impl JackConnection<Deactivated>
[src]
fn connect(
client_name: &str,
opts: Option<JackOpenOptions>
) -> Result<JackConnection<Deactivated>, Error>
client_name: &str,
opts: Option<JackOpenOptions>
) -> Result<JackConnection<Deactivated>, Error>
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
).
fn set_handler<F>(&mut self, handler: F) -> Result<(), Error> where
F: JackHandler,
F: JackHandler,
Register a handler (a struct that implements JackHandler
).
Safety
Warning: Your handler will never be deallocated / Drop
ped.
Errors
UnknownErrorCode
fn activate(
self
) -> Result<JackConnection<Activated>, (JackConnection<Deactivated>, Error)>
self
) -> Result<JackConnection<Activated>, (JackConnection<Deactivated>, Error)>
impl JackConnection<Activated>
[src]
fn deactivate(
self
) -> Result<JackConnection<Deactivated>, (JackConnection<Activated>, Error)>
self
) -> Result<JackConnection<Deactivated>, (JackConnection<Activated>, Error)>