Update of /cvsroot/jake2/jake2/src/jake2/sound/joal
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3369/src/jake2/sound/joal
Modified Files:
JOALSoundImpl.java
Log Message:
unpack libopenal.so on Linux
Index: JOALSoundImpl.java
===================================================================
RCS file: /cvsroot/jake2/jake2/src/jake2/sound/joal/JOALSoundImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** JOALSoundImpl.java 27 Oct 2004 16:51:32 -0000 1.8
--- JOALSoundImpl.java 31 Oct 2004 19:47:52 -0000 1.9
***************
*** 9,23 ****
import jake2.Defines;
import jake2.Globals;
- import jake2.client.CL;
- import jake2.client.CL_ents;
import jake2.game.*;
import jake2.qcommon.*;
import jake2.sound.*;
! import jake2.util.*;
! import java.io.IOException;
! import java.io.RandomAccessFile;
import java.nio.IntBuffer;
- import java.util.*;
import net.java.games.joal.*;
--- 9,20 ----
import jake2.Defines;
import jake2.Globals;
import jake2.game.*;
import jake2.qcommon.*;
import jake2.sound.*;
! import jake2.util.Lib;
! import jake2.util.Vargs;
! import java.io.*;
import java.nio.IntBuffer;
import net.java.games.joal.*;
***************
*** 47,50 ****
--- 44,69 ----
}
+ /**
+ * unpack OpenAL shared library on Linux
+ */
+ private void unpack() {
+ String path = System.getProperty("user.home") + "/.jake2/libopenal.so";
+ File f = new File(path);
+ if (!f.exists()) {
+ try {
+ f.createNewFile();
+ InputStream in = getClass().getResourceAsStream("/libopenal.so");
+ OutputStream out = new FileOutputStream(f);
+ byte[] buf = new byte[8192];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ } catch (Exception e) {
+ f.delete();
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see jake2.sound.SoundImpl#Init()
***************
*** 55,59 ****
String os = System.getProperty("os.name");
if (os.startsWith("Linux")) {
! System.loadLibrary("openal");
} else if (os.startsWith("Windows")) {
System.loadLibrary("OpenAL32");
--- 74,78 ----
String os = System.getProperty("os.name");
if (os.startsWith("Linux")) {
! unpack();
} else if (os.startsWith("Windows")) {
System.loadLibrary("OpenAL32");
|