diff --git a/lib/linux-x86_64/libao-play-async.so b/lib/linux-x86_64/libao-play-async.so index 0ef5f00..5401d6b 100755 Binary files a/lib/linux-x86_64/libao-play-async.so and b/lib/linux-x86_64/libao-play-async.so differ diff --git a/libao/c/ao-play-async/ao_playasync.c b/libao/c/ao-play-async/ao_playasync.c index f0ac282..e35dae2 100644 --- a/libao/c/ao-play-async/ao_playasync.c +++ b/libao/c/ao-play-async/ao_playasync.c @@ -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); +} + diff --git a/libao/libao-async-ffi.rkt b/libao/libao-async-ffi.rkt index 0a9fd04..eb73c75 100644 --- a/libao/libao-async-ffi.rkt +++ b/libao/libao-async-ffi.rkt @@ -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)) + diff --git a/libao/libao-async.rkt b/libao/libao-async.rkt index 79a77a8..d8ce323 100644 --- a/libao/libao-async.rkt +++ b/libao/libao-async.rkt @@ -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 ) @@ -173,4 +183,8 @@ (set-ao-shm-queue! shm (make-queue)) (set-ao-shm-bufsize! shm 0) ) + +(define (ao_pause_async shm pause) + (set-ao-shm-paused! shm pause) + ) diff --git a/libao/libao.rkt b/libao/libao.rkt index ad7eba6..7c7717b 100644 --- a/libao/libao.rkt +++ b/libao/libao.rkt @@ -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)) diff --git a/libtag/taglib.rkt b/libtag/taglib.rkt index ef56a3c..7d1e8ff 100644 --- a/libtag/taglib.rkt +++ b/libtag/taglib.rkt @@ -248,7 +248,7 @@ 'jpg) ((string-suffix? mt "/png") 'png) - (else (error (format "mimetype not supported: ~a" mt))) + (else #f) ) ))