mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
port connections; DevicePorts -> PortList
This commit is contained in:
parent
b1df7bf4e6
commit
22b44f562b
8 changed files with 117 additions and 77 deletions
|
|
@ -21,7 +21,7 @@ pub use self::launcher::Launcher;
|
|||
use crossterm::event;
|
||||
use ::jack::{AudioIn, AudioOut, MidiIn, MidiOut, Port, PortSpec, Client};
|
||||
|
||||
pub trait Device: Render + Handle + DevicePorts + Send + Sync {}
|
||||
pub trait Device: Render + Handle + PortList + Send + Sync {}
|
||||
|
||||
pub fn run (device: impl Device + Send + Sync + 'static) -> Result<(), Box<dyn Error>> {
|
||||
let device = Arc::new(Mutex::new(device));
|
||||
|
|
@ -92,7 +92,7 @@ pub fn run (device: impl Device + Send + Sync + 'static) -> Result<(), Box<dyn E
|
|||
Ok(())
|
||||
}
|
||||
|
||||
impl<T: Render + Handle + DevicePorts + Send + Sync> Device for T {}
|
||||
impl<T: Render + Handle + PortList + Send + Sync> Device for T {}
|
||||
|
||||
pub trait Handle {
|
||||
// Handle an input event.
|
||||
|
|
@ -125,7 +125,7 @@ impl<T: AsRef<str>> Blit for T {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait DevicePorts {
|
||||
pub trait PortList {
|
||||
fn audio_ins (&self) -> Usually<Vec<String>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
|
|
@ -196,7 +196,7 @@ pub struct DynamicDevice<T> {
|
|||
pub render: Mutex<Box<dyn FnMut(&T, &mut Buffer, Rect)->Usually<Rect> + Send>>,
|
||||
pub handle: Arc<Mutex<Box<dyn FnMut(&mut T, &AppEvent)->Usually<bool> + Send>>>,
|
||||
pub process: Arc<Mutex<Box<dyn FnMut(&mut T, &Client, &ProcessScope)->Control + Send>>>,
|
||||
client: Option<DynamicAsyncClient>
|
||||
pub client: Option<DynamicAsyncClient>
|
||||
}
|
||||
|
||||
impl<T> Handle for DynamicDevice<T> {
|
||||
|
|
@ -211,7 +211,7 @@ impl<T> Render for DynamicDevice<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: DevicePorts + Send + Sync + 'static> DevicePorts for DynamicDevice<T> {
|
||||
impl<T: PortList + Send + Sync + 'static> PortList for DynamicDevice<T> {
|
||||
fn audio_ins (&self) -> Usually<Vec<String>> {
|
||||
self.state().audio_ins()
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ impl<T: Send + Sync + 'static> DynamicDevice<T> {
|
|||
client: None,
|
||||
}
|
||||
}
|
||||
fn state (&self) -> std::sync::MutexGuard<'_, T> {
|
||||
pub fn state (&self) -> std::sync::MutexGuard<'_, T> {
|
||||
self.state.lock().unwrap()
|
||||
}
|
||||
fn activate (mut self, client: Client) -> Usually<Self> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue