From cc5bf0c203a81125f73b5135adc7dcc8d3772d3f Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Tue, 24 Feb 2026 14:05:46 +0100 Subject: [PATCH] - --- libao/libao.rkt | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libao/libao.rkt b/libao/libao.rkt index 7596f74..a04e4e0 100644 --- a/libao/libao.rkt +++ b/libao/libao.rkt @@ -29,6 +29,7 @@ [channels #:auto #:mutable] [rate #:auto #:mutable] [async-player #:auto #:mutable] + [closed #:auto #:mutable] ) #:auto-value #f ) @@ -107,15 +108,17 @@ (printf "Unexpected: cannot close ao-device")))) 'internally-closed) (let ((handle-num (ao-handle-handle-num handle))) - (ao_stop_async (ao-handle-async-player handle)) - (let ((ao-device (hash-ref devices handle-num #f))) - (if (eq? ao-device #f) - 'error-ao-device-non-existent - (let ((r (ao_close ao-device))) - (hash-remove! devices handle-num) - (if (= r 0) - 'error-closing-ao-device - 'ok))))))) + (unless (ao-handle-closed handle) + (set-ao-handle-closed! handle #t) + (ao_stop_async (ao-handle-async-player handle)) + (let ((ao-device (hash-ref devices handle-num #f))) + (if (eq? ao-device #f) + 'error-ao-device-non-existent + (let ((r (ao_close ao-device))) + (hash-remove! devices handle-num) + (if (= r 0) + 'error-closing-ao-device + 'ok)))))))) (define count 0)