quit patch

This commit is contained in:
2026-07-06 15:20:36 +02:00
parent c8494e289e
commit 01752d6e4b
+16 -5
View File
@@ -97,6 +97,11 @@
(define (get)
(uni-channel-get ch-in))
(define (close-and-wait ch)
(when ch
(uni-channel-close ch)
(uni-channel-wait ch)))
(define (audio-read-worker ao-dec file-id)
(set! feeding-audio #t)
@@ -481,11 +486,17 @@
))])
(cond
((eq? cmd 'quit) (do-rpc
(stop-and-cleanup)
(set! player-state 'quit)
(state "quit" evt 'force)
'(quit)))
((eq? cmd 'quit)
;; Quit is the one RPC where the acknowledgement must be written
;; before the worker starts tearing down its audio state and stdio
;; transport. For port-based uni-channels, put is asynchronous:
;; close-and-wait makes sure the queued '(quit) has actually been
;; written and flushed before the process exits.
(put '(quit))
(close-and-wait ch-out)
(stop-and-cleanup)
(set! player-state 'quit)
(close-and-wait ch-evt))
((eq? cmd 'init) (do-rpc
(set! ch-out (->uni-channel (cadr data)))
(set! ch-evt (->uni-channel (caddr data)))