Skip to content

Commit

Permalink
Fix handling of null device/context in ALC bindings (#108)
Browse files Browse the repository at this point in the history
Closes #100
  • Loading branch information
eigenraven authored Jan 11, 2024
1 parent 8e5ce1e commit b4b733c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
36 changes: 25 additions & 11 deletions src/generated/java/org/lwjglx/openal/ALC10.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -46,56 +46,56 @@ public static org.lwjglx.openal.ALCcontext alcGetCurrentContext() {
}

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;
}
Expand All @@ -108,4 +108,18 @@ public static org.lwjglx.openal.ALCdevice alcOpenDevice(java.lang.String arg0) {
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;
}

}
15 changes: 11 additions & 4 deletions src/generated/java/org/lwjglx/openal/ALC11.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -28,20 +28,27 @@ public static org.lwjglx.openal.ALCdevice alcCaptureOpenDevice(java.lang.String

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;
}

}

0 comments on commit b4b733c

Please sign in to comment.