Well, good news: the change from AL.alGetProcAddress() to return a long via the C++ jlong type instead of trying to get the address from the direct buffer, fixed it up! I guess the (*env)->NewDirectByteBuffer() kept returning the address of the buffer, not the address of the function itself? I dunno, JNI isn’t exactly my specialty.
@Tramboturbiener - if you want to fix this up on your own, you could probably do something similar to what I’ve been instructed to do. It’s probably not the most elegant solution, but I dunno if Ken can get it fixed right this instant (something to do with JavaOne) : In short:
- you need to be able to build the project from the source. There are instructions for that in the Readme.txt that comes with the source archives.
- comment the lines that say something like Ignore al©GetProcAddress from the joal(-alc).cfg files
- uncomment the line Opaque long ALproc from the joal.cfg file
- add a method like that in the code snippet below to the net.java.games.joal.impl.ALProcAddressTable class
- add a call to that method within the resetALProcAddressTable() method, after the line which has ProcAddressHelper.resetProcAddressTable(alTable, lookup);, of the ALProcAddressTable.
- rebuild
I did some other non-code stuff, but that was more to do with getting the thing to work properly using the VC8 compiler more than anything else.
/**
* Retrieves the values of the OpenAL functions using alGetProcAddress().
*/
private static void useALGetProcAddress() {
String addrOfPrefix = "_addressof_";
AL al = ALFactory.getAL();
System.out.println("\nLooking-up EFX function pointers");
for (Field field: ALProcAddressTable.class.getFields()) {
// Skip non-address fields
String fieldname = field.getName();
if (!fieldname.startsWith(addrOfPrefix)) {
continue;
}
try {
String functionname = fieldname.substring(addrOfPrefix.length());
long fieldval = field.getLong(alTable);
// Skip fields which have already been valued
if (fieldval != 0) {
continue;
}
// Get the address
long procAddressVal = al.alGetProcAddress(functionname);
System.out.println("Address of " + functionname + ": 0x" + Long.toHexString(procAddressVal));
field.setLong(alTable, procAddressVal);
}
catch (Exception ex) {
throw new RuntimeException("Unable to repopulate ALProcAddressTable values");
}
}
}