mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
refactor: jack proto-lib
This commit is contained in:
parent
4aadc712b8
commit
fe6ffea5df
12 changed files with 467 additions and 441 deletions
29
src/jack/device.rs
Normal file
29
src/jack/device.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use super::*;
|
||||
|
||||
/// A Device bound to a JACK client and a set of ports.
|
||||
pub struct JackDevice {
|
||||
/// The active JACK client of this device.
|
||||
pub client: DynamicAsyncClient,
|
||||
/// The device state, encapsulated for sharing between threads.
|
||||
pub state: Arc<Mutex<Box<dyn Device>>>,
|
||||
/// Unowned copies of the device's JACK ports, for connecting to the device.
|
||||
/// The "real" readable/writable `Port`s are owned by the `state`.
|
||||
pub ports: UnownedJackPorts,
|
||||
}
|
||||
ports!(JackDevice {
|
||||
audio: {
|
||||
ins: |s|Ok(s.ports.audio_ins.values().collect()),
|
||||
outs: |s|Ok(s.ports.audio_outs.values().collect()),
|
||||
}
|
||||
midi: {
|
||||
ins: |s|Ok(s.ports.midi_ins.values().collect()),
|
||||
outs: |s|Ok(s.ports.midi_outs.values().collect()),
|
||||
}
|
||||
});
|
||||
impl JackDevice {
|
||||
/// Returns a locked mutex of the state's contents.
|
||||
pub fn state (&self) -> MutexGuard<Box<dyn Device>> {
|
||||
self.state.lock().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue