Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  SingleStaticSource tutorial  (Read 2069 times)
0 Members and 1 Guest are viewing this topic.
Offline romiodelta

JGO Visitor




« Posted 2007-10-24 04:09:00 »

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?


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?


Offline Ultraq

Junior Member




That's what she said


« Reply #1 - Posted 2007-10-24 22:45:39 »

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.

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (144 views)
2013-05-17 21:29:12

alaslipknot (152 views)
2013-05-16 21:24:48

gouessej (183 views)
2013-05-16 00:53:38

gouessej (177 views)
2013-05-16 00:17:58

theagentd (187 views)
2013-05-15 15:01:13

theagentd (172 views)
2013-05-15 15:00:54

StreetDoggy (215 views)
2013-05-14 15:56:26

kutucuk (240 views)
2013-05-12 17:10:36

kutucuk (238 views)
2013-05-12 15:36:09

UnluckyDevil (244 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.125 seconds with 20 queries.