tek/crates/device/src/port/port_audio_in.rs
unspeaker 0192d85a19
Some checks are pending
/ build (push) Waiting to run
wip: compiles again, after extensive jack rework
2025-05-21 01:45:23 +03:00

48 lines
1.2 KiB
Rust

use crate::*;
#[derive(Debug)] pub struct AudioInput {
/// Handle to JACK client, for receiving reconnect events.
jack: Jack<'static>,
/// Port name
name: Arc<str>,
/// Port handle.
port: Port<AudioIn>,
/// List of ports to connect to.
pub connections: Vec<Connect>,
}
impl HasJack<'static> for AudioInput {
fn jack (&self) -> &Jack<'static> {
&self.jack
}
}
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)
}
}