diff options
-rw-r--r-- | build.xml | 7 | ||||
-rw-r--r-- | src/java/build.xml | 4 | ||||
-rw-r--r-- | src/java/net/java/games/joal/ALC.java | 2 | ||||
-rw-r--r-- | src/java/net/java/games/joal/ALCImpl.java | 11 | ||||
-rw-r--r-- | src/java/net/java/games/joal/ALFactory.java | 4 | ||||
-rw-r--r-- | src/native/alcbind.c | 5 | ||||
-rw-r--r-- | src/native/alcbind.h | 4 | ||||
-rw-r--r-- | src/native/build.xml | 48 |
8 files changed, 63 insertions, 22 deletions
@@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="iso-8859-1"?> <!-- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. @@ -45,8 +45,11 @@ <mkdir dir="lib"/> </target> - <target name="compile" depends="init"> + <target name="native-compile" depends="init"> <ant dir="src/native" target="compile"/> + </target> + + <target name="compile" depends="native-compile"> <ant dir="src/java" target="compile"/> <ant dir="unit_tests" target="compile"/> </target> diff --git a/src/java/build.xml b/src/java/build.xml index 7a1a68c..9e6eca7 100644 --- a/src/java/build.xml +++ b/src/java/build.xml @@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="iso-8859-1"?> <!-- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. @@ -73,7 +73,7 @@ <target name="clean"> <delete dir="../../apidocs"/> <delete dir="../../classes/net"/> - <delete file="../../bin/joal.jar"/> + <delete file="../../lib/joal.jar"/> </target> </project>
\ No newline at end of file diff --git a/src/java/net/java/games/joal/ALC.java b/src/java/net/java/games/joal/ALC.java index 2da7f2d..36dfee1 100644 --- a/src/java/net/java/games/joal/ALC.java +++ b/src/java/net/java/games/joal/ALC.java @@ -130,7 +130,7 @@ public interface ALC extends ALCConstants { * <pre>ALCEnum alcGetError(ALvoid);</pre> * @return the current context error state */ - public int alcGetError(); + public int alcGetError(Device device); /** * This method retrieves the current context. <br> diff --git a/src/java/net/java/games/joal/ALCImpl.java b/src/java/net/java/games/joal/ALCImpl.java index fab3a56..3edfd7e 100644 --- a/src/java/net/java/games/joal/ALCImpl.java +++ b/src/java/net/java/games/joal/ALCImpl.java @@ -124,7 +124,16 @@ final class ALCImpl implements ALC { private native void destroyContextNative(int pointer); - public native int alcGetError(); + public int alcGetError(Device device) { + int result = 0; + int pointer = 0; + if(device != null) { + pointer = device.pointer; + } + result = alcGetErrorNative(pointer); + return result; + } + private native int alcGetErrorNative(int pointer); public Context alcGetCurrentContext() { Context result = null; diff --git a/src/java/net/java/games/joal/ALFactory.java b/src/java/net/java/games/joal/ALFactory.java index 04276ad..8d364e4 100644 --- a/src/java/net/java/games/joal/ALFactory.java +++ b/src/java/net/java/games/joal/ALFactory.java @@ -59,8 +59,10 @@ public class ALFactory { String osProperty = System.getProperty("os.name"); if(osProperty.startsWith("Win")) { isInitialized = init(new String[] { "OpenAL32.dll" }); + } else if(osProperty.startsWith("Linux")) { + isInitialized = init(new String[] { "libopenal.so" }); } else { - // Linux & OSX + // OSX } return isInitialized; } diff --git a/src/native/alcbind.c b/src/native/alcbind.c index e9a64a8..5933810 100644 --- a/src/native/alcbind.c +++ b/src/native/alcbind.c @@ -35,6 +35,11 @@ #include "alcbind.h" #include "extal.h" +JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_alcGetErrorNative + (JNIEnv *env, jobject obj, jint pointer) { + return alcGetError((ALCdevice*)pointer); +} + JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_openDeviceNative (JNIEnv *env, jobject obj, jstring deviceName) { diff --git a/src/native/alcbind.h b/src/native/alcbind.h index 27ceffe..f4a6212 100644 --- a/src/native/alcbind.h +++ b/src/native/alcbind.h @@ -99,8 +99,8 @@ JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_destroyContextNative * Method: alcGetError * Signature: ()I */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_alcGetError - (JNIEnv *, jobject); +JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_alcGetErrorNative + (JNIEnv *, jobject, jint pointer); /* * Class: net_java_games_joal_ALCImpl diff --git a/src/native/build.xml b/src/native/build.xml index 531da19..7f28128 100644 --- a/src/native/build.xml +++ b/src/native/build.xml @@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="iso-8859-1"?> <!-- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. @@ -39,22 +39,43 @@ <target name="init"> <property name="cc" value ="gcc"/> <property name="no_cygwin" value="-mno-cygwin"/> - <property name="include" value="-I${jdk.home}/include -I${jdk.home}/include/win32 -I'${openal.home}'/include" /> - <property name="compilerflags" value ="-O3 -Wl,--add-stdcall-alias -shared"/> - <property name="output" value="../../lib/joal.dll"/> <property name="sources" value="extal.c eaxfactory.c eaxbind.c alfactory.c alcbind.c albind.c"/> <property name="specs" value="-specs='./specs.new'"/> + <condition property="isUnix"> + <os family="unix" /> + </condition> + <condition property="isWindows"> + <os family="windows" /> + </condition> </target> - <target name="compile" depends="init"> - <exec executable="${cc}" os="Windows 2000, Windows XP"> - <arg line=" ${no_cygwin}"/> - <arg line=" ${include}"/> - <arg line=" ${compilerflags}"/> - <arg line=" -o ${output}"/> - <arg line=" ${sources}"/> - </exec> + <target name="compile-dll" depends="init" if="isWindows"> + <echo message="Compiling DLL for Windows." /> + <antcall target="compile-native-lib"> + <param name="include" value="-I${jdk.home}/include -I${jdk.home}/include/win32 -I'${openal.home}'/include" /> + <param name="compilerflags" value ="${no_cygwin} -O3 -Wl,--add-stdcall-alias -shared"/> + <param name="output" value="../../lib/joal.dll"/> + </antcall> </target> + + <target name="compile-so" depends="init" if="isUnix"> + <echo message="Compiling shared library for Unix." /> + <antcall target="compile-native-lib"> + <param name="include" value="-I${jdk.home}/include -I${jdk.home}/include/linux -I'${openal.home}'/include -I'${openal.home}'/include/AL" /> + <param name="compilerflags" value ="-O3 -D_X11 -shared -Wl,-soname -Wl,libjoal.so -Wl,-export-dynamic "/> + <param name="output" value="../../lib/libjoal.so"/> + </antcall> + </target> + + <target name="compile-native-lib"> + <echo message="${cc} ${include} ${compilerflags} -o ${output} ${sources}" /> + <exec executable="${cc}"> + <arg line=" ${include} ${compilerflags} -o ${output} ${sources}"/> + </exec> + </target> + + <target name="compile" depends="compile-so, compile-dll"> + </target> <target name="javadoc" depends="init"> <ant dir="src/java" target="javadoc"/> @@ -66,6 +87,7 @@ </target> <target name="clean" description="Clean all build products."> - <delete file="../../bin/joal.dll" /> + <delete file="../../lib/joal.dll" /> + <delete file="../../lib/libjoal.so" /> </target> </project> |