aboutsummaryrefslogtreecommitdiff
path: root/guile
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-01 17:28:33 +0100
committerThomas White <taw@physics.org>2021-03-01 17:28:33 +0100
commitd7d10c78b205b9490f8d2cdf98d5f759f3aec391 (patch)
tree624b63794b9bed3fe3298a35b37fbf8b384fefd9 /guile
parent52b63c846c010e16aed96a06bb17b9e0bfaf1abc (diff)
Refuse to run two OLA output threads at once
Diffstat (limited to 'guile')
-rw-r--r--guile/starlet/base.scm35
1 files changed, 20 insertions, 15 deletions
diff --git a/guile/starlet/base.scm b/guile/starlet/base.scm
index 54c3806..8f93751 100644
--- a/guile/starlet/base.scm
+++ b/guile/starlet/base.scm
@@ -470,23 +470,28 @@ pre-existing contents."
(scanout-loop ola-uri ola-socket (hirestime) 0))
(scanout-loop ola-uri ola-socket start-time (+ count 1)))))
+(define ola-thread #f)
(define (start-ola-output)
- (let* ((ola-uri (build-uri 'http
- #:host "127.0.0.1"
- #:port 9090
- #:path "/set_dmx"))
- (ola-socket (open-socket-for-uri ola-uri))
- (start-time (hirestime)))
-
- (begin-thread
- (with-exception-handler
- (lambda (exn)
- (backtrace)
- (raise-exception exn))
- (lambda ()
- (scanout-loop ola-uri ola-socket start-time 0))
- #:unwind? #f))))
+ (unless ola-thread
+ (let* ((ola-uri (build-uri 'http
+ #:host "127.0.0.1"
+ #:port 9090
+ #:path "/set_dmx"))
+ (ola-socket (open-socket-for-uri ola-uri))
+ (start-time (hirestime)))
+
+ (set! ola-thread
+ (begin-thread
+ (with-exception-handler
+ (lambda (exn)
+ (display "Error in OLA output thread:\n")
+ (set! ola-thread #f)
+ (backtrace)
+ (raise-exception exn))
+ (lambda ()
+ (scanout-loop ola-uri ola-socket start-time 0))
+ #:unwind? #f))))))