diff options
author | David Thompson <dthompson2@worcester.edu> | 2022-09-17 16:13:15 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2022-09-17 16:13:15 -0400 |
commit | c601d6a7e2079421627a77c5fcbd93716870e3c7 (patch) | |
tree | 712954e33046b597ba380154ea301e9295325393 | |
parent | 43d179567499a62653f2d110f30caf135b84c069 (diff) |
audio: Do not crash if there are no audio devices available.
-rw-r--r-- | chickadee/audio.scm | 21 |
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) |