pub struct Port { /* private fields */ }Expand description
An endpoint to interact with Jack data streams, for audio, midi, etc…
Implementations§
Source§impl Port
impl Port
Sourcepub fn name_size() -> usize
pub fn name_size() -> usize
The maximum length of a full Jack port name. Unlike the “C” Jack API,
this does not count the NULL character and corresponds to a string’s
.len().
The port’s full name contains the owning client name concatenated with a colon (:) followed by its short name.
This value is constant
Sourcepub fn type_size() -> usize
pub fn type_size() -> usize
The maximum length of a port type. Unlike the “C” Jack API, this does
not count the NULL character and corresponds to a string’s .len().
This value is constant.
Sourcepub fn unregister(self) -> Result<(), JackErr>
pub fn unregister(self) -> Result<(), JackErr>
Remove the port from the client, disconnecting any existing connections.
Sourcepub fn name<'a>(&'a self) -> &'a str
pub fn name<'a>(&'a self) -> &'a str
Returns the full name of the port, including the “client_name:” prefix.
Sourcepub fn short_name<'a>(&'a self) -> &'a str
pub fn short_name<'a>(&'a self) -> &'a str
Returns the short name of the port, it excludes the “client_name:” prefix.
Sourcepub fn flags(&self) -> PortFlags
pub fn flags(&self) -> PortFlags
The flags for the port. These are set when the port is registered with its client.
Sourcepub fn port_type<'a>(&self) -> &'a str
pub fn port_type<'a>(&self) -> &'a str
The port type. Jack’s built in types include “32 bit float mono audio” and “8 bit raw midi”. Custom types may also be used.
Sourcepub fn connected_count(&self) -> usize
pub fn connected_count(&self) -> usize
Number of ports connected to/from
Sourcepub fn is_connected_to(&self, port_name: &str) -> bool
pub fn is_connected_to(&self, port_name: &str) -> bool
Returns true if the port is directly connected to a port with the name
port_name.
Sourcepub unsafe fn connections(&self) -> Vec<String>
pub unsafe fn connections(&self) -> Vec<String>
Full port names to which self is connected to. This combines Jack’s
jack_port_get_all_connections() and jack_port_get_connections(). If
the client from which port was spawned from is the owner, then it
may be used in the graph reordered callback or else it should not be
used.
§Unsafe
- Can’t be used in the callback for graph reordering under certain conditions.
Sourcepub fn is_monitoring_input(&self) -> bool
pub fn is_monitoring_input(&self) -> bool
Returns true if monitoring has been requested for self.
Sourcepub fn set_name(&self, short_name: &str) -> Result<(), JackErr>
pub fn set_name(&self, short_name: &str) -> Result<(), JackErr>
Set’s the short name of the port. If the full name is longer than
Port::name_size(), then it will be truncated.
Sourcepub fn set_alias(&self, alias: &str) -> Result<(), JackErr>
pub fn set_alias(&self, alias: &str) -> Result<(), JackErr>
Sets alias as an alias for self.
May be called at any time. If the alias is longer than
Client::name_size(), it will be truncated.
After a successful call, and until Jack exists, or the alias is unset,
alias may be used as an alternate name for the port.
Ports can have up to two aliases - if both are already set, this function will return an error.
Sourcepub fn unset_alias(&self, alias: &str) -> Result<(), JackErr>
pub fn unset_alias(&self, alias: &str) -> Result<(), JackErr>
Remove alias as an alias for port. May be called at any time.
After a successful call, alias can no longer be used as an alternate
name for self.
Sourcepub fn request_monitor(&self, enable_monitor: bool) -> Result<(), JackErr>
pub fn request_monitor(&self, enable_monitor: bool) -> Result<(), JackErr>
Turn input monitoring for the port on or off.
This only works if the port has the CAN_MONITOR flag set.
Sourcepub fn ensure_monitor(&self, enable_monitor: bool) -> Result<(), JackErr>
pub fn ensure_monitor(&self, enable_monitor: bool) -> Result<(), JackErr>
If the CAN_MONITOR flag is set for the port, then input monitoring is
turned on if it was off, and turns it off if only one request has been
made to turn it on. Otherwise it does nothing.
Sourcepub fn disconnect(&self) -> Result<(), JackErr>
pub fn disconnect(&self) -> Result<(), JackErr>
Perform the same function as Client::disconnect_ports(), but with a
port handle instead.
Avoids the name lookup inherent in the name-based version.
Clients connecting their own ports are likely to use this function,
while generic connection clients (e.g. patchbays) would use
Client::disconnect_ports().
Sourcepub unsafe fn buffer(&self, n_frames: u32) -> *mut c_void
pub unsafe fn buffer(&self, n_frames: u32) -> *mut c_void
Returns a pointer to the memory area associated with the specified port. For an output port, it will be a memory area that can be written to; for an input port, it will be an area containing the data from the port’s connection(s), or zero-filled. If there are multiple inbound connections, the data will be mixed appropriately.
Do not cache the returned address across process() calls. Port buffers
have to be retrieved in each callback for proper functioning.
Sourcepub unsafe fn as_slice<T>(&self, n_frames: u32) -> &[T]
pub unsafe fn as_slice<T>(&self, n_frames: u32) -> &[T]
Interprets the buffer as a slice of type T with length n_frames.
Sourcepub unsafe fn as_slice_mut<T>(&self, n_frames: u32) -> &mut [T]
pub unsafe fn as_slice_mut<T>(&self, n_frames: u32) -> &mut [T]
Interprets the buffer as a mutable slice of type T with length
n_frames.