From 91b33eb6494e359c47df794419a2f72e6f0fd191 Mon Sep 17 00:00:00 2001 From: Brian Matzon Date: Sun, 27 Apr 2003 21:26:02 +0000 Subject: [PATCH] add: default constructor for OpenAL --- src/java/org/lwjgl/openal/AL.java | 25 +++++++++++++++---- src/java/org/lwjgl/test/openal/BasicTest.java | 2 +- .../lwjgl/test/openal/OpenALCreationTest.java | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/java/org/lwjgl/openal/AL.java b/src/java/org/lwjgl/openal/AL.java index cefc29f9..a0015072 100644 --- a/src/java/org/lwjgl/openal/AL.java +++ b/src/java/org/lwjgl/openal/AL.java @@ -59,16 +59,25 @@ public class AL extends CoreAL { protected String deviceArguments; /** Frequency for mixing output buffer, in units of Hz. */ - protected int contextFrequency; + protected int contextFrequency = -1; /** Refresh intervalls, in units of Hz. */ - protected int contextRefresh; + protected int contextRefresh = -1; /** Flag, indicating a synchronous context. */ - protected int contextSynchronized; + protected int contextSynchronized = ALC.FALSE; + + /** + * Creates an OpenAL instance. The empty constructor will cause OpenAL to + * open the default device, and create a context using default values. + */ + public AL() { + } /** - * Creates an OpenAL instance + * Creates an OpenAL instance. Using this constructor will cause OpenAL to + * open the device using supplied device argument, and create a context using the context values + * supplied. * * @param deviceArguments Arguments supplied to native device * @param contextFrequency Frequency for mixing output buffer, in units of Hz (Common values include 11025, 22050, and 44100). @@ -93,10 +102,16 @@ public class AL extends CoreAL { alc.create(); device = alc.openDevice(deviceArguments); - + + //check if doing default values or not + if (contextFrequency == -1) { + context = alc.createContext(device.device, 0); + } else { context = alc.createContext(device.device, Sys.getDirectBufferAddress( ALCcontext.createAttributeList(contextFrequency, contextRefresh, contextSynchronized))); + } + alc.makeContextCurrent(context.context); } diff --git a/src/java/org/lwjgl/test/openal/BasicTest.java b/src/java/org/lwjgl/test/openal/BasicTest.java index 97be85ba..89eef901 100644 --- a/src/java/org/lwjgl/test/openal/BasicTest.java +++ b/src/java/org/lwjgl/test/openal/BasicTest.java @@ -58,7 +58,7 @@ public abstract class BasicTest { * Creates an instance of PlayTest */ public BasicTest() { - al = new AL(null, 44100, 15, false); + al = new AL(); try { al.create(); } catch (Exception e) { diff --git a/src/java/org/lwjgl/test/openal/OpenALCreationTest.java b/src/java/org/lwjgl/test/openal/OpenALCreationTest.java index 41ad1e1a..671f91be 100644 --- a/src/java/org/lwjgl/test/openal/OpenALCreationTest.java +++ b/src/java/org/lwjgl/test/openal/OpenALCreationTest.java @@ -61,7 +61,7 @@ public class OpenALCreationTest { * Creates an instance of OpenALCreationTest */ public OpenALCreationTest() { - al = new AL(null, 44100, 15, false); + al = new AL(); } public void alInitialize() {