diff options
author | Thomas White <taw@physics.org> | 2021-03-01 17:28:33 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-03-01 17:28:33 +0100 |
commit | d7d10c78b205b9490f8d2cdf98d5f759f3aec391 (patch) | |
tree | 624b63794b9bed3fe3298a35b37fbf8b384fefd9 | |
parent | 52b63c846c010e16aed96a06bb17b9e0bfaf1abc (diff) |
Refuse to run two OLA output threads at once
-rw-r--r-- | guile/starlet/base.scm | 35 |
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)))))) |