-
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
ao_stop_async
|
ao_stop_async
|
||||||
ao_play_async
|
ao_play_async
|
||||||
ao_is_at_second_async
|
ao_is_at_second_async
|
||||||
|
ao_music_duration_async
|
||||||
ao_bufsize_async
|
ao_bufsize_async
|
||||||
ao_clear_async
|
ao_clear_async
|
||||||
)
|
)
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
(mutex
|
(mutex
|
||||||
device
|
device
|
||||||
[at-second #:mutable]
|
[at-second #:mutable]
|
||||||
|
[music-duration #:mutable]
|
||||||
[bufsize #:mutable]
|
[bufsize #:mutable]
|
||||||
queue-sem
|
queue-sem
|
||||||
[queue #:mutable]
|
[queue #:mutable]
|
||||||
@@ -70,11 +72,13 @@
|
|||||||
'done)]
|
'done)]
|
||||||
[(eq? command 'play)
|
[(eq? command 'play)
|
||||||
(let ((at-second (cadr elem))
|
(let ((at-second (cadr elem))
|
||||||
(buf-len (caddr elem))
|
(duration (caddr elem))
|
||||||
(buf (cadddr elem))
|
(buf-len (caddrr elem))
|
||||||
|
(buf (car (cddddr elem)))
|
||||||
)
|
)
|
||||||
(mutex-lock (ao-shm-mutex shm))
|
(mutex-lock (ao-shm-mutex shm))
|
||||||
(set-ao-shm-at-second! shm at-second)
|
(set-ao-shm-at-second! shm at-second)
|
||||||
|
(set-ao-shm-music-duration! shm duration)
|
||||||
(let ((bs (ao-shm-bufsize shm)))
|
(let ((bs (ao-shm-bufsize shm)))
|
||||||
(set-ao-shm-bufsize! shm (- bs buf-len)))
|
(set-ao-shm-bufsize! shm (- bs buf-len)))
|
||||||
(mutex-unlock (ao-shm-mutex shm))
|
(mutex-unlock (ao-shm-mutex shm))
|
||||||
@@ -93,7 +97,7 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
(define (ao-player ao_device)
|
(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)
|
(ao-player* shm)
|
||||||
shm
|
shm
|
||||||
)
|
)
|
||||||
@@ -109,7 +113,7 @@
|
|||||||
(define (ao_stop_async shm)
|
(define (ao_stop_async shm)
|
||||||
(mutex-lock (ao-shm-mutex shm))
|
(mutex-lock (ao-shm-mutex shm))
|
||||||
(ao_clear_async* 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))
|
(os-semaphore-post (ao-shm-queue-sem shm))
|
||||||
(mutex-unlock (ao-shm-mutex shm))
|
(mutex-unlock (ao-shm-mutex shm))
|
||||||
(let ((stopped (λ ()
|
(let ((stopped (λ ()
|
||||||
@@ -128,8 +132,8 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(define (ao_play_async shm at-second buf-size buf)
|
(define (ao_play_async shm at-second music-duration buf-size buf)
|
||||||
(let ((item (list 'play at-second buf-size buf)))
|
(let ((item (list 'play at-second music-duration buf-size buf)))
|
||||||
(mutex-lock (ao-shm-mutex shm))
|
(mutex-lock (ao-shm-mutex shm))
|
||||||
(let ((bs (ao-shm-bufsize shm)))
|
(let ((bs (ao-shm-bufsize shm)))
|
||||||
(set-ao-shm-bufsize! shm (+ bs buf-size)))
|
(set-ao-shm-bufsize! shm (+ bs buf-size)))
|
||||||
@@ -143,6 +147,12 @@
|
|||||||
(mutex-unlock (ao-shm-mutex shm))
|
(mutex-unlock (ao-shm-mutex shm))
|
||||||
at-second))
|
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)
|
(define (ao_bufsize_async shm)
|
||||||
(mutex-lock (ao-shm-mutex shm))
|
(mutex-lock (ao-shm-mutex shm))
|
||||||
(let ((buf-size (ao-shm-bufsize shm)))
|
(let ((buf-size (ao-shm-bufsize shm)))
|
||||||
|
|||||||
Reference in New Issue
Block a user