From 516c4f11c002fea54f10d782d8c0b1acc6637173 Mon Sep 17 00:00:00 2001 From: Hileb <107909747+Ecdcaeb@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:14:18 +0800 Subject: [PATCH] Fix SoundManager handling when no sound devices exist (#226) * destroy only when created --- src/main/java/org/lwjgl/openal/AL.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/lwjgl/openal/AL.java b/src/main/java/org/lwjgl/openal/AL.java index 358a5329..6152b7c2 100644 --- a/src/main/java/org/lwjgl/openal/AL.java +++ b/src/main/java/org/lwjgl/openal/AL.java @@ -70,10 +70,14 @@ public static boolean isCreated() { } public static void destroy() { - org.lwjgl3.openal.ALC10.alcDestroyContext(alcContext.context); - org.lwjgl3.openal.ALC10.alcCloseDevice(alcDevice.device); - alcContext = null; - alcDevice = null; + if (alcContext != null) { + org.lwjgl3.openal.ALC10.alcDestroyContext(alcContext.context); + alcContext = null; + } + if (alcDevice != null) { + org.lwjgl3.openal.ALC10.alcCloseDevice(alcDevice.device); + alcDevice = null; + } created = false; }