Files
racket-sound/libao/libao-async-ffi.rkt
2026-02-22 23:26:31 +01:00

45 lines
1.5 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
)
(define-runtime-path libao-async-path "./lib/libao-play-async")
(define-ffi-definer define-libao-async
(ffi-lib libao-async-path '("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))