Multiple Contexts

Hi,

the first question:
is it possible to create and switch multiple contexts for one device? Daniel PEACOCK says: http://www.nabble.com/Multiple-Contexts-On-One-Device-tf4107112.html Is there a wokaround to solve this problem? My code throws a EXCEPTION_ACCESS_VIOLATION when I try this:


        AL al = ALFactory.getAL();
        ALC alc = ALFactory.getALC();
        ALCdevice dev = alc.alcOpenDevice(null);
        ALCcontext con = alc.alcCreateContext(dev, null);
        
        if (alc.alcGetError(dev) == ALC.ALC_TRUE) {
            System.out.println("Error...");
        }

        ALCcontext con1 = alc.alcCreateContext(dev, null);  

        if (alc.alcGetError(dev) == ALC.ALC_TRUE) {
            System.out.println("Error....");
        }
        
        System.out.println("is con current? : " + alc.alcMakeContextCurrent(con) + "\n");   
                
        System.out.println("is con1 current? : " + alc.alcMakeContextCurrent(con1));  
      
        System.out.println("Version: " + al.alGetString(al.AL_VERSION));
        System.out.println("Device: " + al.alGetString(al.AL_RENDERER));
 

the next question:
is it possible to create and switch multiple contexts for different devices (each device has one context)? I have tried this unsuccessfully:


        AL al = ALFactory.getAL();
        ALC alc = ALFactory.getALC();
        ALCdevice dev = alc.alcOpenDevice(null);
        ALCdevice dev1 = alc.alcOpenDevice("Generic Hardware");

        ALCcontext con = alc.alcCreateContext(dev, null);
        
        if (alc.alcGetError(dev) == ALC.ALC_TRUE) {
            System.out.println("Error...");
        }
        ALCcontext con1 = alc.alcCreateContext(dev1, null);  
        if (alc.alcGetError(dev1) == ALC.ALC_TRUE) {
            System.out.println("Error...");
        }
        
        System.out.println("is con current? : " + alc.alcMakeContextCurrent(con));   
        System.out.println("Version: " + al.alGetString(al.AL_VERSION));
        System.out.println("Device - Name: " + al.alGetString(al.AL_RENDERER) + "\n"); 
        
        System.out.println("is con1 current? : " + alc.alcMakeContextCurrent(con1));        
        System.out.println("Version: " + al.alGetString(al.AL_VERSION));
        System.out.println("Name: " + al.alGetString(al.AL_RENDERER));       

I’m pretty sure there are some bugs in JOAL if there are multiple OpenAL devices in use simultaneously; I think we don’t maintain the pointers to OpenAL functions properly. However I believe multiple contexts should work if your OpenAL implementation is correct. If you have a small and self-contained test case please file a bug. You’ll need to be an Observer of the project to do so.

I hope my implementation is correct (see the peace of code above to my second question), but it does not work. It’s a pity… :frowning: I make a bug report with this code.