mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-11 14:16:42 +01:00
wip: refactor pt.34 (35e) more traits, fewer structs
This commit is contained in:
parent
cbbecc5aba
commit
beca1a6ade
19 changed files with 361 additions and 379 deletions
|
|
@ -35,18 +35,23 @@ impl<T: PlayheadApi> Command<T> for PlayheadCommand {
|
|||
|
||||
pub trait PlayheadApi: ClockApi {
|
||||
|
||||
fn playing (&self) -> &Arc<RwLock<TransportState>>;
|
||||
fn transport (&self) -> &RwLock<Option<TransportState>>;
|
||||
|
||||
fn transport (&self) -> Transport;
|
||||
fn playing (&self) -> &RwLock<Option<TransportState>>;
|
||||
|
||||
/// Global sample and usec at which playback started
|
||||
fn started (&self) -> &RwLock<Option<(usize, usize)>>;
|
||||
|
||||
fn pulse (&self) -> f64 {
|
||||
self.current().pulse.get()
|
||||
}
|
||||
|
||||
fn next_launch_pulse (&self) -> usize {
|
||||
let sync = self.sync().get() as usize;
|
||||
let pulse = self.pulse() as usize;
|
||||
if pulse % sync == 0 { pulse } else { (pulse / sync + 1) * sync }
|
||||
}
|
||||
|
||||
fn toggle_play (&self) -> Usually<()> {
|
||||
let playing = self.playing().read().unwrap().expect("1st sample has not been processed yet");
|
||||
let playing = match playing {
|
||||
|
|
@ -63,10 +68,12 @@ pub trait PlayheadApi: ClockApi {
|
|||
*self.playing().write().unwrap() = playing;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_stopped (&self) -> bool {
|
||||
*self.playing().read().unwrap() == Some(TransportState::Stopped)
|
||||
}
|
||||
|
||||
fn is_rolling (&self) -> bool {
|
||||
*self.clock.playing.read().unwrap() == Some(TransportState::Rolling)
|
||||
*self.playing().read().unwrap() == Some(TransportState::Rolling)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue