From: Brian M. <ma...@us...> - 2002-09-03 18:54:44
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal In directory usw-pr-cvs1:/tmp/cvs-serv5649/org/lwjgl/openal Modified Files: ALC.java ALUT.java BaseAL.java Log Message: mod: updated to create/destroy architecture Index: ALC.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/ALC.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/ALC.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ALC.java 26 Aug 2002 15:30:19 -0000 1.3 +++ ALC.java 3 Sep 2002 18:54:40 -0000 1.4 @@ -41,6 +41,8 @@ * @version $Revision$ */ public class ALC { + /** Has the ALC object been created? */ + protected static boolean created; /** Bad value */ public static final int INVALID = -1; @@ -92,18 +94,66 @@ */ public static final int OUT_OF_MEMORY = 0xA005; - static { - try { - System.loadLibrary(org.lwjgl.Sys.getLibraryName()); - } catch (UnsatisfiedLinkError ule) { - System.out.println("Failed to load OpenAL library: " + org.lwjgl.Sys.getLibraryName()); - ule.printStackTrace(); - } - } + static { + initialize(); + } /** Creates a new instance of ALC */ public ALC() { } + + /** + * Override to provide any initialization code after creation. + */ + protected void init() { + } + + /** + * Static initialization + */ + private static void initialize() { + System.loadLibrary(org.lwjgl.Sys.getLibraryName()); + } + + /** + * Creates the ALC instance + * + * @throws Exception if a failiure occured in the ALC creation process + */ + public void create() throws Exception { + if (created) { + return; + } + + if (!nCreate()) { + throw new Exception("ALC instance could not be created."); + } + created = true; + init(); + } + + /** + * Native method to create ALC instance + * + * @return true if the ALC creation process succeeded + */ + protected native boolean nCreate(); + + /** + * Calls whatever destruction rutines that are needed + */ + public void destroy() { + if (!created) { + return; + } + created = false; + nDestroy(); + } + + /** + * Native method the destroy the ALC + */ + protected native void nDestroy(); /** * Returns strings related to the context. Index: ALUT.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/ALUT.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/ALUT.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ALUT.java 29 Aug 2002 01:11:03 -0000 1.6 +++ ALUT.java 3 Sep 2002 18:54:40 -0000 1.7 @@ -42,18 +42,69 @@ */ public class ALUT { - static { - try { - System.loadLibrary(org.lwjgl.Sys.getLibraryName()); - } catch (UnsatisfiedLinkError ule) { - System.out.println("Failed to load OpenAL library: " + org.lwjgl.Sys.getLibraryName()); - ule.printStackTrace(); - } - } + /** Has the ALUT object been created? */ + protected static boolean created; + + static { + initialize(); + } /** Creates a new instance of ALUT */ public ALUT() { } + + /** + * Override to provide any initialization code after creation. + */ + protected void init() { + } + + /** + * Static initialization + */ + private static void initialize() { + System.loadLibrary(org.lwjgl.Sys.getLibraryName()); + } + + /** + * Creates the ALUT instance + * + * @throws Exception if a failiure occured in the ALUT creation process + */ + public void create() throws Exception { + if (created) { + return; + } + + if (!nCreate()) { + throw new Exception("ALUT instance could not be created."); + } + created = true; + init(); + } + + /** + * Native method to create ALUT instance + * + * @return true if the ALUT creation process succeeded + */ + protected native boolean nCreate(); + + /** + * Calls whatever destruction rutines that are needed + */ + public void destroy() { + if (!created) { + return; + } + created = false; + nDestroy(); + } + + /** + * Native method the destroy the ALUT + */ + protected native void nDestroy(); /** * Initializes the OpenAL engine Index: BaseAL.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/BaseAL.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/BaseAL.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- BaseAL.java 19 Aug 2002 14:02:55 -0000 1.3 +++ BaseAL.java 3 Sep 2002 18:54:40 -0000 1.4 @@ -44,12 +44,63 @@ * @version $Revision$ */ public abstract class BaseAL { - static { - try { - System.loadLibrary(org.lwjgl.Sys.getLibraryName()); - } catch (UnsatisfiedLinkError ule) { - System.out.println("Failed to load OpenAL library: " + org.lwjgl.Sys.getLibraryName()); - ule.printStackTrace(); + /** Has the ALC object been created? */ + protected static boolean created; + + static { + initialize(); + } + + /** + * Override to provide any initialization code after creation. + */ + protected void init() { + } + + /** + * Static initialization + */ + private static void initialize() { + System.loadLibrary(org.lwjgl.Sys.getLibraryName()); + } + + /** + * Creates the AL instance + * + * @throws Exception if a failiure occured in the AL creation process + */ + public void create() throws Exception { + if (created) { + return; } - } + + if (!nCreate()) { + throw new Exception("AL instance could not be created."); + } + created = true; + init(); + } + + /** + * Native method to create AL instance + * + * @return true if the AL creation process succeeded + */ + protected native boolean nCreate(); + + /** + * Calls whatever destruction rutines that are needed + */ + public void destroy() { + if (!created) { + return; + } + created = false; + nDestroy(); + } + + /** + * Native method the destroy the AL + */ + protected native void nDestroy(); } |