53 lines
1.8 KiB
Racket
53 lines
1.8 KiB
Racket
#lang racket/base
|
|
|
|
|
|
(require ffi/unsafe
|
|
ffi/unsafe/define
|
|
setup/dirs
|
|
"../utils/utils.rkt"
|
|
racket/runtime-path
|
|
"libao-ffi.rkt"
|
|
)
|
|
|
|
(provide ao_create_async
|
|
ao_stop_async
|
|
ao_play_async
|
|
ao_is_at_second_async
|
|
ao_bufsize_async
|
|
ao_clear_async
|
|
)
|
|
|
|
(define-runtime-path libao-async-lib-path "./lib")
|
|
|
|
(define lib (if (eq? (system-type 'os) 'windows)
|
|
(build-path libao-async-lib-path "ao-play-async")
|
|
(build-path libao-async-lib-path "libao-play-async")))
|
|
|
|
(define-ffi-definer define-libao-async
|
|
(ffi-lib lib '("0" #f)
|
|
#:get-lib-dirs (λ ()
|
|
(let ((sp (cons (build-path ".") (get-lib-search-dirs))))
|
|
;(displayln sp)
|
|
sp))
|
|
#:fail (λ () (error "Cannot load libao-play-async"))
|
|
))
|
|
|
|
(define _libao-async-handle-pointer (_cpointer 'ao-async-handle))
|
|
|
|
;extern void *ao_create_async(void *ao_device, );
|
|
(define-libao-async ao_create_async(_fun _pointer _fpointer -> _libao-async-handle-pointer))
|
|
|
|
;extern void ao_stop_async(void *handle);
|
|
(define-libao-async ao_stop_async(_fun _libao-async-handle-pointer -> _void))
|
|
|
|
;extern void ao_play_async(void *handle, double at_second, int buf_size, void *mem);
|
|
(define-libao-async ao_play_async(_fun _libao-async-handle-pointer _double _uint32 _pointer -> _void))
|
|
|
|
;extern double ao_is_at_second_async(void *handle);
|
|
(define-libao-async ao_is_at_second_async(_fun _libao-async-handle-pointer -> _double))
|
|
|
|
;extern int ao_bufsize_async(void *handle);
|
|
(define-libao-async ao_bufsize_async(_fun _libao-async-handle-pointer -> _int))
|
|
|
|
;extern void ao_clear_async(void *handle);
|
|
(define-libao-async ao_clear_async(_fun _libao-async-handle-pointer -> _void)) |