Using Effects and Filters from JOAL? (Method "alGenFilters" not available)

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) ::slight_smile: 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");
        }
    }
}

@Ultraq: well, it was not easy, but now I can build the project.
I don’t really understand where the classes are. Do you mean this package (file): …\build\gensrc\classes\net\java\games\joal\impl\ALProcAddressTable.java ? It is a auto-generated file and I can write what I want, it will be rewriting by building-process. Anyway I have tried to edit this file. After rebuilding of the project I still have “not available Exception”. The code of ALProcAddressTable.java (before rebuilding):


public long getAddressFor(String functionName) {
        String addressFieldName = com.sun.gluegen.runtime.ProcAddressHelper.PROCADDRESS_VAR_PREFIX + functionName;
        try {
            java.lang.reflect.Field addressField = getClass().getField(addressFieldName);
            return addressField.getLong(this);
        } catch (Exception e) {
            // The user is calling a bogus function or one which is not
            // runtime linked
            throw new RuntimeException(
                    "WARNING: Address query failed for \"" + functionName +
                    "\"; it's either statically linked or is not a known " +
                    "function", e);
        }
    }
    
    
    /**
     * 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");
            }
        }
    }
    
    /**
     * my own method
     */
    private static void resetALProcAddressTable() {
        com.sun.gluegen.runtime.ProcAddressHelper.resetProcAddressTable(alTable, lookup);
        useALGetProcAddress();
    } 

Do I anything wrong or ist that a wrong file?

Sorry, I did name the wrong file. :-X

The file to edit is ALProcAddressLookup.java, in src/java/net/java/games/joal/impl It is not an auto-generated file. I’ll attach the file, just to make sure that I give the right instructions this time. The lines I’ve added are at:

  • 69-71: This is just a System.out I to see what OpenAL functions were being done before the modifications. You can remove this if you want.
  • 89-93: Most of this is a comment, and the only line of code is a call to that custom method to get the addresses of the EFX functions.
  • 127-161: The custom method I mentioned.

Ultraq: thanks for investigating this. Very nice work. Just to confirm, using this technique the effects stuff is now working?

I’ve filed a bug about this on the JOAL Issue Tracker and will incorporate your changes as soon as possible.

@Ultraq: Thank you!!! I fixed this and it works fine!!! :slight_smile: All effects and filters are available! :slight_smile:

P.S.: I had also the same problem with msvcr80.dll and I use Netbeans, so I must create java.exe.manifest (and not javaw.exe.manifest)

@Ken: Yes, I’ve even been able to translate one of the EFX examples from the OpenAL 1.1 SDK, into Java, just to make sure. (attached if anybody watching this thread is interested, although it needs the footsteps.wav sample from the SDK). [EDIT]: And it seems it’s working for Tramboturbiener too :slight_smile:

@Tramboturbiener: If you want to avoid having to use a java.exe.manifest, you can incorporate the manifest files, which were generated in the /build/obj directory, into the DLLs themselves by using the following in the VS2005 command prompt:

mt -manifest gluegen-rt.dll -outputresource:gluegen-rt.dll;#2

(do the same for joal_native.dll)

@Ultraq: sorry for the long delay. I hadn’t taken a close look at your patches until now and they’re perfectly correct. I misread them earlier and thought it was necessary to do a manual reset of the ALProcAddressTable from the end user’s code, which would have been gross.

This and some other new functionality will be out soon – tomorrow, if tonight’s nightly builds succeed.

Oh cool, thanks Ken. I was about to post that I hadn’t made any progress on your suggestions in the other thread, but it seems you’ve sorted things out. :slight_smile: