pause behavior

This commit is contained in:
2026-05-07 15:00:00 +02:00
parent d531f9caef
commit 51697f2106
+5 -15
View File
@@ -1,4 +1,4 @@
(#lang racket/base
#lang racket/base
;; Pure Racket replacement for ao_playasync.c as used by libao.rkt.
;;
@@ -469,20 +469,12 @@
(mutex-lock (ao-handle-pause-mutex h))
(mutex-unlock (ao-handle-pause-mutex h))
(mutex-lock (ao-handle-clear-mutex h))
(let ((elem (if (ao-handle-paused h)
#f
(get h 150))))
(let ((elem (get h 150)))
(mutex-unlock (ao-handle-clear-mutex h))
(if (eq? elem #f)
(if (ao-handle-paused h)
(begin
(dbg-sound "run thread paused")
(sleep 0.1)
)
(begin
(dbg-sound "nothing in the queue")
(sleep 0.01))
)
(begin
(dbg-sound "nothing in the queue")
(sleep 0.05))
(begin
(if (eq? (queue-elem-command elem) 'stop)
(set! go-on #f)
@@ -768,14 +760,12 @@
(when (integer? paused)
(set! paused (not (= paused 0))))
(dbg-sound "ao_pause_async ~a" paused)
(sync-log-sound)
(if (ao-handle-paused h)
(when (eq? paused #f)
(mutex-unlock (ao-handle-pause-mutex h))
(set-ao-handle-paused! h #f)
)
(when (eq? paused #t)
(dbg-sound "locking pause mutex")
(sync-log-sound)
(mutex-lock (ao-handle-pause-mutex h))
(set-ao-handle-paused! h #t)