From e045927e3992cf68213fe8ef1a6edb51d8d13550 Mon Sep 17 00:00:00 2001 From: kstvr32 Date: Fri, 13 Sep 2024 13:21:51 -0400 Subject: [PATCH] add null check to mimic behavior of lwjgl2 fix error type --- src/main/java/org/lwjglx/openal/AL.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/lwjglx/openal/AL.java b/src/main/java/org/lwjglx/openal/AL.java index 56a03ec8..af382015 100644 --- a/src/main/java/org/lwjglx/openal/AL.java +++ b/src/main/java/org/lwjglx/openal/AL.java @@ -26,12 +26,12 @@ public static void create() throws LWJGLException { } public static void create(String deviceArguments, int contextFrequency, int contextRefresh, - boolean contextSynchronized) { + boolean contextSynchronized) throws LWJGLException { create(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, true); } public static void create(String deviceArguments, int contextFrequency, int contextRefresh, - boolean contextSynchronized, boolean openDevice) { + boolean contextSynchronized, boolean openDevice) throws LWJGLException { IntBuffer attribs = BufferUtils.createIntBuffer(16); attribs.put(org.lwjgl.openal.ALC10.ALC_FREQUENCY); @@ -64,6 +64,10 @@ public static void create(String deviceArguments, int contextFrequency, int cont long deviceHandle = org.lwjgl.openal.ALC10.alcOpenDevice(defaultDevice); + if (deviceHandle == 0) { + throw new LWJGLException("Could not open ALC device"); + } + alcDevice = new ALCdevice(deviceHandle); final ALCCapabilities deviceCaps = org.lwjgl.openal.ALC.createCapabilities(deviceHandle);