From df27105a06669def109adf8670542bfd4fd033fe Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Wed, 15 Apr 2026 09:44:01 +0200 Subject: [PATCH] added validity checking --- libao.rkt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libao.rkt b/libao.rkt index 1e0e241..df311bc 100644 --- a/libao.rkt +++ b/libao.rkt @@ -16,6 +16,7 @@ ao-bufsize-async ao-clear-async ao-pause + ao-valid? ) (define device-number 1) @@ -71,6 +72,9 @@ ) ) +(define (ao-valid? handle) + (not (eq? (ao-handle-async-player handle) #f))) + (define (ao-play handle at-time-in-s music-duration-s buffer buf-len buf-type) (let* ((bytes-per-sample (ao-handle-bytes-per-sample handle)) (bits (ao-handle-bits handle)) @@ -79,6 +83,8 @@ (endianess (ao-handle-byte-format handle)) (buf-info (ffi:make-BufferInfo_t buf-type bits rate channels endianess)) ) + (unless (ao-valid? handle) + (error "Cannot play on an invalid ao-device")) (ffi:ao_play_async (ao-handle-async-player handle) (exact->inexact at-time-in-s) (exact->inexact music-duration-s)