SingleStaticSource tutorial

[b]Hi, Guys

I’m new to JOAL.
I’m trying to run the SingleStaticSource tutorial.
But I’m getting some weird errors.
Can anyone help me with this,please?[/b]

Exception in thread “main” java.lang.RuntimeException: Can not get proc address for method “alcCaptureCloseDevice”: Couldn’t set value of field “_addressof_alcCaptureCloseDevice” in class net.java.games.joal.impl.ALCProcAddressTable
at com.sun.gluegen.runtime.ProcAddressHelper.resetProcAddressTable(ProcAddressHelper.java:68)
at net.java.games.joal.impl.ALProcAddressLookup.resetALCProcAddressTable(ALProcAddressLookup.java:109)
at net.java.games.joal.impl.ALCImpl.alcOpenDevice(ALCImpl.java:342)
at net.java.games.joal.util.ALut.alutInit(ALut.java:69)
at lesson1.SingleStaticSource.main(SingleStaticSource.java:139)
Caused by: java.lang.RuntimeException: Unable to find and load OpenAL library
at net.java.games.joal.impl.ALProcAddressLookup$DynamicLookup.dynamicLookupFunction(ALProcAddressLookup.java:66)
at com.sun.gluegen.runtime.ProcAddressHelper.resetProcAddressTable(ProcAddressHelper.java:64)
… 4 more

I’m using Linux fedora and Java 1.6.0
And JOAL (joal-1.1.1-linux-i586)
And here is the source code.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;

import net.java.games.joal.AL;
import net.java.games.joal.ALFactory;
import net.java.games.joal.util.ALut;

public class SingleStaticSource {

static AL al = ALFactory.getAL();
static int[] buffer = new int[1];
static int[] source = new int[1];
static float[] sourcePos = { 0.0f, 0.0f, 0.0f };
static float[] sourceVel = { 0.0f, 0.0f, 0.0f };
static float[] listenerPos = { 0.0f, 0.0f, 0.0f };
static float[] listenerVel = { 0.0f, 0.0f, 0.0f };

static int LoadALData() {
	int[] format = new int[1];
	int[] size = new int[1];
	ByteBuffer[] data = new ByteBuffer[1];
	int[] freq = new int[1];
	int[] loop = new int[1];
	
	al.alGenBuffers(1, buffer, 0);
	if(al.alGetError() != AL.AL_NO_ERROR ) return AL.AL_FALSE;
	
	ALut.alutLoadWAVFile("Gun1.wav", format, data, size, freq, loop);
	
	if (data[0] == null) {
		throw new RuntimeException("Error loading WAV file");
	}
	
	System.out.println("sound size = " + size[0]);
	System.out.println("sound freq = " + freq[0]);
	al.alBufferData(buffer[0], format[0], data[0], size[0], freq[0]);
	
	
	al.alGenSources(1, source, 0);

	al.alSourcei(source[0], AL.AL_BUFFER, buffer[0]);
	al.alSourcef(source[0], AL.AL_PITCH, 1.0f);
	al.alSourcef(source[0], AL.AL_GAIN, 1.0f);
	al.alSourcefv(source[0], AL.AL_POSITION, sourcePos, 0);
	al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel, 0);
	al.alSourcei(source[0], AL.AL_LOOPING, loop[0]);

    if(al.alGetError() == AL.AL_NO_ERROR)
        return AL.AL_TRUE;

    return AL.AL_FALSE;
}

static void setListenerValues() {
	al.alListenerfv(AL.AL_POSITION, listenerPos, 0);
	al.alListenerfv(AL.AL_VELOCITY, listenerVel, 0);
	al.alListenerfv(AL.AL_ORIENTATION, listenerOri, 0);
}

static void killAllData() {
	al.alDeleteBuffers(1, buffer, 0);
	al.alDeleteSources(1, source, 0);
	ALut.alutExit();
}


public static void main(String[] args) {

	ALut.alutInit();
	al = ALFactory.getAL();
	al.alGetError();
	if (LoadALData() == AL.AL_FALSE) 
	    System.exit(1);
	setListenerValues();

	char[] c = new char[1];
	while (c[0] != 'q') {
		try {
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Press a key and hit ENTER: \n" + "'p' to play, 's' to stop, " +"'h' to pause and 'q' to quit");
			buf.read(c);
			
			switch (c[0]) {
	        	case 'p' :
	        		// Pressing 'p' will begin playing the sample.
	        		al.alSourcePlay(source[0]);
	        		break;
	        	case 's' :
	        		// Pressing 's' will stop the sample from playing.
	        		al.alSourceStop(source[0]);
	        		break;
	        	case 'h' :
	        		// Pressing 'n' will pause (hold) the sample.
	        		al.alSourcePause(source[0]);
	        		break;
	        	case 'q' :
	        		killAllData();
	        		break;
	       }
			
		} catch (IOException e) {
	    	System.exit(1);
	    }
	}
}

}

The error occurs at the very beginning ‘ALut.alutInit();’.
I have no idea why.
Can anyone tell me?

2 things come to mind:

  • alcCaptureCloseDevice is an OpenAL 1.1 function. Maybe installing an OpenAL 1.1 driver for your soundcard might help?
  • the ‘caused by’ part of the stack trace points to the lines in the JOAL code which indicate that an OpenAL driver couldn’t be found at all. Installing OpenAL and making sure the OpenAL libraries are somewhere on the library path (although the installation should already do that) should help here.