mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: port: make device
This commit is contained in:
parent
447638ee71
commit
cb7e4f7a95
31 changed files with 602 additions and 865 deletions
44
crates/device/src/port/port_audio_out.rs
Normal file
44
crates/device/src/port/port_audio_out.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Debug)] pub struct AudioOutput {
|
||||
/// Handle to JACK client, for receiving reconnect events.
|
||||
jack: Jack<'static>,
|
||||
/// Port name
|
||||
name: Arc<str>,
|
||||
/// Port handle.
|
||||
port: Port<AudioOut>,
|
||||
/// List of ports to connect to.
|
||||
pub connections: Vec<Connect>,
|
||||
}
|
||||
has!(Jack<'static>: |self: AudioOutput|self.jack);
|
||||
impl JackPort for AudioOutput {
|
||||
type Port = AudioOut;
|
||||
type Pair = AudioIn;
|
||||
fn 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