aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-05-24 18:49:32 +0200
committerThomas White <taw@physics.org>2021-05-24 18:49:57 +0200
commitd685dd9b22301e0622e9f8f80a9d9b9480062e17 (patch)
treee9110da7e8239284ad105f258f1293db346c2038
parentf0dca1d9b2abaf0852af80736d4757082e3f07b5 (diff)
Factorise set-playback-state
-rw-r--r--guile/starlet/playback.scm20
1 files changed, 10 insertions, 10 deletions
diff --git a/guile/starlet/playback.scm b/guile/starlet/playback.scm
index 5a8f7a3..cc73d65 100644
--- a/guile/starlet/playback.scm
+++ b/guile/starlet/playback.scm
@@ -144,13 +144,17 @@
cue-list))
+(define (set-playback-state! pb state)
+ (atomic-box-set! (state-box pb) state)
+ (run-hook (state-change-hook pb) state))
+
+
(define (cut-to-cue-index! pb cue-index)
(let ((cue-list (get-playback-cue-list pb)))
(clear-state! pb)
(set-next-cue-index! pb (+ cue-index 1))
(set-cue-clock! pb #f)
- (atomic-box-set! (state-box pb) 'ready)
- (run-hook (state-change-hook pb) 'ready)
+ (set-playback-state! pb 'ready)
(let ((cue-state (calculate-tracking cue-list cue-index)))
(state-for-each
(lambda (fix attr val)
@@ -199,8 +203,7 @@
;; Restart paused cue
(begin (start-clock! clock)
- (atomic-box-set! (state-box pb) 'running)
- (run-hook (state-change-hook pb) 'running))
+ (set-playback-state! pb 'running))
;; Run next cue
(let ((next-cue-index (get-next-cue-index pb)))
@@ -217,16 +220,14 @@
(when (and clock
(not (clock-expired? clock)))
(stop-clock! (get-cue-clock pb))
- (atomic-box-set! (state-box pb) 'pause)
- (run-hook (state-change-hook pb) 'pause))))
+ (set-playback-state! pb 'pause))))
(define (back! pb)
(let ((prev-cue-index (- (get-next-cue-index pb) 2)))
(if (>= prev-cue-index 0)
(begin (cut-to-cue-index! pb prev-cue-index)
- (atomic-box-set! (state-box pb) 'ready)
- (run-hook (state-change-hook pb) 'ready))
+ (set-playback-state! pb 'ready))
'already-at-cue-zero)))
@@ -518,8 +519,7 @@
(atomically-overlay-state! pb overlay-state)
(set-cue-clock! pb cue-clock)
- (atomic-box-set! (state-box pb) 'running)
- (run-hook (state-change-hook pb) 'running)))
+ (set-playback-state! pb 'running)))
(define (print-playback pb)