diff --git a/libao/libao.rkt b/libao/libao.rkt index b5bb368..d7cd10a 100644 --- a/libao/libao.rkt +++ b/libao/libao.rkt @@ -156,11 +156,16 @@ (if (number? handle) (let ((ao-device (hash-ref devices handle #f))) - (close-device #f ao-device)) + (unless (eq? ao-device #f) + (displayln (format "Closing ao device ~a" ao-device)) + (close-device #f ao-device) + (hash-remove! devices handle))) (let ((handle-num (ao-handle-handle-num handle))) (let ((ao-device (hash-ref devices handle-num #f))) - (displayln (format "ao-device = ~a" ao-device)) - (close-device handle ao-device)) + (unless (eq? ao-device #f) + (displayln (format "ao-device = ~a" ao-device)) + (close-device handle ao-device) + (hash-remove! devices handle-num))) ) ) )