This commit is contained in:
2026-02-25 10:30:01 +01:00
parent 626670699f
commit 5ebb6a6041

View File

@@ -10,6 +10,7 @@
ao_stop_async
ao_play_async
ao_is_at_second_async
ao_music_duration_async
ao_bufsize_async
ao_clear_async
)
@@ -37,6 +38,7 @@
(mutex
device
[at-second #:mutable]
[music-duration #:mutable]
[bufsize #:mutable]
queue-sem
[queue #:mutable]
@@ -70,11 +72,13 @@
'done)]
[(eq? command 'play)
(let ((at-second (cadr elem))
(buf-len (caddr elem))
(buf (cadddr elem))
(duration (caddr elem))
(buf-len (caddrr elem))
(buf (car (cddddr elem)))
)
(mutex-lock (ao-shm-mutex shm))
(set-ao-shm-at-second! shm at-second)
(set-ao-shm-music-duration! shm duration)
(let ((bs (ao-shm-bufsize shm)))
(set-ao-shm-bufsize! shm (- bs buf-len)))
(mutex-unlock (ao-shm-mutex shm))
@@ -93,7 +97,7 @@
)
(define (ao-player ao_device)
(let ((shm (make-ao-shm (make-mutex) ao_device 0.0 0 (make-os-semaphore) (make-queue) #f)))
(let ((shm (make-ao-shm (make-mutex) ao_device 0.0 0.0 0 (make-os-semaphore) (make-queue) #f)))
(ao-player* shm)
shm
)
@@ -109,7 +113,7 @@
(define (ao_stop_async shm)
(mutex-lock (ao-shm-mutex shm))
(ao_clear_async* shm)
(enqueue! (ao-shm-queue shm) (list 'stop 0 #f #f))
(enqueue! (ao-shm-queue shm) (list 'stop 0 0 #f #f))
(os-semaphore-post (ao-shm-queue-sem shm))
(mutex-unlock (ao-shm-mutex shm))
(let ((stopped (λ ()
@@ -128,8 +132,8 @@
)
)
(define (ao_play_async shm at-second buf-size buf)
(let ((item (list 'play at-second buf-size buf)))
(define (ao_play_async shm at-second music-duration buf-size buf)
(let ((item (list 'play at-second music-duration buf-size buf)))
(mutex-lock (ao-shm-mutex shm))
(let ((bs (ao-shm-bufsize shm)))
(set-ao-shm-bufsize! shm (+ bs buf-size)))
@@ -143,6 +147,12 @@
(mutex-unlock (ao-shm-mutex shm))
at-second))
(define (ao_music_duration_async shm)
(mutex-lock (ao-shm-mutex shm))
(let ((music-duration (ao-shm-music-duration shm)))
(mutex-unlock (ao-shm-mutex shm))
music-duration))
(define (ao_bufsize_async shm)
(mutex-lock (ao-shm-mutex shm))
(let ((buf-size (ao-shm-bufsize shm)))