mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 15:56:57 +02:00
restruct: 92e
This commit is contained in:
parent
4ec2165e3d
commit
ae347eeef7
31 changed files with 2924 additions and 2663 deletions
103
src/device/port/audio.rs
Normal file
103
src/device/port/audio.rs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue