-
This commit is contained in:
Binary file not shown.
@@ -67,6 +67,7 @@ typedef struct {
|
||||
double music_duration;
|
||||
ao_play_func_t ao_play_f;
|
||||
int buf_size;
|
||||
int paused;
|
||||
} AO_Handle;
|
||||
|
||||
//static int(*ao_play)(void *device, char *samples, uint32_t n) = NULL;
|
||||
@@ -158,7 +159,7 @@ static DWORD run(LPVOID arg)
|
||||
|
||||
while(go_on) {
|
||||
MUTEX_LOCK(handle->mutex);
|
||||
int has_frames = (handle->play_queue != NULL);
|
||||
int has_frames = (!handle->paused) && (handle->play_queue != NULL);
|
||||
|
||||
if (has_frames) {
|
||||
Queue_t *q = get(handle);
|
||||
@@ -201,6 +202,7 @@ void *ao_create_async(void *ao_device_yeah, void *ao_play_f)
|
||||
|
||||
handle->ao_play_f = ao_play_f;
|
||||
handle->buf_size = 0;
|
||||
handle->paused = (1 == 0);
|
||||
|
||||
#ifdef USE_PTHREADS
|
||||
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -266,7 +268,6 @@ double ao_is_at_second_async(void *ao_handle)
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
double ao_music_duration_async(void *ao_handle)
|
||||
{
|
||||
AO_Handle *h = (AO_Handle *) ao_handle;
|
||||
@@ -285,4 +286,12 @@ int ao_bufsize_async(void *ao_handle)
|
||||
return s;
|
||||
}
|
||||
|
||||
void ao_pause_async(void *ao_handle, int paused)
|
||||
{
|
||||
AO_Handle *h = (AO_Handle *) ao_handle;
|
||||
MUTEX_LOCK(h->mutex);
|
||||
h->paused = paused;
|
||||
MUTEX_UNLOCK(h->mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
ao_music_duration_async
|
||||
ao_bufsize_async
|
||||
ao_clear_async
|
||||
ao_pause_async
|
||||
)
|
||||
|
||||
(define lib (get-lib '("ao-play-async" "libao-play-async") '(#f)))
|
||||
@@ -42,3 +43,6 @@
|
||||
;extern void ao_clear_async(void *handle);
|
||||
(define-libao-async ao_clear_async(_fun _libao-async-handle-pointer -> _void))
|
||||
|
||||
;extern void ao_pause_async(void *handle, int pause);
|
||||
(define-libao-async ao_pause_async(_fun _libao-async-handle-pointer int -> _void))
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
ao_music_duration_async
|
||||
ao_bufsize_async
|
||||
ao_clear_async
|
||||
ao_pause_async
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -43,6 +44,7 @@
|
||||
queue-sem
|
||||
[queue #:mutable]
|
||||
[stopped #:mutable]
|
||||
[paused #:mutable]
|
||||
)
|
||||
#:transparent
|
||||
)
|
||||
@@ -53,6 +55,14 @@
|
||||
(λ ()
|
||||
(let ((ao-device (ao-shm-device shm)))
|
||||
(define (player)
|
||||
|
||||
(mutex-lock (ao-shm-mutex shm))
|
||||
(let ((p (ao-shm-paused shm)))
|
||||
(mutex-unlock (ao-shm-mutex shm))
|
||||
(when p
|
||||
(sleep 0.25)
|
||||
(player)))
|
||||
|
||||
(os-semaphore-wait (ao-shm-queue-sem shm))
|
||||
(mutex-lock (ao-shm-mutex shm))
|
||||
(if (= (queue-length (ao-shm-queue shm)) 0)
|
||||
@@ -97,7 +107,7 @@
|
||||
)
|
||||
|
||||
(define (ao-player ao_device)
|
||||
(let ((shm (make-ao-shm (make-mutex) ao_device 0.0 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 #f)))
|
||||
(ao-player* shm)
|
||||
shm
|
||||
)
|
||||
@@ -174,3 +184,7 @@
|
||||
(set-ao-shm-bufsize! shm 0)
|
||||
)
|
||||
|
||||
(define (ao_pause_async shm pause)
|
||||
(set-ao-shm-paused! shm pause)
|
||||
)
|
||||
|
||||
|
||||
@@ -230,6 +230,12 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define (ao-pause handle pause)
|
||||
(if (eq? libao-async-mode 'ffi)
|
||||
(ffi:ao_pause_async (ao-handle-async-player handle) pause)
|
||||
(scm:ao_pause_async (ao-handle-async-plauer handle) pause)
|
||||
))
|
||||
|
||||
(define (ao-at-second handle)
|
||||
(if (eq? libao-async-mode 'ffi)
|
||||
(ffi:ao_is_at_second_async (ao-handle-async-player handle))
|
||||
|
||||
@@ -248,7 +248,7 @@
|
||||
'jpg)
|
||||
((string-suffix? mt "/png")
|
||||
'png)
|
||||
(else (error (format "mimetype not supported: ~a" mt)))
|
||||
(else #f)
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user