mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-11 14:16:42 +01:00
wip: borrow checker battles
This commit is contained in:
parent
1d4db3c629
commit
7fbb40fad6
38 changed files with 778 additions and 708 deletions
|
|
@ -3,18 +3,16 @@ use tek_core::edn;
|
|||
|
||||
/// A sequencer track.
|
||||
#[derive(Debug)]
|
||||
pub struct Track {
|
||||
pub struct Track<T, U> {
|
||||
pub name: String,
|
||||
/// Inputs and outputs of 1st and last device
|
||||
pub ports: JackPorts,
|
||||
/// Device chain
|
||||
pub devices: Vec<JackDevice>,
|
||||
pub devices: Vec<JackDevice<T, U>>,
|
||||
/// Device selector
|
||||
pub device: usize,
|
||||
}
|
||||
|
||||
impl Track {
|
||||
|
||||
impl<T, U> Track<T, U> {
|
||||
pub fn new (name: &str) -> Usually<Self> {
|
||||
Ok(Self {
|
||||
name: name.to_string(),
|
||||
|
|
@ -23,15 +21,14 @@ impl Track {
|
|||
device: 0,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_device_mut (&self, i: usize) -> Option<RwLockWriteGuard<Box<dyn Device>>> {
|
||||
fn get_device_mut (&self, i: usize) -> Option<RwLockWriteGuard<Box<dyn Device<T, U>>>> {
|
||||
self.devices.get(i).map(|d|d.state.write().unwrap())
|
||||
}
|
||||
pub fn device_mut (&self) -> Option<RwLockWriteGuard<Box<dyn Device>>> {
|
||||
pub fn device_mut (&self) -> Option<RwLockWriteGuard<Box<dyn Device<T, U>>>> {
|
||||
self.get_device_mut(self.device)
|
||||
}
|
||||
/// Add a device to the end of the chain.
|
||||
pub fn append_device (&mut self, device: JackDevice) -> Usually<&mut JackDevice> {
|
||||
pub fn append_device (&mut self, device: JackDevice<T, U>) -> Usually<&mut JackDevice<T, U>> {
|
||||
self.devices.push(device);
|
||||
let index = self.devices.len() - 1;
|
||||
Ok(&mut self.devices[index])
|
||||
|
|
@ -57,7 +54,7 @@ impl Track {
|
|||
let mut _gain = 0.0f64;
|
||||
let mut track = Self::new("")?;
|
||||
#[allow(unused_mut)]
|
||||
let mut devices: Vec<JackDevice> = vec![];
|
||||
let mut devices: Vec<JackDevice<T, U>> = vec![];
|
||||
edn!(edn in args {
|
||||
Edn::Map(map) => {
|
||||
if let Some(Edn::Str(n)) = map.get(&Edn::Key(SYM_NAME)) {
|
||||
|
|
@ -98,8 +95,7 @@ impl Track {
|
|||
}
|
||||
Ok(track)
|
||||
}
|
||||
|
||||
pub fn add_device (&mut self, device: JackDevice) {
|
||||
pub fn add_device (&mut self, device: JackDevice<T, U>) {
|
||||
self.devices.push(device);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue