mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
jack: add Port::close
This commit is contained in:
parent
57e0f64056
commit
80964d5b4a
2 changed files with 11 additions and 5 deletions
|
|
@ -55,7 +55,7 @@ impl HasJack for &Jack {
|
|||
/// Wraps [JackState] and through it [jack::Client].
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Jack {
|
||||
state: Arc<RwLock<JackState>>
|
||||
pub state: Arc<RwLock<JackState>>
|
||||
}
|
||||
|
||||
impl Jack {
|
||||
|
|
@ -99,7 +99,8 @@ impl Jack {
|
|||
/// This is a connection which may be [Inactive], [Activating], or [Active].
|
||||
/// In the [Active] and [Inactive] states, [JackState::client] returns a
|
||||
/// [jack::Client], which you can use to talk to the JACK API.
|
||||
#[derive(Debug, Default)] enum JackState {
|
||||
#[derive(Debug, Default)]
|
||||
pub enum JackState {
|
||||
/// Unused
|
||||
#[default] Inert,
|
||||
/// Before activation.
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@ macro_rules! impl_port {
|
|||
}
|
||||
impl AsRef<Port<$Spec>> for $Name { fn as_ref (&self) -> &Port<$Spec> { &self.port } }
|
||||
impl $Name {
|
||||
pub fn name (&self) -> &Arc<str> { &self.name }
|
||||
pub fn port (&self) -> &Port<$Spec> { &self.port }
|
||||
pub fn port_mut (&mut self) -> &mut Port<$Spec> { &mut self.port }
|
||||
pub fn new ($jack: &Jack, name: impl AsRef<str>, connect: &[PortConnect])
|
||||
-> Usually<Self>
|
||||
{
|
||||
|
|
@ -29,6 +26,14 @@ macro_rules! impl_port {
|
|||
port.connect_to_matching()?;
|
||||
Ok(port)
|
||||
}
|
||||
pub fn name (&self) -> &Arc<str> { &self.name }
|
||||
pub fn port (&self) -> &Port<$Spec> { &self.port }
|
||||
pub fn port_mut (&mut self) -> &mut Port<$Spec> { &mut self.port }
|
||||
pub fn into_port (self) -> Port<$Spec> { self.port }
|
||||
pub fn close (self) -> Usually<()> {
|
||||
let Self { jack, port, .. } = self;
|
||||
Ok(jack.with_client(|client|client.unregister_port(port))?)
|
||||
}
|
||||
}
|
||||
impl HasJack for $Name { fn jack (&self) -> &Jack { &self.jack } }
|
||||
impl JackPort for $Name {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue