mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
modularize core
This commit is contained in:
parent
a4061535b5
commit
2837ffff4a
43 changed files with 629 additions and 770 deletions
50
src/core/port.rs
Normal file
50
src/core/port.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use crate::core::*;
|
||||
|
||||
/// Trait for things that may expose JACK ports.
|
||||
pub trait PortList {
|
||||
fn audio_ins (&self) -> Usually<Vec<String>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
fn audio_outs (&self) -> Usually<Vec<String>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
fn midi_ins (&self) -> Usually<Vec<String>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
fn midi_outs (&self) -> Usually<Vec<String>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
fn connect (&mut self, _connect: bool, _source: &str, _target: &str)
|
||||
-> Usually<()>
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
fn connect_all (&mut self, connections: &[(bool, &str, &str)])
|
||||
-> Usually<()>
|
||||
{
|
||||
for (connect, source, target) in connections.iter() {
|
||||
self.connect(*connect, source, target)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DevicePort<T: PortSpec> {
|
||||
pub name: String,
|
||||
pub port: Port<T>,
|
||||
pub connect: Vec<String>,
|
||||
}
|
||||
|
||||
impl<T: PortSpec + Default> DevicePort<T> {
|
||||
pub fn new (client: &Client, name: &str, connect: &[&str]) -> Usually<Self> {
|
||||
let mut connects = vec![];
|
||||
for port in connect.iter() {
|
||||
connects.push(port.to_string());
|
||||
}
|
||||
Ok(Self {
|
||||
name: name.to_string(),
|
||||
port: client.register_port(name, T::default())?,
|
||||
connect: connects,
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue