Fix handling of null device/context in ALC bindings (#108)

Closes #100
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2024-01-11 22:18:54 +00:00
1 parent 8e5ce1ec21
commit b4b733ceb2
2 files changed
+36 -15

No files matched your search

+25 -11
View File
@@ -24,7 +24,7 @@ public class ALC10 {
public static boolean alcCloseDevice(org.lwjglx.openal.ALCdevice device) {
boolean returnValue = org.lwjgl.openal.ALC10.alcCloseDevice(device.device);
boolean returnValue = org.lwjgl.openal.ALC10.alcCloseDevice(getDevice(device));
return returnValue;
}
@@ -46,56 +46,56 @@ public class ALC10 {
}
public static void alcDestroyContext(org.lwjglx.openal.ALCcontext ctx) {
org.lwjgl.openal.ALC10.alcDestroyContext(ctx.context);
org.lwjgl.openal.ALC10.alcDestroyContext(getContext(ctx));
}
public static org.lwjglx.openal.ALCdevice alcGetContextsDevice(org.lwjglx.openal.ALCcontext ctx) {
final long devId = org.lwjgl.openal.ALC10.alcGetContextsDevice(ctx.context);
final long devId = org.lwjgl.openal.ALC10.alcGetContextsDevice(getContext(ctx));
return new ALCdevice(devId);
}
public static int alcMakeContextCurrent(org.lwjglx.openal.ALCcontext ctx) {
return org.lwjgl.openal.ALC10.alcMakeContextCurrent(ctx.context) ? ALC_TRUE : ALC_FALSE;
return org.lwjgl.openal.ALC10.alcMakeContextCurrent(getContext(ctx)) ? ALC_TRUE : ALC_FALSE;
}
public static void alcProcessContext(org.lwjglx.openal.ALCcontext ctx) {
org.lwjgl.openal.ALC10.alcProcessContext(ctx.context);
org.lwjgl.openal.ALC10.alcProcessContext(getContext(ctx));
}
public static void alcSuspendContext(org.lwjglx.openal.ALCcontext ctx) {
org.lwjgl.openal.ALC10.alcSuspendContext(ctx.context);
org.lwjgl.openal.ALC10.alcSuspendContext(getContext(ctx));
}
public static int alcGetEnumValue(org.lwjglx.openal.ALCdevice device, java.lang.String enumName) {
int returnValue = org.lwjgl.openal.ALC10.alcGetEnumValue(device.device, enumName);
int returnValue = org.lwjgl.openal.ALC10.alcGetEnumValue(getDevice(device), enumName);
return returnValue;
}
public static int alcGetError(org.lwjglx.openal.ALCdevice device) {
int returnValue = org.lwjgl.openal.ALC10.alcGetError(device.device);
int returnValue = org.lwjgl.openal.ALC10.alcGetError(getDevice(device));
return returnValue;
}
public static void alcGetInteger(org.lwjglx.openal.ALCdevice device, int pname, java.nio.IntBuffer integerdata) {
org.lwjgl.openal.ALC10.alcGetIntegerv(device.device, pname, integerdata);
org.lwjgl.openal.ALC10.alcGetIntegerv(getDevice(device), pname, integerdata);
}
public static java.lang.String alcGetString(org.lwjglx.openal.ALCdevice device, int pname) {
java.lang.String returnValue = org.lwjgl.openal.ALC10.alcGetString(device.device, pname);
java.lang.String returnValue = org.lwjgl.openal.ALC10.alcGetString(getDevice(device), pname);
return returnValue;
}
public static boolean alcIsExtensionPresent(org.lwjglx.openal.ALCdevice device, java.lang.String extName) {
boolean returnValue = org.lwjgl.openal.ALC10.alcIsExtensionPresent(device.device, extName);
boolean returnValue = org.lwjgl.openal.ALC10.alcIsExtensionPresent(getDevice(device), extName);
return returnValue;
}
@@ -108,4 +108,18 @@ public class ALC10 {
return returnValue;
}
private static long getDevice(org.lwjglx.openal.ALCdevice dev) {
if (dev == null) {
return 0;
}
return dev.device;
}
private static long getContext(org.lwjglx.openal.ALCcontext context) {
if (context == null) {
return 0;
}
return context.context;
}
}
@@ -12,7 +12,7 @@ public class ALC11 {
public static boolean alcCaptureCloseDevice(org.lwjglx.openal.ALCdevice device) {
boolean returnValue = org.lwjgl.openal.ALC11.alcCaptureCloseDevice(device.device);
boolean returnValue = org.lwjgl.openal.ALC11.alcCaptureCloseDevice(getDevice(device));
return returnValue;
}
@@ -28,20 +28,27 @@ public class ALC11 {
public static void alcCaptureSamples(org.lwjglx.openal.ALCdevice device, java.nio.ByteBuffer buffer, int samples) {
org.lwjgl.openal.ALC11.alcCaptureSamples(device.device, buffer, samples);
org.lwjgl.openal.ALC11.alcCaptureSamples(getDevice(device), buffer, samples);
}
public static void alcCaptureStart(org.lwjglx.openal.ALCdevice device) {
org.lwjgl.openal.ALC11.alcCaptureStart(device.device);
org.lwjgl.openal.ALC11.alcCaptureStart(getDevice(device));
}
public static void alcCaptureStop(org.lwjglx.openal.ALCdevice device) {
org.lwjgl.openal.ALC11.alcCaptureStop(device.device);
org.lwjgl.openal.ALC11.alcCaptureStop(getDevice(device));
}
private static long getDevice(org.lwjglx.openal.ALCdevice dev) {
if (dev == null) {
return 0;
}
return dev.device;
}
}