pause behavior

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