New buffer code

This commit is contained in:
Caspian Rychlik-Prince 2003-08-11 19:58:12 +00:00
parent f625bea9f0
commit eb7e231172
8 changed files with 398 additions and 566 deletions

View file

@ -32,6 +32,7 @@
package org.lwjgl.openal;
import java.nio.Buffer;
import java.nio.IntBuffer;
/**
* $Id$
@ -65,7 +66,7 @@ import java.nio.Buffer;
public class ALC {
/** Has the ALC object been created? */
protected static boolean created;
/** Bad value */
public static final int ALC_INVALID = -1;
@ -78,39 +79,39 @@ public class ALC {
/** Errors: No Error */
public static final int ALC_NO_ERROR = ALC_FALSE;
/** Major version query. */
/** Major version query. */
public static final int ALC_MAJOR_VERSION = 0x1000;
/** Minor version query. */
/** Minor version query. */
public static final int ALC_MINOR_VERSION = 0x1001;
/**
* The size required for the zero-terminated attributes list, for the current context.
**/
/**
* The size required for the zero-terminated attributes list, for the current context.
**/
public static final int ALC_ATTRIBUTES_SIZE = 0x1002;
/**
* Expects a destination of ALC_CURRENT_ATTRIBUTES_SIZE,
* and provides the attribute list for the current context of the specified device.
*/
/**
* Expects a destination of ALC_CURRENT_ATTRIBUTES_SIZE,
* and provides the attribute list for the current context of the specified device.
*/
public static final int ALC_ALL_ATTRIBUTES = 0x1003;
/** The specifier string for the default device */
/** The specifier string for the default device */
public static final int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004;
/** The specifier string for the device */
/** The specifier string for the device */
public static final int ALC_DEVICE_SPECIFIER = 0x1005;
/** The extensions string for diagnostics and printing */
/** The extensions string for diagnostics and printing */
public static final int ALC_EXTENSIONS = 0x1006;
/** Frequency for mixing output buffer, in units of Hz. */
/** Frequency for mixing output buffer, in units of Hz. */
public static final int ALC_FREQUENCY = 0x1007;
/** Refresh intervalls, in units of Hz. */
/** Refresh intervalls, in units of Hz. */
public static final int ALC_REFRESH = 0x1008;
/** Flag, indicating a synchronous context. */
/** Flag, indicating a synchronous context. */
public static final int ALC_SYNC = 0x1009;
/** The device argument does not name a valid device */
@ -143,8 +144,8 @@ public class ALC {
}
/** Creates a new instance of ALC */
protected ALC() {
}
protected ALC() {
}
/**
* Override to provide any initialization code after creation.
@ -164,7 +165,7 @@ public class ALC {
*
* @throws Exception if a failiure occured in the ALC creation process
*/
protected static void create() throws OpenALException {
protected static void create() throws OpenALException {
if (created) {
return;
}
@ -173,7 +174,7 @@ public class ALC {
throw new OpenALException("ALC instance could not be created.");
}
init();
created = true;
created = true;
}
/**
@ -186,7 +187,7 @@ public class ALC {
/**
* Calls whatever destruction rutines that are needed
*/
protected static void destroy() {
protected static void destroy() {
if (!created) {
return;
}
@ -199,61 +200,60 @@ public class ALC {
*/
protected static native void nDestroy();
/**
* The application can obtain certain strings from ALC.
*
* <code>ALC_DEFAULT_DEVICE_SPECIFIER</code> - The specifer string for the default device
* <code>ALC_DEVICE_SPECIFIER</code> - The specifer string for the device
* <code>ALC_EXTENSIONS</code> - The extensions string for diagnostics and printing.
*
* In addition, printable error message strings are provided for all valid error tokens,
* including <code>ALC_NO_ERROR</code>,<code>ALC_INVALID_DEVICE</code>, <code>ALC_INVALID_CONTEXT</code>,
* <code>ALC_INVALID_ENUM</code>, <code>ALC_INVALID_VALUE</code>.
*
* @param pname Property to get
* @return String property from device
*/
/**
* The application can obtain certain strings from ALC.
*
* <code>ALC_DEFAULT_DEVICE_SPECIFIER</code> - The specifer string for the default device
* <code>ALC_DEVICE_SPECIFIER</code> - The specifer string for the device
* <code>ALC_EXTENSIONS</code> - The extensions string for diagnostics and printing.
*
* In addition, printable error message strings are provided for all valid error tokens,
* including <code>ALC_NO_ERROR</code>,<code>ALC_INVALID_DEVICE</code>, <code>ALC_INVALID_CONTEXT</code>,
* <code>ALC_INVALID_ENUM</code>, <code>ALC_INVALID_VALUE</code>.
*
* @param pname Property to get
* @return String property from device
*/
public static String alcGetString(int pname) {
return nGetString(AL.device.device, pname);
return nGetString(AL.device.device, pname);
}
native static String nGetString(int device, int pname);
native static String nGetString(int device, int pname);
/**
* The application can query ALC for information using an integer query function.
* For some tokens, <code>null</code> is a legal deviceHandle. In other cases, specifying a <code>null</code>
* device will generate an <code>ALC_INVALID_DEVICE</code> error. The application has to
* specify the size of the destination buffer provided. A <code>null</code> destination or a zero
* size parameter will cause ALC to ignore the query.
*
* <code>ALC_MAJOR_VERSION</code> - Major version query.
* <code>ALC_MINOR_VERSION</code> - Minor version query.
* <code>ALC_ATTRIBUTES_SIZE</code> - The size required for the zero-terminated attributes list,
* for the current context. <code>null</code> is an invalid device. <code>null</code> (no current context
* for the specified device) is legal.
* <code>ALC_ALL_ATTRIBUTES</code> - Expects a destination of <code>ALC_CURRENT_ATTRIBUTES_SIZE</code>,
* and provides the attribute list for the current context of the specified device.
* <code>null</code> is an invalid device. <code>null</code> (no current context for the specified device)
* will return the default attributes defined by the specified device.
* For some tokens, <code>null</code> is a legal deviceHandle. In other cases, specifying a <code>null</code>
* device will generate an <code>ALC_INVALID_DEVICE</code> error. The application has to
* specify the size of the destination buffer provided. A <code>null</code> destination or a zero
* size parameter will cause ALC to ignore the query.
*
* <code>ALC_MAJOR_VERSION</code> - Major version query.
* <code>ALC_MINOR_VERSION</code> - Minor version query.
* <code>ALC_ATTRIBUTES_SIZE</code> - The size required for the zero-terminated attributes list,
* for the current context. <code>null</code> is an invalid device. <code>null</code> (no current context
* for the specified device) is legal.
* <code>ALC_ALL_ATTRIBUTES</code> - Expects a destination of <code>ALC_CURRENT_ATTRIBUTES_SIZE</code>,
* and provides the attribute list for the current context of the specified device.
* <code>null</code> is an invalid device. <code>null</code> (no current context for the specified device)
* will return the default attributes defined by the specified device.
*
* @param pname Property to get
* @param size Size of destination buffer provided
* @param integerdata ByteBuffer to write integers to
*/
public static void alcGetIntegerv(int pname, int size, Buffer integerdata) {
nGetIntegerv(AL.device.device, pname, size, integerdata);
}
native static void nGetIntegerv(int device, int pname, int size, Buffer integerdata);
public static void alcGetInteger(int pname, IntBuffer integerdata) {
nGetIntegerv(AL.device.device, pname, integerdata.remaining(), integerdata, integerdata.position());
}
native static void nGetIntegerv(int device, int pname, int size, Buffer integerdata, int offset);
/**
* The <code>alcOpenDevice</code> function allows the application (i.e. the client program) to
* connect to a device (i.e. the server).
*
* If the function returns <code>null</code>, then no sound driver/device has been found. The
* argument is a null terminated string that requests a certain device or device
* configuration. If <code>null</code> is specified, the implementation will provide an
* implementation specific default.
* connect to a device (i.e. the server).
*
* If the function returns <code>null</code>, then no sound driver/device has been found. The
* argument is a null terminated string that requests a certain device or device
* configuration. If <code>null</code> is specified, the implementation will provide an
* implementation specific default.
*
* @param devicename name of device to open
* @return opened device, or null
@ -262,10 +262,10 @@ public class ALC {
/**
* The <code>alcCloseDevice</code> function allows the application (i.e. the client program) to
* disconnect from a device (i.e. the server).
*
* If deviceHandle is <code>null</code> or invalid, an <code>ALC_INVALID_DEVICE</code> error will be
* generated. Once closed, a deviceHandle is invalid.
* disconnect from a device (i.e. the server).
*
* If deviceHandle is <code>null</code> or invalid, an <code>ALC_INVALID_DEVICE</code> error will be
* generated. Once closed, a deviceHandle is invalid.
*
* @param device address of native device to close
*/
@ -273,57 +273,57 @@ public class ALC {
/**
* A context is created using <code>alcCreateContext</code>. The device parameter has to be a valid
* device. The attribute list can be <code>null</code>, or a zero terminated list of integer pairs
* composed of valid ALC attribute tokens and requested values.
*
* Context creation will fail if the application requests attributes that, by themselves,
* can not be provided. Context creation will fail if the combination of specified
* attributes can not be provided. Context creation will fail if a specified attribute, or
* the combination of attributes, does not match the default values for unspecified
* attributes.
* device. The attribute list can be <code>null</code>, or a zero terminated list of integer pairs
* composed of valid ALC attribute tokens and requested values.
*
* Context creation will fail if the application requests attributes that, by themselves,
* can not be provided. Context creation will fail if the combination of specified
* attributes can not be provided. Context creation will fail if a specified attribute, or
* the combination of attributes, does not match the default values for unspecified
* attributes.
*
* @param device address of device to associate context to
* @param attrList Buffer to read attributes from
* @return New context, or null if creation failed
*/
native static ALCcontext alcCreateContext(int device, Buffer attrList);
native static ALCcontext alcCreateContext(int device, IntBuffer attrList);
/**
* To make a Context current with respect to AL Operation (state changes by issueing
* commands), <code>alcMakeContextCurrent</code> is used. The context parameter can be <code>null</code>
* or a valid context pointer. The operation will apply to the device that the context
* was created for.
*
* For each OS process (usually this means for each application), only one context can
* be current at any given time. All AL commands apply to the current context.
* Commands that affect objects shared among contexts (e.g. buffers) have side effects
* on other contexts.
* commands), <code>alcMakeContextCurrent</code> is used. The context parameter can be <code>null</code>
* or a valid context pointer. The operation will apply to the device that the context
* was created for.
*
* For each OS process (usually this means for each application), only one context can
* be current at any given time. All AL commands apply to the current context.
* Commands that affect objects shared among contexts (e.g. buffers) have side effects
* on other contexts.
*
* @param context address of context to make current
* @return true if successfull, false if not
*/
native static boolean alcMakeContextCurrent(int context);
/**
* The current context is the only context accessible to state changes by AL commands
* (aside from state changes affecting shared objects). However, multiple contexts can
* be processed at the same time. To indicate that a context should be processed (i.e.
* that internal execution state like offset increments are supposed to be performed),
* the application has to use <code>alcProcessContext</code>.
*
* Repeated calls to <code>alcProcessContext</code> are legal, and do not affect a context that is
* already marked as processing. The default state of a context created by
* alcCreateContext is that it is not marked as processing.
*/
public static void alcProcessContext() {
nProcessContext(AL.context.context);
}
native static void nProcessContext(int context);
/**
* The current context is the only context accessible to state changes by AL commands
* (aside from state changes affecting shared objects). However, multiple contexts can
* be processed at the same time. To indicate that a context should be processed (i.e.
* that internal execution state like offset increments are supposed to be performed),
* the application has to use <code>alcProcessContext</code>.
*
* Repeated calls to <code>alcProcessContext</code> are legal, and do not affect a context that is
* already marked as processing. The default state of a context created by
* alcCreateContext is that it is not marked as processing.
*/
public static void alcProcessContext() {
nProcessContext(AL.context.context);
}
native static void nProcessContext(int context);
/**
* The application can query for, and obtain an handle to, the current context for the
* application. If there is no current context, <code>null</code> is returned.
* application. If there is no current context, <code>null</code> is returned.
*
* @return Current ALCcontext
*/
@ -339,13 +339,13 @@ public class ALC {
/**
* The application can suspend any context from processing (including the current
* one). To indicate that a context should be suspended from processing (i.e. that
* internal execution state like offset increments is not supposed to be changed), the
* application has to use <code>alcSuspendContext</code>.
*
* Repeated calls to <code>alcSuspendContext</code> are legal, and do not affect a context that is
* already marked as suspended. The default state of a context created by
* <code>alcCreateContext</code> is that it is marked as suspended.
* one). To indicate that a context should be suspended from processing (i.e. that
* internal execution state like offset increments is not supposed to be changed), the
* application has to use <code>alcSuspendContext</code>.
*
* Repeated calls to <code>alcSuspendContext</code> are legal, and do not affect a context that is
* already marked as suspended. The default state of a context created by
* <code>alcCreateContext</code> is that it is marked as suspended.
*
* @param context address of context to suspend
*/
@ -353,7 +353,7 @@ public class ALC {
/**
* The correct way to destroy a context is to first release it using <code>alcMakeCurrent</code> and
* <code>null</code>. Applications should not attempt to destroy a current context.
* <code>null</code>. Applications should not attempt to destroy a current context.
*
* @param context address of context to Destroy
*/
@ -361,53 +361,53 @@ public class ALC {
/**
* ALC uses the same conventions and mechanisms as AL for error handling. In
* particular, ALC does not use conventions derived from X11 (GLX) or Windows
* (WGL). The <code>alcGetError</code> function can be used to query ALC errors.
*
* Error conditions are specific to the device.
*
* ALC_NO_ERROR - The device handle or specifier does name an accessible driver/server.
* <code>ALC_INVALID_DEVICE</code> - The Context argument does not name a valid context.
* <code>ALC_INVALID_CONTEXT</code> - The Context argument does not name a valid context.
* <code>ALC_INVALID_ENUM</code> - A token used is not valid, or not applicable.
* <code>ALC_INVALID_VALUE</code> - An value (e.g. attribute) is not valid, or not applicable.
* particular, ALC does not use conventions derived from X11 (GLX) or Windows
* (WGL). The <code>alcGetError</code> function can be used to query ALC errors.
*
* Error conditions are specific to the device.
*
* ALC_NO_ERROR - The device handle or specifier does name an accessible driver/server.
* <code>ALC_INVALID_DEVICE</code> - The Context argument does not name a valid context.
* <code>ALC_INVALID_CONTEXT</code> - The Context argument does not name a valid context.
* <code>ALC_INVALID_ENUM</code> - A token used is not valid, or not applicable.
* <code>ALC_INVALID_VALUE</code> - An value (e.g. attribute) is not valid, or not applicable.
*
* @return Errorcode from ALC statemachine
*/
public static int alcGetError() {
return nGetError(AL.device.device);
}
public static int alcGetError() {
return nGetError(AL.device.device);
}
native static int nGetError(int device);
/**
* Verify that a given extension is available for the current context and the device it
* is associated with.
* A <code>null</code> name argument returns <code>ALC_FALSE</code>, as do invalid and unsupported string
* tokens.
* Verify that a given extension is available for the current context and the device it
* is associated with.
* A <code>null</code> name argument returns <code>ALC_FALSE</code>, as do invalid and unsupported string
* tokens.
*
* @param extName name of extension to find
* @return true if extension is available, false if not
*/
public static boolean alcIsExtensionPresent(String extName) {
return nIsExtensionPresent(AL.device.device, extName);
}
public static boolean alcIsExtensionPresent(String extName) {
return nIsExtensionPresent(AL.device.device, extName);
}
native static boolean nIsExtensionPresent(int device, String extName);
/**
* Enumeration/token values are device independend, but tokens defined for
* extensions might not be present for a given device. But only the tokens defined
* by the AL core are guaranteed. Availability of extension tokens dependends on the ALC extension.
*
* Specifying a <code>null</code> name parameter will cause an <code>ALC_INVALID_VALUE</code> error.
* extensions might not be present for a given device. But only the tokens defined
* by the AL core are guaranteed. Availability of extension tokens dependends on the ALC extension.
*
* Specifying a <code>null</code> name parameter will cause an <code>ALC_INVALID_VALUE</code> error.
*
* @param enumName name of enum to find
* @return value of enumeration
*/
public static int alcGetEnumValue(String enumName) {
return nGetEnumValue(AL.device.device, enumName);
}
public static int alcGetEnumValue(String enumName) {
return nGetEnumValue(AL.device.device, enumName);
}
native static int nGetEnumValue(int device, String enumName);
}

View file

@ -31,7 +31,7 @@
*/
package org.lwjgl.openal;
import java.nio.Buffer;
import java.nio.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -57,16 +57,16 @@ final class ALCcontext {
this.context = context;
}
static Buffer createAttributeList(int contextFrequency, int contextRefresh, int contextSynchronized) {
ByteBuffer attribList = ByteBuffer.allocateDirect(7*4).order(ByteOrder.nativeOrder());
static IntBuffer createAttributeList(int contextFrequency, int contextRefresh, int contextSynchronized) {
IntBuffer attribList = ByteBuffer.allocateDirect(7*4).order(ByteOrder.nativeOrder()).asIntBuffer();
attribList.putInt(ALC.ALC_FREQUENCY);
attribList.putInt(contextFrequency);
attribList.putInt(ALC.ALC_REFRESH);
attribList.putInt(contextRefresh);
attribList.putInt(ALC.ALC_SYNC);
attribList.putInt(contextSynchronized);
attribList.putInt(0); //terminating int
attribList.put(ALC.ALC_FREQUENCY);
attribList.put(contextFrequency);
attribList.put(ALC.ALC_REFRESH);
attribList.put(contextRefresh);
attribList.put(ALC.ALC_SYNC);
attribList.put(contextSynchronized);
attribList.put(0); //terminating int
return attribList;
}

View file

@ -95,7 +95,7 @@ public abstract class BaseAL {
String jwsLibname =
(System.getProperty("os.name").toLowerCase().indexOf("windows") == -1)
? "openal"
: "OpenAL32";
: "lwjglaudio";
String jwsPath = getPathFromJWS(jwsLibname);
if (jwsPath != null) {

View file

@ -34,9 +34,6 @@ package org.lwjgl.openal;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.FloatBuffer;
import java.nio.DoubleBuffer;
/**
* $Id$
* <br>
@ -136,36 +133,7 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
*/
public static native float alGetFloat(int pname);
/**
* Like OpenGL, AL uses a simplified interface for querying global state.
*
* Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
* AL_DISTANCE_MODEL.
* <p>
* <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
* in specifying pName. The amount of memory required in the destination
* depends on the actual state requested.
* </p>
*
* @return double state described by pname will be returned.
*/
public static native double alGetDouble(int pname);
/**
* Like OpenGL, AL uses a simplified interface for querying global state.
*
* Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
* AL_DISTANCE_MODEL.
* <p>
* <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
* in specifying pName. The amount of memory required in the destination
* depends on the actual state requested.
* </p>
*
* @param pname state to be queried
* @param data Buffer to place the booleans in
*/
public static native void alGetBooleanv(int pname, ByteBuffer data);
private static native void nalGetBooleanv(int pname, ByteBuffer data, int offset);
/**
* Like OpenGL, AL uses a simplified interface for querying global state.
@ -181,7 +149,11 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* @param pname state to be queried
* @param data Buffer to place the integers in
*/
public static native void alGetIntegerv(int pname, IntBuffer data);
public static void alGetInteger(int pname, IntBuffer data) {
assert data.remaining() > 0;
nalGetIntegerv(pname, data, data.position());
}
private static native void nalGetIntegerv(int pname, IntBuffer data, int offset);
/**
* Like OpenGL, AL uses a simplified interface for querying global state.
@ -197,23 +169,11 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* @param pname state to be queried
* @param data Buffer to place the floats in
*/
public static native void alGetFloatv(int pname, FloatBuffer data);
/**
* Like OpenGL, AL uses a simplified interface for querying global state.
*
* Legal values are e.g. AL_DOPPLER_FACTOR, AL_DOPPLER_VELOCITY,
* AL_DISTANCE_MODEL.
* <p>
* <code>null</code> destinations are quietly ignored. AL_INVALID_ENUM is the response to errors
* in specifying pName. The amount of memory required in the destination
* depends on the actual state requested.
* </p>
*
* @param pname state to be queried
* @param data Buffer to place the floats in
*/
public static native void alGetDoublev(int pname, DoubleBuffer data);
public static void alGetFloat(int pname, FloatBuffer data) {
assert data.remaining() > 0;
nalGetFloatv(pname, data, data.position());
}
private static native void nalGetFloatv(int pname, FloatBuffer data, int position);
/**
* The application can retrieve state information global to the current AL Context.
@ -367,30 +327,22 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
/**
* Listener attributes are changed using the Listener group of commands.
* Listener state is maintained inside the AL implementation and can be queried in
* full.
*
* @param pname name of the attribute to be set
* @param floatdata Buffer to read floats from
* @param pname name of the attribute to be retrieved
* @return int
*/
public static native void alListenerfv(int pname, FloatBuffer floatdata);
public static native int alGetListeneri(int pname);
/**
* Listener state is maintained inside the AL implementation and can be queried in
* full.
*
* @param pname name of the attribute to be retrieved
* @param integerdata Buffer to write integer to
* @return float
*/
public static native void alGetListeneri(int pname, IntBuffer integerdata);
/**
* Listener state is maintained inside the AL implementation and can be queried in
* full.
*
* @param pname name of the attribute to be retrieved
* @param floatdata Buffer to write float to
*/
public static native void alGetListenerf(int pname, FloatBuffer floatdata);
public static native float alGetListenerf(int pname);
/**
* Listener state is maintained inside the AL implementation and can be queried in
@ -399,23 +351,30 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* @param pname name of the attribute to be retrieved
* @param floatdata Buffer to write floats to
*/
public static native void alGetListenerfv(int pname, FloatBuffer floatdata);
public static void alGetListener(int pname, FloatBuffer floatdata) {
nalGetListenerfv(pname, floatdata, floatdata.position());
}
private static native void nalGetListenerfv(int pname, FloatBuffer floatdata, int offset);
/**
* The application requests a number of Sources using GenSources.
*
* @param n number of sources to generate
* @param sources array holding sources
*/
public static native void alGenSources(int n, IntBuffer sources);
public static void alGenSources(IntBuffer sources) {
nalGenSources(sources.remaining(), sources, sources.position());
}
private static native void nalGenSources(int n, IntBuffer sources, int offset);
/**
* The application requests deletion of a number of Sources by DeleteSources.
*
* @param n Number of sources to delete
* @param source Source array to delete from
*/
public static native void alDeleteSources(int n, IntBuffer source);
public static void alDeleteSources(IntBuffer source) {
nalDeleteSources(source.remaining(), source, source.position());
}
private static native void nalDeleteSources(int n, IntBuffer source, int offset);
/**
* The application can verify whether a source name is valid using the IsSource query.
@ -464,14 +423,15 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
/**
* Specifies the position and other properties as taken into account during
* sound processing.
* Source state is maintained inside the AL implementation, and the current attributes
* can be queried. The performance of such queries is implementation dependent, no
* performance guarantees are made.
*
* @param source source whichs attribute is being set
* @param pname name of the attribute being set
* @param floatdata Buffer to read floats from
* @param source source to get property from
* @param pname name of property
* @return int
*/
public static native void alSourcefv(int source, int pname, FloatBuffer floatdata);
public static native int alGetSourcei(int source, int pname);
/**
* Source state is maintained inside the AL implementation, and the current attributes
@ -480,20 +440,9 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
*
* @param source source to get property from
* @param pname name of property
* @param integerdata Buffer to write integer to
* @return float
*/
public static native void alGetSourcei(int source, int pname, IntBuffer integerdata);
/**
* Source state is maintained inside the AL implementation, and the current attributes
* can be queried. The performance of such queries is implementation dependent, no
* performance guarantees are made.
*
* @param source source to get property from
* @param pname name of property
* @param floatdata Buffer to write float to
*/
public static native void alGetSourcef(int source, int pname, FloatBuffer floatdata);
public static native float alGetSourcef(int source, int pname);
/**
* Source state is maintained inside the AL implementation, and the current attributes
@ -504,7 +453,11 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* @param pname property to get
* @param floatdata Buffer to write floats to
*/
public static native void alGetSourcefv(int source, int pname, FloatBuffer floatdata);
public static void alGetSource(int source, int pname, FloatBuffer floatdata) {
assert floatdata.remaining() > 0;
nalGetSourcefv(source, pname, floatdata, floatdata.position());
}
private static native void nalGetSourcefv(int source, int pname, FloatBuffer floatdata, int position);
/**
* Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus
@ -516,10 +469,12 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* Pause() operation. Play() applied to a AL_STOPPED Source will propagate it to
* AL_INITIAL then to AL_PLAYING immediately.
*
* @param n number of sources to play
* @param sources array of sources to play
*/
public static native void alSourcePlayv(int n, IntBuffer sources);
public static void alSourcePlay(int n, IntBuffer sources) {
nalSourcePlayv(sources.remaining(), sources, sources.position());
}
private static native void nalSourcePlayv(int n, IntBuffer sources, int offset);
/**
* Pause() applied to an AL_INITIAL Source is a legal NOP. Pause() applied to a
@ -527,10 +482,12 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* processing, its current state is preserved. Pause() applied to a AL_PAUSED Source is a
* legal NOP. Pause() applied to a AL_STOPPED Source is a legal NOP.
*
* @param n number of sources to pause
* @param sources array of sources to pause
*/
public static native void alSourcePausev(int n, IntBuffer sources);
public static void alSourcePause(IntBuffer sources) {
nalSourcePausev(sources.remaining(), sources, sources.position());
}
private static native void nalSourcePausev(int n, IntBuffer sources, int offset);
/**
* Stop() applied to an AL_INITIAL Source is a legal NOP. Stop() applied to a AL_PLAYING
@ -539,10 +496,12 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* state to AL_STOPPED, with the same consequences as on a AL_PLAYING Source. Stop()
* applied to a AL_STOPPED Source is a legal NOP.
*
* @param n number of sources to stop
* @param sources array of sources to stop
*/
public static native void alSourceStopv(int n, IntBuffer sources);
public static void alSourceStop(IntBuffer sources) {
nalSourceStopv(sources.remaining(), sources, sources.position());
}
private static native void nalSourceStopv(int n, IntBuffer sources, int offset);
/**
* Rewind() applied to an AL_INITIAL Source is a legal NOP. Rewind() applied to a
@ -556,7 +515,10 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* @param n number of sources to rewind
* @param sources array of sources to rewind
*/
public static native void alSourceRewindv(int n, IntBuffer sources);
public static void alSourceRewind(IntBuffer sources) {
nalSourceRewindv(sources.remaining(), sources, sources.position());
}
private static native void nalSourceRewindv(int n, IntBuffer sources, int offset);
/**
* Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus
@ -609,10 +571,12 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
/**
* The application requests a number of Buffers using GenBuffers.
*
* @param n number of buffers to generate
* @param buffers holding buffers
*/
public static native void alGenBuffers(int n, IntBuffer buffers);
public static void alGenBuffers(IntBuffer buffers) {
nalGenBuffers(buffers.remaining(), buffers, buffers.position());
}
private static native void nalGenBuffers(int n, IntBuffer buffers, int offset);
/**
* <p>
@ -628,10 +592,12 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* a legal NOP in both scalar and vector forms of the command. The same is true for
* unused buffer names, e.g. such as not allocated yet, or as released already.
*
* @param n Number of buffers to delete
* @param buffers Buffer to delete from
*/
public static native void alDeleteBuffers(int n, IntBuffer buffers);
public static void alDeleteBuffers(int n, IntBuffer buffers) {
nalDeleteBuffers(buffers.remaining(), buffers, buffers.position());
}
private static native void nalDeleteBuffers(int n, IntBuffer buffers, int offset);
/**
* The application can verify whether a buffer Name is valid using the IsBuffer query.
@ -666,13 +632,22 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* @param buffer Buffer to fill
* @param format format sound data is in
* @param data location of data
* @param size size of data segment
* @param freq frequency of data
*/
public static native void alBufferData(
public static void alBufferData(
int buffer,
int format,
ByteBuffer data,
ByteBuffer data,
int size,
int freq) {
// TODO: add an assertion here?
nalBufferData(buffer, format, data, data.position(), data.remaining(), freq);
}
private static native void nalBufferData(
int buffer,
int format,
ByteBuffer data,
int offset,
int size,
int freq);
@ -683,9 +658,9 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
*
* @param buffer buffer to get property from
* @param pname name of property to retrieve
* @param integerdata Buffer to write integer to
* @param int
*/
public static native void alGetBufferi(int buffer, int pname, IntBuffer integerdata);
public static native int alGetBufferi(int buffer, int pname);
/**
* Buffer state is maintained inside the AL implementation and can be queried in full.<br>
@ -694,9 +669,9 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
*
* @param buffer buffer to get property from
* @param pname name of property to retrieve
* @param floatdata Buffer to write float to
* @return float
*/
public static native void alGetBufferf(int buffer, int pname, FloatBuffer floatdata);
public static native float alGetBufferf(int buffer, int pname);
/**
* <p>
@ -711,10 +686,12 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* </p>
*
* @param source source to queue buffers onto
* @param n number of buffers to be queued
* @param buffers buffers to be queued
*/
public static native void alSourceQueueBuffers(int source, int n, IntBuffer buffers);
public static void alSourceQueueBuffers(int source, IntBuffer buffers) {
nalSourceQueueBuffers(source, buffers.remaining(), buffers, buffers.position());
}
private static native void nalSourceQueueBuffers(int source, int n, IntBuffer buffers, int offset);
/**
* <p>
@ -733,10 +710,12 @@ public abstract class CoreAL extends BaseAL implements BaseALConstants {
* </p>
*
* @param source source to unqueue buffers from
* @param n number of buffers to be unqueued
* @param buffers buffers to be unqueued
*/
public static native void alSourceUnqueueBuffers(int source, int n, IntBuffer buffers);
public static void alSourceUnqueueBuffers(int source, IntBuffer buffers) {
nalSourceUnqueueBuffers(source, buffers.remaining(), buffers, buffers.position());
}
private static native void nalSourceUnqueueBuffers(int source, int n, IntBuffer buffers, int offset);
/**
* <p>