summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-09-17 16:13:15 -0400
committerDavid Thompson <dthompson2@worcester.edu>2022-09-17 16:13:15 -0400
commitc601d6a7e2079421627a77c5fcbd93716870e3c7 (patch)
tree712954e33046b597ba380154ea301e9295325393
parent43d179567499a62653f2d110f30caf135b84c069 (diff)
audio: Do not crash if there are no audio devices available.
-rw-r--r--chickadee/audio.scm21
1 files changed, 13 insertions, 8 deletions
diff --git a/chickadee/audio.scm b/chickadee/audio.scm
index 7b5b0f3..e7bce70 100644
--- a/chickadee/audio.scm
+++ b/chickadee/audio.scm
@@ -161,14 +161,19 @@
(guardian sound-system-guardian))
(define (make-sound-system)
- (%make-sound-system (openal:make-context (openal:open-device))
- (make-array-list)
- (make-hash-table)
- (make-weak-key-hash-table)
- (make-hash-table)
- (make-array-list)
- (make-hash-table)
- (make-guardian)))
+ ;; It's possible that there are *no* audio devices available, in
+ ;; which case open-device throws an exception. In that case, return
+ ;; #f.
+ (let ((device (false-if-exception (openal:open-device))))
+ (and device
+ (%make-sound-system (openal:make-context device)
+ (make-array-list)
+ (make-hash-table)
+ (make-weak-key-hash-table)
+ (make-hash-table)
+ (make-array-list)
+ (make-hash-table)
+ (make-guardian)))))
(define (register-source sound-system source)
(hashq-set! (sound-system-sources sound-system) source source)