mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 07:46:57 +02:00
103 lines
2.7 KiB
Rust
103 lines
2.7 KiB
Rust
use crate::*;
|
|
|
|
def_command!(AudioInputCommand: |port: AudioInput| {
|
|
Close => todo!(),
|
|
Connect { audio_out: Arc<str> } => todo!(),
|
|
});
|
|
|
|
def_command!(AudioOutputCommand: |port: AudioOutput| {
|
|
Close => todo!(),
|
|
Connect { audio_in: Arc<str> } => todo!(),
|
|
});
|
|
|
|
impl HasJack<'static> for AudioInput { fn jack (&self) -> &Jack<'static> { &self.jack } }
|
|
impl HasJack<'static> for AudioOutput { fn jack (&self) -> &Jack<'static> { &self.jack } }
|
|
|
|
/// Audio input port.
|
|
#[derive(Debug)] pub struct AudioInput {
|
|
/// Handle to JACK client, for receiving reconnect events.
|
|
pub jack: Jack<'static>,
|
|
/// Port name
|
|
pub name: Arc<str>,
|
|
/// Port handle.
|
|
pub port: Port<AudioIn>,
|
|
/// List of ports to connect to.
|
|
pub connections: Vec<Connect>,
|
|
}
|
|
|
|
/// Audio output port.
|
|
#[derive(Debug)] pub struct AudioOutput {
|
|
/// Handle to JACK client, for receiving reconnect events.
|
|
pub jack: Jack<'static>,
|
|
/// Port name
|
|
pub name: Arc<str>,
|
|
/// Port handle.
|
|
pub port: Port<AudioOut>,
|
|
/// List of ports to connect to.
|
|
pub connections: Vec<Connect>,
|
|
}
|
|
|
|
|
|
impl JackPort for AudioInput {
|
|
type Port = AudioIn;
|
|
type Pair = AudioOut;
|
|
fn port_name (&self) -> &Arc<str> {
|
|
&self.name
|
|
}
|
|
fn port (&self) -> &Port<Self::Port> {
|
|
&self.port
|
|
}
|
|
fn port_mut (&mut self) -> &mut Port<Self::Port> {
|
|
&mut self.port
|
|
}
|
|
fn into_port (self) -> Port<Self::Port> {
|
|
self.port
|
|
}
|
|
fn connections (&self) -> &[Connect] {
|
|
self.connections.as_slice()
|
|
}
|
|
fn new (jack: &Jack<'static>, name: &impl AsRef<str>, connect: &[Connect])
|
|
-> Usually<Self> where Self: Sized
|
|
{
|
|
let port = Self {
|
|
port: Self::register(jack, name)?,
|
|
jack: jack.clone(),
|
|
name: name.as_ref().into(),
|
|
connections: connect.to_vec()
|
|
};
|
|
port.connect_to_matching()?;
|
|
Ok(port)
|
|
}
|
|
}
|
|
|
|
impl JackPort for AudioOutput {
|
|
type Port = AudioOut;
|
|
type Pair = AudioIn;
|
|
fn port_name (&self) -> &Arc<str> {
|
|
&self.name
|
|
}
|
|
fn port (&self) -> &Port<Self::Port> {
|
|
&self.port
|
|
}
|
|
fn port_mut (&mut self) -> &mut Port<Self::Port> {
|
|
&mut self.port
|
|
}
|
|
fn into_port (self) -> Port<Self::Port> {
|
|
self.port
|
|
}
|
|
fn connections (&self) -> &[Connect] {
|
|
self.connections.as_slice()
|
|
}
|
|
fn new (jack: &Jack<'static>, name: &impl AsRef<str>, connect: &[Connect])
|
|
-> Usually<Self> where Self: Sized
|
|
{
|
|
let port = Self {
|
|
port: Self::register(jack, name)?,
|
|
jack: jack.clone(),
|
|
name: name.as_ref().into(),
|
|
connections: connect.to_vec()
|
|
};
|
|
port.connect_to_matching()?;
|
|
Ok(port)
|
|
}
|
|
}
|