diff options
author | kbr <[email protected]> | 2006-01-10 11:07:30 +0000 |
---|---|---|
committer | kbr <[email protected]> | 2006-01-10 11:07:30 +0000 |
commit | 1a0b7c61155813ac0bf3c6d58b4dac15f0225101 (patch) | |
tree | e3b573ca2193ae8a6aacd5bc5cb3060321308ba7 | |
parent | 0badf374064da5c608dcb06ef2d2e9966792ddc8 (diff) |
Merged gluegen-branch-1-0 on to the main JOAL trunk. JOAL is now built
using GlueGen and currently requires a built JOGL workspace as a
sibling workspace of the JOAL workspace.
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@101 03bf7f67-59de-4072-a415-9a990d468a3f
62 files changed, 3265 insertions, 7131 deletions
@@ -42,6 +42,8 @@ Author: Sun Microsystems -- This file updated 08/19/2003 by Ole Arndt <ole at sugarshark dot com> -- This file updated 11/23/2003 by Gregory Pierce <[email protected]> + -- This file updated 12/21/2005 by Kenneth Russell <[email protected]> + Introduction: ============= @@ -80,17 +82,20 @@ packages and tools have been used: -- OSX Developer Tools -- OpenAL1.0 SDK from Creative Labs (avaulable at http://developer.creative.com under "Gaming->Development Kits->Open AL") +The sources currently require a built JOGL source tree as a sibling +directory of your JOAL tree; this is to pick up the GlueGen tool, +which currently lives in the JOGL workspace. We plan to move this tool +into its own workspace and thereby break this dependence. Directory Organization: ======================= -The root contains a master ANT build.xml and the following sub directories: - - -- apidocs Where the javadocs get built to - -- lib Where the Jar and DLL files get built to - -- src The actual source for the JGI APIs. - -- www JGI project webpage files - + -- make Build-related files and the main build.xml + -- src The actual source for the JOAL APIs. + -- build (generated directory) Where the Jar and DLL files get built to + -- javadoc_public (generated directory) Where the public Javadoc gets built to + -- unit_tests A couple of small tests + -- www JOAL project webpage files Preparations: ============= @@ -116,16 +121,21 @@ Preparations: * OSX: Grab the OpenAL SDK from Creative Labs and install it. + JOAL Build Instructions: =================== -Edit the value of the jdk.home property in the root build.xml file to point -to your Java 2 SDK installation (ex: c:/j2sdk1.4.2 ,/opt/j2sdk1.4.2, or /Library/Java/Home) +Copy the joal.properties file from the make/ subdirectory into your +home directory, or in particular where the Java system property +user.home points to (on Windows, this is C:\Documents and Settings\username\) -Edit the value of the openal.home property in the root build.xml file to point -to your OpenAL SDK installation. +Download the current ANTLR jar file (http://www.antlr.org/). Edit the +value of the antlr.jar property in this file to point to the full path +of this jar. ANTLR is used during the glue code generation process. -For Windows this might be "c:/program files/creative labs/openal 1.0 sdk". +Edit the joal.lib.dir property to point to the lib directory of your +current OpenAL installation. For Windows this might be "C:/Program +Files/OpenAL 1.1 SDK/libs/Win32". Under Linux set the property to the toplevel directory of your OpenAL CVS version. If OpenAl came with your distribution and the header files are in /usr/include/AL, @@ -133,48 +143,18 @@ set the property to '/usr'. Under OSX the default distribution will install to "/Library/Frameworks/OpenAL.framework ". +On Windows, you may want to edit the win32.c.compiler property to +indicate the C compiler you prefer to use (vc6, vc7 or mingw). + +On OS X, you can produce 'fat' dual PowerPC/x86 binaries on an +appropriately-equipped machine by uncommenting the declaration of the +'macosxfat' property. + To clean: ant clean To build: ant all (or just ant) To build docs: ant javadoc To test: ant runtests - Release Info: Initial Release: This release contains an implementation of the Java bindings for OpenAL, as well as the Sound3D Object-Oriented toolkit for games. - -Additional Information - This release includes source code adapted from the Lightweight Java Games Library - subject to the following terms and conditions: - - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - diff --git a/build.xml b/build.xml deleted file mode 100644 index f472c49..0000000 --- a/build.xml +++ /dev/null @@ -1,157 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> - -<!-- -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. ---> - - -<project name="Games @ Java.Net Open Source Client Technologies" basedir="." default="all"> - - <!-- if JAVA_HOME does not point to your JDK installation then --> - <!-- edit the jdk.home property accordingly --> - - <target name="set-jdk.home"> - <property environment="env"/> - <property name="jdk.home" value="${env.JAVA_HOME}"/> <!-- Edit if necessary --> - - <echo message="checking for JDK Installation"></echo> - <available file="${jdk.home}/include" type="dir" property="isValidJavaHome"/> - <fail message="jdk.home in build.xml does not point to valid JDK install. Please see README.txt for instructions" unless="isValidJavaHome"/> - </target> - - <!-- If OpenAL is typically installed in the default location specified below --> - <!-- If this is not the case in your environment, please edit the openal.home --> - <!-- property accordingly --> - - <!-- On Windows --> - <target name="set-openal.home-win32" if="isWindows"> - <!-- Edit the following property if necessary --> - <property name="openal.home" value="/Program Files/Creative Labs/OpenAL 1.0 SDK"/> - - <echo message="checking for OpenAL Installation"></echo> - <available file="${openal.home}" type="dir" property="isValidOpenALHome"/> - <fail message="openal.home in build.xml does not point to valid OpenAL install. Please see README.txt for instructions" unless="isValidOpenALHome"/> - </target> - - <!-- On OSX --> - <target name="set-openal.home-osx" if="isOSX"> - <!-- Warning! The current version of JOAL requires that OpenAL --> - <!-- installed in this location! --> - <property name="openal.home" value="/Library/Frameworks/OpenAL.framework"/> - - <echo message="checking for OpenAL Installation"></echo> - <available file="${openal.home}" type="dir" property="isValidOpenALHome"/> - <fail message="openal.home in build.xml does not point to valid OpenAL install. Please see README.txt for instructions" unless="isValidOpenALHome"/> - </target> - - <!-- On Unix --> - <target name="set-openal.home-unix" if="isUnix"> - <!-- Edit the following property if necessary --> - <property name="openal.home" value="/usr"/> - - <echo message="checking for OpenAL Installation"></echo> - <available file="${openal.home}/include/AL" type="dir" property="isValidOpenALHome"/> - <fail message="openal.home in build.xml does not point to valid OpenAL install. Please see README.txt for instructions" unless="isValidOpenALHome"/> - </target> - - <!-- Set your compiler options here --> - - <target name="set-compiler-options"> - <property name="optimize" value="on"/> - <property name="debug" value="on"/> - </target> - - <!-- You shouldn't need to set anything below this line. Edit at your own risk! --> - <!-- ========================================================================== --> - - <target name="check-platform"> - <condition property="isOSX"> - <and> - <os family="mac"/> - <os family="unix"/> - </and> - </condition> - <condition property="isUnix"> - <and> - <os family="unix" /> - <not> - <os family="mac" /> - </not> - </and> - </condition> - <condition property="isWindows"> - <os family="windows" /> - </condition> - </target> - - <target name="init" depends="set-jdk.home, check-platform, set-openal.home-unix, set-openal.home-win32, set-openal.home-osx, set-compiler-options"> - <mkdir dir="classes"/> - <mkdir dir="apidocs"/> - <mkdir dir="lib"/> - </target> - - - <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> - - <target name="jar" depends="compile"> - <ant dir="src/java" target="jar"/> - </target> - - <target name="javadoc" depends="init"> - <ant dir="src/java" target="javadoc"/> - </target> - - <target name="all" depends="jar,javadoc" description="Build everything."> - <echo message="Application built."/> - </target> - - <target name="clean" description="Clean all build products."> - <delete dir="classes"/> - <delete dir="apidocs"/> - <delete dir="bin"/> - <ant dir="src/native" target="clean"/> - <ant dir="src/java" target="clean"/> - <ant dir="unit_tests" target="clean"/> - </target> - <target name="runtests" depends="jar"> - <ant dir="unit_tests" target="runOpenALTest"/> - <ant dir="unit_tests" target="runSound3DTest"/> - </target> - -</project> diff --git a/make/build.xml b/make/build.xml new file mode 100755 index 0000000..e04f629 --- /dev/null +++ b/make/build.xml @@ -0,0 +1,755 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + - Ant build for JOAL. This build has been tested with ANT 1.6.2. The + - optional.jar that contains the optional ANT tasks must be in the ANT + - classpath (typically the ant/lib directory). + - + - A clean download of JOAL is required for this build. + - + - This build has no dependence on environment variables; the needed + - ones (e.g. java.home, ANT_HOME) are all set by the Ant wrapper shell + - script, by the virtual machine, or elsewhere. However, on all platforms, + - the C compiler and linker should be in the path. All other paths that + - need to be set are in host.properties. + - + - NOTE: because the GlueGen config files have their own relative paths + - which cannot be overridden by GlueGen, GlueGen MUST be run from + - the "make" directory. This also means that this build.xml MUST + - be run from the "make" directory. + - + - All targets do the following: + - Build the ancillary Ant tasks. + - Generate the Java and C files. + - Compile all sources. + - Create the joal.jar and platform library. + - Public targets: + - linux + - macosx + - solaris + - win32.vc6 + - win32.vc7 + - win32.mingw: build everything (jar, DSOs) for the current platform + - clean: clean all built + - javadoc: create the standard developer Javadoc + - + - Optional properties: + - -Djoal.cg=1 when combined with the build or javadoc targets will cause + - the experimental binding to NVidia's Cg language to be built. + - + - Thanks to Rob Grzywinski and Artur Biesiadowski for the bulk of the + - ANT build, including the GlueGen and StaticGLInfo tasks, the building of + - the Java generated sources, the first and second phase Java compiles, and + - the building of the jar file. + --> +<project name="JOAL" basedir="." default="all"> + + <!-- ================================================================== --> + <!-- + - Base initialization and detection of operating system. + --> + <target name="base.init"> + <!-- Set the project root directory to be up one directory. --> + <property name="project.root" value=".." /> + + <!-- Set the configuration and build files to this directory. --> + <property name="make" value="." /> + + <!-- Detection of operating system. --> + <condition property="isOSX"> + <and> + <os family="mac"/> + <os family="unix"/> + </and> + </condition> + <condition property="isUnix"> + <and> + <os family="unix" /> + <not> + <os family="mac" /> + </not> + </and> + </condition> + <condition property="isLinux"> + <os name="Linux" /> + </condition> + <condition property="isSolaris"> + <os name="SunOS" /> + </condition> + <condition property="isWindows"> + <os family="windows" /> + </condition> + <condition property="isFreeBSD"> + <os name="FreeBSD" /> + </condition> + <condition property="isLinuxAMD64"> + <and> + <istrue value="${isLinux}" /> + <os arch="AMD64" /> + </and> + </condition> + <condition property="isIA64"> + <os arch="IA64" /> + </condition> + <echo message="OS X=${isOSX}" /> + <echo message="Windows=${isWindows}" /> + <echo message="Unix=${isUnix}" /> + <echo message="Linux=${isLinux}" /> + <echo message="Solaris=${isSolaris}" /> + <echo message="FreeBSD=${isFreeBSD}" /> + <echo message="LinuxAMD64=${isLinuxAMD64}" /> + <echo message="IA64=${isIA64}" /> + </target> + + <!-- ================================================================== --> + <!-- + - Load user properties which override build defaults. + --> + <target name="load.user.properties" depends="base.init"> + <!-- Load the user specified properties file that defines various host + - specific paths. The user will be notified if this is does not + - exist. --> + <property name="user.properties.file" value="${user.home}/joal.properties" /> + <property file="${user.properties.file}" /> + <echo message="Loaded ${user.properties.file}." /> + <echo message="antlr.jar=${antlr.jar}" /> + <fail message="antlr.jar was not specified in joal.properties. Please see README.txt for instructions" unless="antlr.jar"/> + <fail message="joal.lib.dir was not specified in joal.properties. Please see README.txt for instructions" unless="joal.lib.dir"/> + <condition property="isVC6"> + <and> + <istrue value="${isWindows}" /> + <equals arg1="${win32.c.compiler}" arg2="vc6" /> + </and> + </condition> + <condition property="isVC7"> + <and> + <istrue value="${isWindows}" /> + <equals arg1="${win32.c.compiler}" arg2="vc7" /> + </and> + </condition> + <condition property="isMingw"> + <and> + <istrue value="${isWindows}" /> + <equals arg1="${win32.c.compiler}" arg2="mingw" /> + </and> + </condition> + <echo message="VC6=${isVC6}" /> + <echo message="VC7=${isVC7}" /> + <echo message="MingW=${isMingw}" /> + </target> + + <!-- ================================================================== --> + <!-- + - Set up java.home.dir appropriately on all platforms. + --> + <target name="setup.java.home.dir.nonmacosx" depends="load.user.properties" unless="isOSX"> + <!-- java home dir is up one directory as java.home points to '<java-install-dir>/jre' --> + <property name="java.home.dir" value="${java.home}/.." /> + </target> + <target name="setup.java.home.dir.macosx" depends="load.user.properties" if="isOSX"> + <property name="java.home.dir" value="/System/Library/Frameworks/JavaVM.framework/Home" /> + </target> + <target name="setup.java.home.dir" depends="setup.java.home.dir.nonmacosx,setup.java.home.dir.macosx"/> + + <!-- ================================================================== --> + <!-- + - Declare all paths and user defined variables. + --> + <target name="declare.common" description="Declare properties" depends="base.init"> + <!-- Shorthand for file.separator --> + <property name="sep" value="${file.separator}" /> + + <!-- The location and name of the configuration ANT file that will + - validate to ensure that all user-define variables are set. --> + <property name="validate.user.properties" value="${make}/validate-properties.xml" /> + + <!-- Properties pointing to root of the workspace containing GlueGen. + This build.xml expects that GlueGen has already been built and that its + classes are in the build/classes subdirectory of this other workspace. + Currently we expect that it is contained in the JOGL project. --> + <property name="jogl.root" value="../../jogl" /> + <property name="gluegen.classes" value="${jogl.root}/build/classes" /> + + <!-- Names of directories relative to the project root. + Some of these are used in FileMappers later for dependence information + and need exact string matching, which is why they use file.separator + instead of "/". --> + <property name="rootrel.src" value="src" /> + <property name="rootrel.src.java" value="${rootrel.src}${sep}java" /> + <property name="rootrel.src.c" value="${rootrel.src}${sep}native" /> + <property name="rootrel.build" value="build" /> + <property name="rootrel.src.generated" value="${rootrel.build}${sep}gensrc" /> + <property name="rootrel.generated.java" value="${rootrel.src.generated}${sep}classes" /> + <property name="rootrel.generated.c.joal" value="${rootrel.src.generated}${sep}native${sep}joal" /> + <property name="rootrel.obj" value="${rootrel.build}${sep}obj" /> + <property name="rootrel.obj.joal" value="${rootrel.obj}${sep}joal" /> + + <!-- The source directories. --> + <property name="src" value="${project.root}/${rootrel.src}" /> + <property name="src.c" value="${project.root}/${rootrel.src.c}" /> + <property name="src.java" value="${project.root}/${rootrel.src.java}" /> + <property name="build" value="${project.root}/${rootrel.build}" /> + + <!-- The generated source directories. --> + <property name="src.generated" value="${build}/gensrc" /> + <property name="src.generated.java" value="${src.generated}/classes" /> + <property name="src.generated.c" value="${src.generated}/native/joal" /> + + <!-- The compiler output directories. --> + <property name="classes" value="${build}/classes" /> + <property name="obj" value="${project.root}/${rootrel.obj}" /> + <property name="obj.joal" value="${project.root}/${rootrel.obj.joal}" /> + + <!-- The headers from which Java files are generated --> + <property name="config" value="${project.root}/make" /> + <property name="stub.includes" value="${config}/stub_includes" /> + <property name="stub.includes.dir" value="stub_includes" /> <!-- NOTE: this MUST be relative for FileSet --> + <property name="stub.includes.openal" value="${stub.includes}/openal" /> + <dirset id="stub.includes.fileset.all" dir="."> + <include name="${stub.includes.dir}/openal/**" /> + </dirset> + <fileset id="stub.includes.dependencies.fileset" dir="."> + <include name="${stub.includes.dir}/openal/**" /> + <include name="*.cfg" /> + <include name="*.java" /> + <include name="*.c" /> + </fileset> + + <property name="java.includes.dir" value="${java.home.dir}/include" /> <!-- NOTE: this MUST be relative for FileSet --> + <property name="java.includes.dir.win32" value="${java.includes.dir}/win32" /> + <property name="java.includes.dir.linux" value="${java.includes.dir}/linux" /> + <property name="java.includes.dir.solaris" value="${java.includes.dir}/solaris" /> + <property name="java.includes.dir.macosx" value="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" /> + + <!-- Create the classpath that includes ANTLR and any already + - compiled classes. This requires the user-defined "antlr.jar" + - property. --> + <path id="antlr.classpath"> + <pathelement path="${classpath}" /> + <pathelement location="${gluegen.classes}" /> + <pathelement location="${classes}" /> + <pathelement location="${antlr.jar}" /> + </path> + + <!-- The resulting joal.jar. --> + <property name="joal.jar" value="${build}/joal.jar" /> + + <!-- The javadoc dirs. --> + <property name="javadoc" value="${project.root}/javadoc_public" /> + <property name="javadoc.dev" value="${project.root}/javadoc_joal_dev" /> + <property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" /> + <property name="javadoc.packagenames" value="net.java.games.joal,net.java.games.joal.util" /> + <property name="javadoc.dev.packagenames" value="${javadoc.packagenames},net.java.games.joal.impl" /> + + <!-- Names of configuration files used during glue code generation. --> + <property name="joal.cfg" value="${config}/joal.cfg" /> + <property name="joal.constants.cfg" value="${config}/joal-constants.cfg" /> + <property name="joal.alc.cfg" value="${config}/joal-alc.cfg" /> + <property name="joal.alc.constants.cfg" value="${config}/joal-alc-constants.cfg" /> + </target> + + <!-- ================================================================== --> + <!-- + - Platform specific declares. + --> + <target name="declare.win32.vc6" if="isVC6"> + <echo message="Win32.VC6" /> + <property name="c.compiler.include.root" value="${vc6.root}" /> + <property name="c.linker.lib.root" value="${vc6.root}" /> + + <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> + <property name="linker.cfg.id" value="linker.cfg.win32.msvc" /> + </target> + + <target name="declare.win32.vc7" if="isVC7"> + <echo message="Win32.VC7" /> + <property name="c.compiler.include.root" value="${vc7.root}" /> + <property name="c.linker.lib.root" value="${vc7.root}" /> + + <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> + <property name="linker.cfg.id" value="linker.cfg.win32.msvc" /> + </target> + + <target name="declare.win32.mingw" if="isMingw"> + <echo message="Win32.MingW" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.mingw" /> + <property name="linker.cfg.id" value="linker.cfg.win32.mingw" /> + </target> + + <target name="declare.win32" depends="declare.win32.vc6,declare.win32.vc7,declare.win32.mingw" if="isWindows"> + <property name="java.includes.dir.platform" value="${java.includes.dir.win32}" /> + <property name="java.lib.dir.platform" value="${java.lib.dir.win32}" /> + </target> + + <target name="declare.linux.x86" if="isLinux" unless="isLinuxAMD64"> + <echo message="Linux.x86" /> + <property name="java.includes.dir.platform" value="${java.includes.dir.linux}" /> + <property name="java.lib.dir.platform" value="${java.lib.dir.linux}" /> + + <property name="compiler.cfg.id" value="compiler.cfg.linux" /> + <property name="linker.cfg.id" value="linker.cfg.linux" /> + </target> + + <target name="declare.linux.amd64" if="isLinuxAMD64"> + <echo message="Linux.AMD64" /> + <property name="java.includes.dir.platform" value="${java.includes.dir.linux}" /> + <property name="java.lib.dir.platform" value="${java.lib.dir.linux.amd64}" /> + + <property name="compiler.cfg.id" value="compiler.cfg.linux.amd64" /> + <property name="linker.cfg.id" value="linker.cfg.linux.amd64" /> + </target> + + <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64" if="isLinux" /> + + <target name="declare.solaris" if="isSolaris"> + <echo message="Solaris" /> + <property name="java.includes.dir.platform" value="${java.includes.dir.solaris}" /> + <property name="java.lib.dir.platform" value="${java.lib.dir.solaris}" /> + + <property name="compiler.cfg.id" value="compiler.cfg.solaris" /> + <property name="linker.cfg.id" value="linker.cfg.solaris" /> + </target> + + <target name="declare.macosx" if="isOSX"> + <echo message="MacOSX" /> + <property name="java.includes.dir.platform" value="${java.includes.dir.macosx}" /> + <property name="java.lib.dir.platform" value="${java.lib.dir.macosx}" /> + + <property name="compiler.cfg.id" value="compiler.cfg.macosx" /> + <property name="linker.cfg.id" value="linker.cfg.macosx" /> + </target> + + <target name="declare.freebsd" if="isFreeBSD"> + <echo message="FreeBSD" /> + <property name="java.includes.dir.platform" value="${java.includes.dir.freebsd}" /> + <property name="java.lib.dir.platform" value="${java.lib.dir.linux}" /> + + <property name="compiler.cfg.id" value="compiler.cfg.freebsd" /> + <property name="linker.cfg.id" value="linker.cfg.linux" /> + </target> + + <!-- ================================================================== --> + <!-- + - Initialize all parameters required for the build and create any + - required directories. + --> + <target name="init" depends="declare.common"> + <!-- Call the external config validator script to make sure the config is ok and consistent --> + <ant antfile="${validate.user.properties}" inheritall="true"/> + + <!-- Create the required output directories. --> + <mkdir dir="${src.generated.java}" /> + <mkdir dir="${src.generated.c}" /> + <mkdir dir="${classes}" /> + <mkdir dir="${obj}" /> + <mkdir dir="${obj.joal}" /> + </target> + + <target name="declare" depends="init,declare.win32,declare.linux,declare.solaris,declare.macosx,declare.freebsd" /> + + <!-- ================================================================== --> + <!-- Java file generation --> + <!-- + - Check to see whether we need to rebuild the generated sources. + --> + + <target name="java.generate.check"> + <!-- Blow away all target files if any dependencies are violated + (the uptodate task doesn't allow arbitrary source and target filesets but should) --> + <dependset> + <srcfileset refid="stub.includes.dependencies.fileset" /> + <srcfileset dir="."> + <include name="${classes}/net/java/games/gluegen/**/*.class" /> + </srcfileset> + <targetfileset dir="."> + <include name="${src.generated.java}/**/*.java" /> + <include name="${src.generated.c}/**/*.c" /> + </targetfileset> + </dependset> + + <!-- Now check for the presence of one well-known file --> + <uptodate property="java.generate.skip"> + <srcfiles refid="stub.includes.dependencies.fileset" /> + <mapper type="merge" to="${src.generated.java}/net/java/games/joal/AL.java" /> + </uptodate> + </target> + + <!-- + - Setup the generating ANT tasks and use it to generate the Java files + - from the C GL headers. This involves setting the taskdef and creating + - the classpath reference id then running the task on each header. + --> + <target name="java.generate" depends="java.generate.check" unless="java.generate.skip"> + <!-- Add the GlueGen task to ANT --> + <taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask" + classpathref="antlr.classpath" /> + + <!-- Use the GlueGen task to generate the Java files --> + + <!-- Generate the AL interface class and implementation --> + <gluegen src="${stub.includes.openal}/al.h" + config="${joal.cfg}" + includeRefid="stub.includes.fileset.all" + emitter="com.sun.gluegen.procaddress.ProcAddressEmitter"> + <classpath refid="antlr.classpath" /> + </gluegen> + + <!-- Generate the ALConstants interface class --> + <gluegen src="${stub.includes.openal}/al.h" + config="${joal.constants.cfg}" + includeRefid="stub.includes.fileset.all" + emitter="com.sun.gluegen.JavaEmitter"> + <classpath refid="antlr.classpath" /> + </gluegen> + + <!-- Generate the ALC interface class and implementation --> + <gluegen src="${stub.includes.openal}/alc.h" + config="${joal.alc.cfg}" + includeRefid="stub.includes.fileset.all" + emitter="com.sun.gluegen.procaddress.ProcAddressEmitter"> + <classpath refid="antlr.classpath" /> + </gluegen> + + <!-- Generate the ALCConstants interface class --> + <gluegen src="${stub.includes.openal}/alc.h" + config="${joal.alc.constants.cfg}" + includeRefid="stub.includes.fileset.all" + emitter="com.sun.gluegen.JavaEmitter"> + <classpath refid="antlr.classpath" /> + </gluegen> + + <!-- Inform the user that the generators have successfully created + - the necessary Java files --> + <echo message="" /> + <echo message="GlueGen has successfully generated files." /> + + </target> + + <!-- ================================================================== --> + <!-- + - Compile the original and generated source. + --> + <target name="java.compile" depends="java.generate"> + <javac destdir="${classes}" source="1.4" debug="true" debuglevel="source,lines"> + <src path="${src.java}" /> + <src path="${src.generated.java}" /> + <classpath refid="antlr.classpath" /> + </javac> + </target> + + <!-- ================================================================== --> + <!-- + - Compile the native C code for JOAL. + --> + + <target name="c.configure"> + + <!-- import cpptasks --> + <typedef resource="net/sf/antcontrib/cpptasks/antlib.xml" classpath="${jogl.root}/make/lib/cpptasks.jar"/> + <!--typedef resource="net/sf/antcontrib/cpptasks/antlib.xml"/--> + + <!-- compiler configuration --> + <compiler id="compiler.cfg.linux" name="gcc" /> + + <compiler id="compiler.cfg.linux.amd64" name="gcc"> + <compilerarg value="-fPIC"/> + </compiler> + + <compiler id="compiler.cfg.solaris" name="suncc"> + </compiler> + + <compiler id="compiler.cfg.win32.mingw" name="gcc"> + <defineset> + <define name="_DEBUG" if="c.compiler.use-debug"/> + <define name="DEBUG" if="c.compiler.use-debug"/> + <define name="NDEBUG" unless="c.compiler.use-debug"/> + + <define name="DBUILD_DLL" /> + <define name="_WINGDI_" /> + <define name="_STRICT_ANSI" /> + <define name="_JNI_IMPLEMENTATION_" /> + </defineset> + </compiler> + + <compiler id="compiler.cfg.win32.msvc" name="msvc"> + <compilerarg value="/W3"/> <!-- set warning level --> + <compilerarg value="/Ob1"/> <!-- inline only functions marked inline --> + <compilerarg value="/GF"/> <!-- enable string pooling --> + <compilerarg value="/Gy"/> <!-- enable function level linking --> + <compilerarg value="/GS" if="isVC7"/> <!-- buffer security checks --> + <compilerarg value="/Wp64" if="isVC7"/> <!-- detect 64-bit port problems --> + <compilerarg value="/RTCcsu" if="isVC7"/> <!-- various runtime checks --> + <!-- Note: previous compiler options for VC7 were: + Debug: /MDd /Yd /GS /RTCs /RTCu /RTCc /W3 /Od /GF /EHsc /Zi /GS /Gy /Wp64 /Zi /D "_DEBUG" + Optimized: /MD /W3 /O2 /Ob1 /GF /EHsc /GS /Gy /Wp64 /D "NDEBUG" --> + + <sysincludepath path="${c.compiler.include.root}/PlatformSDK/Include"/> + <sysincludepath path="${c.compiler.include.root}/include"/> + + <defineset> + <define name="_DEBUG" if="c.compiler.use-debug"/> + <define name="DEBUG" if="c.compiler.use-debug"/> + <define name="NDEBUG" unless="c.compiler.use-debug"/> + </defineset> + </compiler> + + <compiler id="compiler.cfg.macosx" name="gcc"> + <compilerarg value="-arch" if="macosxfat"/> + <compilerarg value="ppc" if="macosxfat"/> + <compilerarg value="-arch" if="macosxfat"/> + <compilerarg value="i386" if="macosxfat"/> + <compilerarg value="-Wmost" /> + <compilerarg value="-ObjC" /> + <defineset> + <define name="macosx" /> + </defineset> + </compiler> + + <compiler id="compiler.cfg.freebsd" name="gcc"> + <includepath path="/usr/X11R6/include" /> + </compiler> + + <!-- linker configuration --> + + <linker id="linker.cfg.linux" name="gcc"> + <syslibset dir="${joal.lib.dir}" libs="openal"/> + </linker> + + <linker id="linker.cfg.linux.amd64" name="gcc"> + <syslibset dir="${joal.lib.dir}" libs="openal"/> + </linker> + + <linker id="linker.cfg.solaris" name="suncc"> + <syslibset dir="${joal.lib.dir}" libs="openal"/> + </linker> + + <linker id="linker.cfg.win32.mingw" name="gcc" incremental="false"> + <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names --> + <syslibset dir="${joal.lib.dir}" libs="openal32, kernel32"/> + </linker> + + <linker id="linker.cfg.win32.msvc" name="msvc" incremental="false"> + <linkerarg value="/OPT:REF,ICF" /> <!-- enable link-time optimisations --> + <linkerarg value="/SUBSYSTEM:WINDOWS" /> <!-- output is not a console app as uses WinMain entry point --> + <linkerarg value="/MACHINE:IX86" /> <!-- explicity set target platform --> + + <syslibset dir="${joal.lib.dir}" libs="openal32" /> + <syslibset dir="${c.linker.lib.root}/lib" libs="kernel32" unless="isVC7"/> + <syslibset dir="${c.linker.lib.root}/PlatformSDK/lib" libs="kernel32" if="isVC7"/> + </linker> + + <linker id="linker.cfg.macosx" name="gcc"> + <linkerarg value="-arch" if="macosxfat"/> + <linkerarg value="ppc" if="macosxfat"/> + <linkerarg value="-arch" if="macosxfat"/> + <linkerarg value="i386" if="macosxfat"/> + <linkerarg value="-framework" /> + <linkerarg value="Cocoa" /> + <linkerarg value="-framework" /> + <linkerarg value="OpenGL" /> + <linkerarg value="-framework" if="c.compiler.use-cglib" /> + <linkerarg value="Cg" if="c.compiler.use-cglib" /> + </linker> + + <patternset id="c.src.files.joal"> + <include name="${rootrel.src.c}/*.c"/> + <include name="${rootrel.generated.c.joal}/*.c"/> + </patternset> + + </target> + + <target name="c.build" depends="c.configure"> + <fail message="Requires '${c.compiler.src.files}'" unless="c.compiler.src.files"/> + <fail message="Requires '${compiler.cfg.id}'" unless="compiler.cfg.id"/> + <fail message="Requires '${linker.cfg.id}'" unless="linker.cfg.id"/> + <fail message="Requires '${output.lib.name}'" unless="output.lib.name"/> + + <echo message="Output lib name = ${output.lib.name}" /> + + <!-- NOTE: the value of the debug and optimise attributes will not be overridden if already set externally --> + <property name="c.compiler.debug" value="false" /> + <!-- Optimise flags one of { none, size, speed, minimal, full, aggressive, extreme, unsafe } --> + <property name="c.compiler.optimise" value="none" /> + + <condition property="c.compiler.use-debug"><istrue value="${c.compiler.debug}"/></condition> + + <cc outtype="shared" + objdir="${obj.joal}" + outfile="${obj}/${output.lib.name}" + optimize="${c.compiler.optimise}" + debug="${c.compiler.debug}" + multithreaded="true" + exceptions="false" + rtti="false"> + + <!-- TODO: versioninfo companyname="java.net" + legalcopyright="Copyright" + productname="JOAL" + productversion="x.y.z" + description="Description" + fileversion="x.y.z" + filecomments="File Comment" /--> + + <fileset dir="${project.root}"><patternset refid="${c.compiler.src.files}"/></fileset> + + <compiler extends="${compiler.cfg.id}" > + <sysincludepath path="${java.includes.dir}"/> + <sysincludepath path="${java.includes.dir.platform}"/> + <includepath path="stub_includes/openal"/> + </compiler> + + <linker extends="${linker.cfg.id}" /> + </cc> + </target> + + <target name="c.rename.joal.lib.mingw" if="isMingw"> + <!-- FIXME: this is a hack; the cpptask should have an option to change the + suffix or at least understand the override from .so to .dll --> + <move file="${obj}/libjoal.so" tofile="${obj}/joal.dll" failonerror="false" /> + </target> + + <target name="c.rename.joal.lib.macosx" if="isOSX"> + <!-- FIXME: this is a hack; the cpptask should have an option to change the + suffix or at least understand the override from dylib to jnilib --> + <move file="${obj}/libjoal.dylib" tofile="${obj}/libjoal.jnilib" /> + </target> + + <target name="c.build.joal"> + <antcall target="c.build" inheritRefs="true"> + <param name="c.compiler.src.files" value="c.src.files.joal"/> + <param name="output.lib.name" value="joal_native"/> + </antcall> + <antcall target="c.rename.joal.lib.mingw" inheritRefs="true" /> + <antcall target="c.rename.joal.lib.macosx" inheritRefs="true" /> + </target> + + <!-- ================================================================== --> + <!-- + - Build the joal.jar file. + --> + <target name="jar" depends="java.compile"> + <!-- Build the jar excluding any build specific classes. --> + <jar destfile="${joal.jar}"> + <fileset dir="${classes}"> + <include name="net/java/games/**" /> + </fileset> + <fileset dir="${gluegen.classes}"> + <include name="com/sun/gluegen/runtime/**" /> + </fileset> + </jar> + + </target> + + <!-- ================================================================== --> + <!-- + - Build the Javadocs for the sources. + - NOTE: these are not entirely correct as the javadocs targets depend + - on the platform specific build targets. To circumvent any + - errors, ensure that the source is built first. + --> + <target name="javadoc" depends="setup.java.home.dir,init"> + <javadoc packagenames="${javadoc.packagenames}" + sourcepath="${src.java};${src.generated.java}" + classpath="${gluegen.classes}" + destdir="${javadoc}" windowtitle="JOAL API" + source="1.4" + link="${javadoc.link}" /> + </target> + + <target name="javadoc.dev" depends="init"> + <!-- Build the internal developer Javadoc --> + <javadoc packagenames="${javadoc.dev.packagenames},${javadoc.dev.packagenames.platform}" + sourcepath="${src.java};${src.generated.java}" + destdir="${javadoc.dev}" windowtitle="JOAL API" + source="1.4" + link="${javadoc.link}" /> + </target> + + <!-- ================================================================== --> + <!-- + - Build the platform-independent distribution out of jars built for + - Windows, Linux and Mac OS X; the Java sources for Joal can't be + - fully cross-compiled at this time. To run this target, you need to + - specify the property joal.dist.dir as a System property (i.e., + - "ant -Djoal.dist.dir=../dist dist"); directories named joal-linux, + - joal-win32, and joal-macosx need to be inside that directory and each + - of those directories needs to contain both the joal.jar for that + - platform as well as the native code (libjoal.so, joal.dll, or + - libjoal.jnilib). Also builds jars containing the native code for + - Windows, Linux, Mac OS X, Solaris/SPARC and Solaris/x86. + --> + <target name="dist.check" unless="joal.dist.dir"> + <fail> + + ****************************************************************** + ** To build the Joal distribution out of the platform-specific ** + ** component jars and native code, the property joal.dist.dir ** + ** needs to be specified on the command line. Please read the ** + ** comments associated with the "dist" target in the build.xml. ** + ****************************************************************** + </fail> + </target> + + <target name="dist" depends="dist.check"> + <delete file="${joal.dist.dir}/joal.jar" /> + <delete> + <fileset dir="${joal.dist.dir}" includes="joal-natives-*.jar" /> + </delete> + <jar destfile="${joal.dist.dir}/joal.jar" duplicate="preserve"> + <zipgroupfileset dir="${joal.dist.dir}" + includes="joal-win32/*.jar, joal-linux/*.jar, joal-macosx/*.jar" /> + </jar> + <jar destfile="${joal.dist.dir}/joal-natives-win32.jar" + basedir="${joal.dist.dir}/joal-win32" + includes="joal.dll" /> + <jar destfile="${joal.dist.dir}/joal-natives-linux.jar" + basedir="${joal.dist.dir}/joal-linux" + includes="libjoal.so" /> + <jar destfile="${joal.dist.dir}/joal-natives-macosx.jar" + basedir="${joal.dist.dir}/joal-macosx" + includes="libjoal.jnilib" /> + <jar destfile="${joal.dist.dir}/joal-natives-solsparc.jar" + basedir="${joal.dist.dir}/joal-solsparc" + includes="libjoal.so" /> + <!-- Note: Solaris/x86 elided for now as it requires Mesa to + be installed --> + <!-- jar destfile="${joal.dist.dir}/joal-natives-solx86.jar" + basedir="${joal.dist.dir}/joal-solx86" + includes="libjoal.so" --> + </target> + + <!-- ================================================================== --> + <!-- + - Clean up all that is built. + --> + <target name="clean" depends="declare.common"> + <delete includeEmptyDirs="true" quiet="true"> + <fileset dir="${build}" /> + <fileset dir="${javadoc}" /> + <fileset dir="${javadoc.dev}" /> + </delete> + <ant dir="../unit_tests" target="clean"/> + </target> + + <!-- ================================================================== --> + <!-- + - Build everything. + --> + <target name="all" depends="setup.java.home.dir,init,declare"> + <!-- Generate, compile, and build the jar for the Java sources. --> + <antcall target="jar" inheritRefs="true" /> + + <!-- Compile the native C sources . --> + <antcall target="c.build.joal" inheritRefs="true" /> + </target> + + <!-- ================================================================== --> + <!-- + - Build and run tests. + --> + + <target name="runtests" depends="all"> + <ant dir="../unit_tests" target="compile"/> + <ant dir="../unit_tests" target="runOpenALTest"/> + <ant dir="../unit_tests" target="runSound3DTest"/> + </target> +</project> diff --git a/make/joal-CustomCCode.c b/make/joal-CustomCCode.c new file mode 100755 index 0000000..a6d0bb6 --- /dev/null +++ b/make/joal-CustomCCode.c @@ -0,0 +1,40 @@ +#if defined(_MSC_VER) /* Windows */ +#include <windows.h> +static HMODULE oalModule = NULL; +#endif + +/* Java->C glue code: + * Java package: net.java.games.joal.impl.ALImpl + * Java method: long dynamicLookupFunction0(java.lang.String fname) + * C function: ALproc alGetProcAddress(const ALchar * fname); + */ +JNIEXPORT jlong JNICALL +Java_net_java_games_joal_impl_ALImpl_dynamicLookupFunction0__Ljava_lang_String_2(JNIEnv *env, jobject _unused, jstring fname) { + const char* _UTF8fname = NULL; + ALproc _res; + if (fname != NULL) { + if (fname != NULL) { + _UTF8fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL); + if (_UTF8fname == NULL) { + (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), + "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"alGetProcAddress\""); + return 0; + } + } + } +#if defined(_MSC_VER) /* Windows */ + if (oalModule == NULL) { + oalModule = GetModuleHandle("OpenAL32"); + } + _res = (ALproc) GetProcAddress(oalModule, _UTF8fname); +/* Looks like we can use dlsym on OS X as well as other Unix flavors */ +/* #elif defined(__APPLE__) && defined(__MACH__) */ /* OS X */ +#else /* Assume vanilla Unix */ + _res = (ALproc) dlsym(RTLD_DEFAULT, _UTF8fname); +#endif + + if (fname != NULL) { + (*env)->ReleaseStringUTFChars(env, fname, _UTF8fname); + } + return (jlong) (intptr_t) _res; +} diff --git a/make/joal-alc-constants.cfg b/make/joal-alc-constants.cfg new file mode 100755 index 0000000..83ea061 --- /dev/null +++ b/make/joal-alc-constants.cfg @@ -0,0 +1,8 @@ +# This .cfg file is used to generate the ALCConstants interface. +Include joal-common.cfg + +Style InterfaceOnly +JavaClass ALCConstants + +# Factor out the OpenAL constants into their own interface +IgnoreNot ^ALC_.+ diff --git a/make/joal-alc.cfg b/make/joal-alc.cfg new file mode 100755 index 0000000..cdc24bb --- /dev/null +++ b/make/joal-alc.cfg @@ -0,0 +1,57 @@ +# This .cfg file is used to generate the JOAL interface. +Include joal-common.cfg + +Style InterfaceAndImpl +JavaClass ALC +ImplPackage net.java.games.joal.impl +ImplJavaClass ALCImpl +Extends ALC ALCConstants + +EmitProcAddressTable true +ProcAddressTableClassName ALCProcAddressTable +GetProcAddressTableExpr ALProcAddressLookup.getALCProcAddressTable() +ProcAddressNameExpr LP $UPPERCASE({0}) + +Import java.nio.* +Import net.java.games.joal.* +Import net.java.games.joal.impl.* + +# Factor out the OpenAL constants into their own interface +Ignore ^AL_.+ +Ignore ^ALC_.+ + +# This routine is ignored. The analogous routine alGetProcAddress is +# broken at least up through OpenAL 1.1 so there is no point in trying +# to use this routine to look up the ALC function pointers. +Ignore alcGetProcAddress + +# These routines use or return strings +ReturnsString alcGetString +ArgumentIsString alcIsExtensionPresent 1 +ArgumentIsString alcOpenDevice 0 + +# Mappings for data types +Opaque boolean ALCboolean + +# Provide #includes to native code +CustomCCode #include "alc.h" + +# Indicate that the direct buffers for ALCcontext, etc. are "opaque", +# i.e., the user shouldn't be poking around in them +ReturnValueCapacity alcCreateContext 0 +ReturnValueCapacity alcGetContextsDevice 0 +ReturnValueCapacity alcGetCurrentContext 0 +ReturnValueCapacity alcGetCurrentDevice 0 +ReturnValueCapacity alcOpenDevice 0 + +# These routines need to be statically linked for bootstrapping +SkipProcAddressGen alcOpenDevice +SkipProcAddressGen alcCreateContext +SkipProcAddressGen alcMakeContextCurrent + +# Need an epilogue on alcOpenDevice and alcMakeContextCurrent to set +# up the proc address tables the first time +JavaEpilogue alcOpenDevice ALProcAddressLookup.resetALCProcAddressTable(); +JavaEpilogue alcMakeContextCurrent ALProcAddressLookup.resetALProcAddressTable(); + +IncludeAs CustomCCode joal-common-CustomCCode.c diff --git a/make/joal-common-CustomCCode.c b/make/joal-common-CustomCCode.c new file mode 100755 index 0000000..f749723 --- /dev/null +++ b/make/joal-common-CustomCCode.c @@ -0,0 +1,9 @@ +#ifdef _MSC_VER /* Windows, Microsoft compilers */ +/* This typedef is only needed for VC6 */ +#if _MSC_VER <= 1200 +typedef int intptr_t; +#endif +#else +/* This header seems to be available on all other platforms */ +#include <inttypes.h> +#endif diff --git a/make/joal-common.cfg b/make/joal-common.cfg new file mode 100755 index 0000000..85dba07 --- /dev/null +++ b/make/joal-common.cfg @@ -0,0 +1,9 @@ +Package net.java.games.joal + +# Specify output directories +HierarchicalNativeOutput false +JavaOutputDir ../build/gensrc/classes +NativeOutputDir ../build/gensrc/native/joal + +# Raise ALException instead of RuntimeException in glue code +RuntimeExceptionType ALException diff --git a/make/joal-constants.cfg b/make/joal-constants.cfg new file mode 100755 index 0000000..9abd941 --- /dev/null +++ b/make/joal-constants.cfg @@ -0,0 +1,12 @@ +# This .cfg file is used to generate the ALConstants interface. +Include joal-common.cfg + +Style InterfaceOnly +JavaClass ALConstants + +# Factor out the OpenAL constants into their own interface +IgnoreNot ^AL_.+ + +# Add back in the constants the PCPP can't currently parse +# (FIXME: once it does, these lines will have to be removed) +CustomJavaCode ALConstants public static final int AL_INVALID = -1; diff --git a/make/joal.cfg b/make/joal.cfg new file mode 100755 index 0000000..c6894d9 --- /dev/null +++ b/make/joal.cfg @@ -0,0 +1,67 @@ +# This .cfg file is used to generate the JOAL interface. +Include joal-common.cfg + +Style InterfaceAndImpl +JavaClass AL +ImplPackage net.java.games.joal.impl +ImplJavaClass ALImpl +Extends AL ALConstants + +Implements ALImpl DynamicLookupHelper + +EmitProcAddressTable true +ProcAddressTableClassName ALProcAddressTable +GetProcAddressTableExpr ALProcAddressLookup.getALProcAddressTable() +ProcAddressNameExpr LP $UPPERCASE({0}) + +Import net.java.games.joal.* +Import net.java.games.joal.impl.* +Import com.sun.gluegen.runtime.* + +# Factor out the OpenAL constants into their own interface +Ignore ^AL_.+ + +# alGetProcAddress is broken for core OpenAL routines at least up +# through OpenAL 1.1, so we have to implement our own dlsym() +# operation in order to populate the ALProcAddressTable and +# ALCProcAddressTable. If / when it is fixed and we don't need +# compatibility with preexisting OpenAL 1.0 and 1.1 installations we +# can enable the code below and delete the custom C code for +# dynamicLookupFunction0. +Ignore alGetProcAddress + +# This routine is not exposed in the public API +# AccessControl alGetProcAddress PACKAGE_PRIVATE +# And it's also statically linked for bootstrapping +# (could also consider looking it up via dlsym to more fully allow +# unloading of OpenAL, but that doesn't seem necessary and requires +# more native code to load/unload libraries) +# SkipProcAddressGen alGetProcAddress +# We also have to hack its return type for now because we can't make +# just that void* opaque +# Opaque long ALproc + +# This routine doesn't seem to exist +Ignore alHint + +# Mappings for data types +Opaque boolean ALboolean + +# These routines use or return strings +ReturnsString alGetString +ArgumentIsString alIsExtensionPresent 0 +ArgumentIsString alGetEnumValue 0 +ArgumentIsString alGetProcAddress 0 + +# Provide #includes to native code +CustomCCode #include "al.h" + +CustomJavaCode ALImpl /** Provides dlsym() capabilities because alGetProcAddress is +CustomJavaCode ALImpl broken for core OpenAL routines at least up through OpenAL 1.1. */ +CustomJavaCode ALImpl public long dynamicLookupFunction(String functionName) { +CustomJavaCode ALImpl return dynamicLookupFunction0(functionName); +CustomJavaCode ALImpl } +CustomJavaCode ALImpl private native long dynamicLookupFunction0(String functionName); + +IncludeAs CustomCCode joal-common-CustomCCode.c +IncludeAs CustomCCode joal-CustomCCode.c diff --git a/make/joal.properties b/make/joal.properties new file mode 100755 index 0000000..436dc9f --- /dev/null +++ b/make/joal.properties @@ -0,0 +1,69 @@ +############################################################################### +# The host specific properties. The build will inform you of required +# properties. This file must be copied into your home directory (pointed +# to by the Java system property user.home) and the copy modified appropriately. +############################################################################### +# +# java.home.dir is usually inferred from the java.home variable. +# If it appears the build is failing because of an inability to +# find e.g. JAWT or JNI headers, override this to point to the +# root directory of your JDK. +# +# java.home.dir=C:/jdk1.4.2 + +# +# The required antlr.jar property that is the full path to the antlr.jar +# including the name of the jar +# +# Windows +antlr.jar=C:/Users/kbr/ANTLR/antlr-2.7.2/antlr.jar +# Linux +# antlr.jar=/home/kbr/antlr-2.7.2/antlr.jar +# Mac OS X +# antlr.jar=/Users/kbr/antlr-2.7.2/antlr.jar +# Solaris +# antlr.jar=/export/kbr/ANTLR/antlr-2.7.2/antlr.jar + +# +# The required joal.lib.dir points to the directory containing the +# OpenAL library against which JOAL is linked. On Windows, this is the +# directory containing OpenAL32.lib (the import library); on other +# platforms, it's the directory containing libopenal.so. +# Windows +# OpenAL 1.0 +# joal.lib.dir=C:/Program Files/OpenAL 1.0 Software Development Kit/libs +# OpenAL 1.1 (can link against either version; binding supports OpenAL +# 1.1 if available at run time) +# joal.lib.dir=C:/Program Files/OpenAL 1.1 SDK/libs/Win32 +# Linux +# joal.lib.dir=/usr/lib +# Mac OS X +# joal.lib.dir=/Library/Frameworks/OpenAL.framework +# Solaris (not yet supported) +# joal.lib.dir=/usr/lib + +# If you are building on Windows and have the Microsoft Visual C++ +# compilers installed, you can choose an alternate compiler with which +# to build the JOAL native code. Valid strings here are "vc6", "vc7", +# and "mingw". +win32.c.compiler=mingw + +# +# If you are building on Windows with Visual C++ 6.0 and have installed +# the compiler in somewhere other than the default location, modify this +# to point to the absolute path of the VC98 directory +# +vc6.root=C:/Program Files/Microsoft Visual Studio/VC98 + +# +# If you are building on Windows with Visual C++ 7.0 and have installed +# the compiler in somewhere other than the default location, modify this +# to point to the absolute path of the VC98 directory +# +vc7.root=C:/Program Files/Microsoft Visual Studio .NET/Vc7 + +# +# If you are building on a Mac OS X system supporting +# cross-compilation and want to generate fat (PPC and x86) binaries, +# uncomment the property below +# macosxfat=true diff --git a/make/readme.txt b/make/readme.txt new file mode 100755 index 0000000..f435b83 --- /dev/null +++ b/make/readme.txt @@ -0,0 +1,9 @@ +We needed to modify the OpenAL headers from creative.com (the ones +from the Windows installer) in the following ways: + + - In the untaken arms of the #ifdef _WIN32 clauses at the top of al.h + and alc.h, change the #define ALAPIENTRY and #define ALCAPIENTRY to + define those to the empty token rather than to __cdecl. + + - Hoist the typedefs of ALCdevice and ALCcontext in alc.h out of the + #ifdef _WIN32 clause. diff --git a/make/stub_includes/openal/al.h b/make/stub_includes/openal/al.h new file mode 100755 index 0000000..d73a1c0 --- /dev/null +++ b/make/stub_includes/openal/al.h @@ -0,0 +1,756 @@ +#ifndef AL_AL_H +#define AL_AL_H + +/** + * OpenAL cross platform audio library + * Copyright (C) 1999-2000 by authors. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * Or go to http://www.gnu.org/copyleft/lgpl.html + */ + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(_WIN32) && !defined(_XBOX) + /* _OPENAL32LIB is deprecated */ + #if defined(AL_BUILD_LIBRARY) || defined (_OPENAL32LIB) + #define AL_API __declspec(dllexport) + #else + #define AL_API __declspec(dllimport) + #endif +#else + #define AL_API extern +#endif + +#if defined(_WIN32) + #define AL_APIENTRY __cdecl +#else + #define AL_APIENTRY +#endif + +#if TARGET_OS_MAC + #pragma export on +#endif + +/* The OPENAL, ALAPI, and ALAPIENTRY macros are deprecated, but are included for applications porting code + from AL 1.0 */ +#define OPENAL +#define ALAPI AL_API +#define ALAPIENTRY AL_APIENTRY + +#define AL_VERSION_1_0 +#define AL_VERSION_1_1 + + +/** 8-bit boolean */ +typedef char ALboolean; + +/** character */ +typedef char ALchar; + +/** signed 8-bit 2's complement integer */ +typedef char ALbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALsizei; + +/** enumerated 32-bit value */ +typedef int ALenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALdouble; + +/** void type (for opaque pointers only) */ +typedef void ALvoid; + +/** Function pointer type */ +typedef void* ALproc; + +/* Enumerant values begin at column 50. No tabs. */ + +/* bad value */ +#define AL_INVALID -1 + +#define AL_NONE 0 + +/* Boolean False. */ +#define AL_FALSE 0 + +/** Boolean True. */ +#define AL_TRUE 1 + +/** Indicate Source has relative coordinates. */ +#define AL_SOURCE_RELATIVE 0x202 + + + +/** + * Directional source, inner cone angle, in degrees. + * Range: [0-360] + * Default: 360 + */ +#define AL_CONE_INNER_ANGLE 0x1001 + +/** + * Directional source, outer cone angle, in degrees. + * Range: [0-360] + * Default: 360 + */ +#define AL_CONE_OUTER_ANGLE 0x1002 + +/** + * Specify the pitch to be applied, either at source, + * or on mixer results, at listener. + * Range: [0.5-2.0] + * Default: 1.0 + */ +#define AL_PITCH 0x1003 + +/** + * Specify the current location in three dimensional space. + * OpenAL, like OpenGL, uses a right handed coordinate system, + * where in a frontal default view X (thumb) points right, + * Y points up (index finger), and Z points towards the + * viewer/camera (middle finger). + * To switch from a left handed coordinate system, flip the + * sign on the Z coordinate. + * Listener position is always in the world coordinate system. + */ +#define AL_POSITION 0x1004 + +/** Specify the current direction. */ +#define AL_DIRECTION 0x1005 + +/** Specify the current velocity in three dimensional space. */ +#define AL_VELOCITY 0x1006 + +/** + * Indicate whether source is looping. + * Type: ALboolean? + * Range: [AL_TRUE, AL_FALSE] + * Default: FALSE. + */ +#define AL_LOOPING 0x1007 + +/** + * Indicate the buffer to provide sound samples. + * Type: ALuint. + * Range: any valid Buffer id. + */ +#define AL_BUFFER 0x1009 + +/** + * Indicate the gain (volume amplification) applied. + * Type: ALfloat. + * Range: ]0.0- ] + * A value of 1.0 means un-attenuated/unchanged. + * Each division by 2 equals an attenuation of -6dB. + * Each multiplicaton with 2 equals an amplification of +6dB. + * A value of 0.0 is meaningless with respect to a logarithmic + * scale; it is interpreted as zero volume - the channel + * is effectively disabled. + */ +#define AL_GAIN 0x100A + +/* + * Indicate minimum source attenuation + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * Logarthmic + */ +#define AL_MIN_GAIN 0x100D + +/** + * Indicate maximum source attenuation + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * Logarthmic + */ +#define AL_MAX_GAIN 0x100E + +/** + * Indicate listener orientation. + * + * at/up + */ +#define AL_ORIENTATION 0x100F + +/** + * Specify the channel mask. (Creative) + * Type: ALuint + * Range: [0 - 255] + */ +#define AL_CHANNEL_MASK 0x3000 + + +/** + * Source state information. + */ +#define AL_SOURCE_STATE 0x1010 +#define AL_INITIAL 0x1011 +#define AL_PLAYING 0x1012 +#define AL_PAUSED 0x1013 +#define AL_STOPPED 0x1014 + +/** + * Buffer Queue params + */ +#define AL_BUFFERS_QUEUED 0x1015 +#define AL_BUFFERS_PROCESSED 0x1016 + +/** + * Source buffer position information + */ +#define AL_SEC_OFFSET 0x1024 +#define AL_SAMPLE_OFFSET 0x1025 +#define AL_BYTE_OFFSET 0x1026 + +/* + * Source type (Static, Streaming or undetermined) + * Source is Static if a Buffer has been attached using AL_BUFFER + * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers + * Source is undetermined when it has the NULL buffer attached + */ +#define AL_SOURCE_TYPE 0x1027 +#define AL_STATIC 0x1028 +#define AL_STREAMING 0x1029 +#define AL_UNDETERMINED 0x1030 + +/** Sound samples: format specifier. */ +#define AL_FORMAT_MONO8 0x1100 +#define AL_FORMAT_MONO16 0x1101 +#define AL_FORMAT_STEREO8 0x1102 +#define AL_FORMAT_STEREO16 0x1103 + +/** + * source specific reference distance + * Type: ALfloat + * Range: 0.0 - +inf + * + * At 0.0, no distance attenuation occurs. Default is + * 1.0. + */ +#define AL_REFERENCE_DISTANCE 0x1020 + +/** + * source specific rolloff factor + * Type: ALfloat + * Range: 0.0 - +inf + * + */ +#define AL_ROLLOFF_FACTOR 0x1021 + +/** + * Directional source, outer cone gain. + * + * Default: 0.0 + * Range: [0.0 - 1.0] + * Logarithmic + */ +#define AL_CONE_OUTER_GAIN 0x1022 + +/** + * Indicate distance above which sources are not + * attenuated using the inverse clamped distance model. + * + * Default: +inf + * Type: ALfloat + * Range: 0.0 - +inf + */ +#define AL_MAX_DISTANCE 0x1023 + +/** + * Sound samples: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ +#define AL_FREQUENCY 0x2001 +#define AL_BITS 0x2002 +#define AL_CHANNELS 0x2003 +#define AL_SIZE 0x2004 + +/** + * Buffer state. + * + * Not supported for public use (yet). + */ +#define AL_UNUSED 0x2010 +#define AL_PENDING 0x2011 +#define AL_PROCESSED 0x2012 + + +/** Errors: No Error. */ +#define AL_NO_ERROR AL_FALSE + +/** + * Invalid Name paramater passed to AL call. + */ +#define AL_INVALID_NAME 0xA001 + +/** + * Invalid parameter passed to AL call. + */ +#define AL_ILLEGAL_ENUM 0xA002 +#define AL_INVALID_ENUM 0xA002 + +/** + * Invalid enum parameter value. + */ +#define AL_INVALID_VALUE 0xA003 + +/** + * Illegal call. + */ +#define AL_ILLEGAL_COMMAND 0xA004 +#define AL_INVALID_OPERATION 0xA004 + + +/** + * No mojo. + */ +#define AL_OUT_OF_MEMORY 0xA005 + + +/** Context strings: Vendor Name. */ +#define AL_VENDOR 0xB001 +#define AL_VERSION 0xB002 +#define AL_RENDERER 0xB003 +#define AL_EXTENSIONS 0xB004 + +/** Global tweakage. */ + +/** + * Doppler scale. Default 1.0 + */ +#define AL_DOPPLER_FACTOR 0xC000 + +/** + * Tweaks speed of propagation. + */ +#define AL_DOPPLER_VELOCITY 0xC001 + +/** + * Speed of Sound in units per second + */ +#define AL_SPEED_OF_SOUND 0xC003 + +/** + * Distance models + * + * used in conjunction with DistanceModel + * + * implicit: NONE, which disances distance attenuation. + */ +#define AL_DISTANCE_MODEL 0xD000 +#define AL_INVERSE_DISTANCE 0xD001 +#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 +#define AL_LINEAR_DISTANCE 0xD003 +#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 +#define AL_EXPONENT_DISTANCE 0xD005 +#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 + + +/* FIXME: no way to parse both the prototypes and the function pointer typedefs. */ +/* GlueGen requires both in order to recognize a function as dynamically linked. */ +/* #if !defined(AL_NO_PROTOTYPES) */ + +/* + * Renderer State management + */ +AL_API void AL_APIENTRY alEnable( ALenum capability ); + +AL_API void AL_APIENTRY alDisable( ALenum capability ); + +AL_API ALboolean AL_APIENTRY alIsEnabled( ALenum capability ); + + +/* + * State retrieval + */ +AL_API const ALchar* AL_APIENTRY alGetString( ALenum param ); + +AL_API void AL_APIENTRY alGetBooleanv( ALenum param, ALboolean* data ); + +AL_API void AL_APIENTRY alGetIntegerv( ALenum param, ALint* data ); + +AL_API void AL_APIENTRY alGetFloatv( ALenum param, ALfloat* data ); + +AL_API void AL_APIENTRY alGetDoublev( ALenum param, ALdouble* data ); + +AL_API ALboolean AL_APIENTRY alGetBoolean( ALenum param ); + +AL_API ALint AL_APIENTRY alGetInteger( ALenum param ); + +AL_API ALfloat AL_APIENTRY alGetFloat( ALenum param ); + +AL_API ALdouble AL_APIENTRY alGetDouble( ALenum param ); + + +/* + * Error support. + * Obtain the most recent error generated in the AL state machine. + */ +AL_API ALenum AL_APIENTRY alGetError( void ); + + +/* + * Extension support. + * Query for the presence of an extension, and obtain any appropriate + * function pointers and enum values. + */ +AL_API ALboolean AL_APIENTRY alIsExtensionPresent( const ALchar* extname ); + +AL_API ALproc AL_APIENTRY alGetProcAddress( const ALchar* fname ); + +AL_API ALenum AL_APIENTRY alGetEnumValue( const ALchar* ename ); + + +/* + * LISTENER + * Listener represents the location and orientation of the + * 'user' in 3D-space. + * + * Properties include: - + * + * Gain AL_GAIN ALfloat + * Position AL_POSITION ALfloat[3] + * Velocity AL_VELOCITY ALfloat[3] + * Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors) +*/ + +/* + * Set Listener parameters + */ +AL_API void AL_APIENTRY alListenerf( ALenum param, ALfloat value ); + +AL_API void AL_APIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +AL_API void AL_APIENTRY alListenerfv( ALenum param, const ALfloat* values ); + +AL_API void AL_APIENTRY alListeneri( ALenum param, ALint value ); + +AL_API void AL_APIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 ); + +AL_API void AL_APIENTRY alListeneriv( ALenum param, const ALint* values ); + +/* + * Get Listener parameters + */ +AL_API void AL_APIENTRY alGetListenerf( ALenum param, ALfloat* value ); + +AL_API void AL_APIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); + +AL_API void AL_APIENTRY alGetListenerfv( ALenum param, ALfloat* values ); + +AL_API void AL_APIENTRY alGetListeneri( ALenum param, ALint* value ); + +AL_API void AL_APIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); + +AL_API void AL_APIENTRY alGetListeneriv( ALenum param, ALint* values ); + + +/** + * SOURCE + * Sources represent individual sound objects in 3D-space. + * Sources take the PCM data provided in the specified Buffer, + * apply Source-specific modifications, and then + * submit them to be mixed according to spatial arrangement etc. + * + * Properties include: - + * + * Gain AL_GAIN ALfloat + * Min Gain AL_MIN_GAIN ALfloat + * Max Gain AL_MAX_GAIN ALfloat + * Position AL_POSITION ALfloat[3] + * Velocity AL_VELOCITY ALfloat[3] + * Direction AL_DIRECTION ALfloat[3] + * Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE) + * Reference Distance AL_REFERENCE_DISTANCE ALfloat + * Max Distance AL_MAX_DISTANCE ALfloat + * RollOff Factor AL_ROLLOFF_FACTOR ALfloat + * Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat + * Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat + * Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat + * Pitch AL_PITCH ALfloat + * Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE) + * MS Offset AL_MSEC_OFFSET ALint or ALfloat + * Byte Offset AL_BYTE_OFFSET ALint or ALfloat + * Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat + * Attached Buffer AL_BUFFER ALint + * State (Query only) AL_SOURCE_STATE ALint + * Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint + * Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint + */ + +/* Create Source objects */ +AL_API void AL_APIENTRY alGenSources( ALsizei n, ALuint* sources ); + +/* Delete Source objects */ +AL_API void AL_APIENTRY alDeleteSources( ALsizei n, const ALuint* sources ); + +/* Verify a handle is a valid Source */ +AL_API ALboolean AL_APIENTRY alIsSource( ALuint sid ); + +/* + * Set Source parameters + */ +AL_API void AL_APIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value ); + +AL_API void AL_APIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +AL_API void AL_APIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values ); + +AL_API void AL_APIENTRY alSourcei( ALuint sid, ALenum param, ALint value ); + +AL_API void AL_APIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); + +AL_API void AL_APIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values ); + +/* + * Get Source parameters + */ +AL_API void AL_APIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value ); + +AL_API void AL_APIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); + +AL_API void AL_APIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values ); + +AL_API void AL_APIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value ); + +AL_API void AL_APIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); + +AL_API void AL_APIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values ); + + +/* + * Source vector based playback calls + */ + +/* Play, replay, or resume (if paused) a list of Sources */ +AL_API void AL_APIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids ); + +/* Stop a list of Sources */ +AL_API void AL_APIENTRY alSourceStopv( ALsizei ns, const ALuint *sids ); + +/* Rewind a list of Sources */ +AL_API void AL_APIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids ); + +/* Pause a list of Sources */ +AL_API void AL_APIENTRY alSourcePausev( ALsizei ns, const ALuint *sids ); + +/* + * Source based playback calls + */ + +/* Play, replay, or resume a Source */ +AL_API void AL_APIENTRY alSourcePlay( ALuint sid ); + +/* Stop a Source */ +AL_API void AL_APIENTRY alSourceStop( ALuint sid ); + +/* Rewind a Source (set playback postiton to beginning) */ +AL_API void AL_APIENTRY alSourceRewind( ALuint sid ); + +/* Pause a Source */ +AL_API void AL_APIENTRY alSourcePause( ALuint sid ); + +/* + * Source Queuing + */ +AL_API void AL_APIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids ); + +AL_API void AL_APIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids ); + + +/** + * BUFFER + * Buffer objects are storage space for sample data. + * Buffers are referred to by Sources. One Buffer can be used + * by multiple Sources. + * + * Properties include: - + * + * Frequency (Query only) AL_FREQUENCY ALint + * Size (Query only) AL_SIZE ALint + * Bits (Query only) AL_BITS ALint + * Channels (Query only) AL_CHANNELS ALint + */ + +/* Create Buffer objects */ +AL_API void AL_APIENTRY alGenBuffers( ALsizei n, ALuint* buffers ); + +/* Delete Buffer objects */ +AL_API void AL_APIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers ); + +/* Verify a handle is a valid Buffer */ +AL_API ALboolean AL_APIENTRY alIsBuffer( ALuint bid ); + +/* Specify the data to be copied into a buffer */ +AL_API void AL_APIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); + +/* + * Set Buffer parameters + */ +AL_API void AL_APIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value ); + +AL_API void AL_APIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +AL_API void AL_APIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values ); + +AL_API void AL_APIENTRY alBufferi( ALuint bid, ALenum param, ALint value ); + +AL_API void AL_APIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); + +AL_API void AL_APIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values ); + +/* + * Get Buffer parameters + */ +AL_API void AL_APIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value ); + +AL_API void AL_APIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); + +AL_API void AL_APIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values ); + +AL_API void AL_APIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value ); + +AL_API void AL_APIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); + +AL_API void AL_APIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values ); + + +/* + * Global Parameters + */ +AL_API void AL_APIENTRY alDopplerFactor( ALfloat value ); + +AL_API void AL_APIENTRY alDopplerVelocity( ALfloat value ); + +AL_API void AL_APIENTRY alSpeedOfSound( ALfloat value ); + +AL_API void AL_APIENTRY alDistanceModel( ALenum distanceModel ); + +/* FIXME: see above */ +/* #else */ /* AL_NO_PROTOTYPES */ + +typedef void (AL_APIENTRY *LPALENABLE)( ALenum capability ); +typedef void (AL_APIENTRY *LPALDISABLE)( ALenum capability ); +typedef ALboolean (AL_APIENTRY *LPALISENABLED)( ALenum capability ); +typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)( ALenum param ); +typedef void (AL_APIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data ); +typedef void (AL_APIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data ); +typedef void (AL_APIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data ); +typedef void (AL_APIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data ); +typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)( ALenum param ); +typedef ALint (AL_APIENTRY *LPALGETINTEGER)( ALenum param ); +typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)( ALenum param ); +typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)( ALenum param ); +typedef ALenum (AL_APIENTRY *LPALGETERROR)( void ); +typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname ); +typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)( const ALchar* fname ); +typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)( const ALchar* ename ); +typedef void (AL_APIENTRY *LPALLISTENERF)( ALenum param, ALfloat value ); +typedef void (AL_APIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (AL_APIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values ); +typedef void (AL_APIENTRY *LPALLISTENERI)( ALenum param, ALint value ); +typedef void (AL_APIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (AL_APIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values ); +typedef void (AL_APIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value ); +typedef void (AL_APIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); +typedef void (AL_APIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values ); +typedef void (AL_APIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value ); +typedef void (AL_APIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); +typedef void (AL_APIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values ); +typedef void (AL_APIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources ); +typedef void (AL_APIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources ); +typedef ALboolean (AL_APIENTRY *LPALISSOURCE)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value); +typedef void (AL_APIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (AL_APIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values ); +typedef void (AL_APIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value); +typedef void (AL_APIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (AL_APIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values ); +typedef void (AL_APIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value ); +typedef void (AL_APIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +typedef void (AL_APIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values ); +typedef void (AL_APIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value ); +typedef void (AL_APIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +typedef void (AL_APIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values ); +typedef void (AL_APIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCEPLAY)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCESTOP)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEREWIND)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEPAUSE)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids ); +typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids ); +typedef void (AL_APIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers ); +typedef void (AL_APIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers ); +typedef ALboolean (AL_APIENTRY *LPALISBUFFER)( ALuint bid ); +typedef void (AL_APIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); +typedef void (AL_APIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value); +typedef void (AL_APIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (AL_APIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values ); +typedef void (AL_APIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value); +typedef void (AL_APIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (AL_APIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values ); +typedef void (AL_APIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value ); +typedef void (AL_APIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +typedef void (AL_APIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values ); +typedef void (AL_APIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value ); +typedef void (AL_APIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +typedef void (AL_APIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values ); +typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)( ALfloat value ); +typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)( ALfloat value ); +typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)( ALfloat value ); +typedef void (AL_APIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel ); + +/* FIXME: see above */ +/* #endif */ /* AL_NO_PROTOTYPES */ + +#if TARGET_OS_MAC + #pragma export off +#endif + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +#endif /* AL_AL_H */ diff --git a/make/stub_includes/openal/alc.h b/make/stub_includes/openal/alc.h new file mode 100755 index 0000000..0c50a88 --- /dev/null +++ b/make/stub_includes/openal/alc.h @@ -0,0 +1,277 @@ +#ifndef AL_ALC_H +#define AL_ALC_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(_WIN32) && !defined(_XBOX) + /* _OPENAL32LIB is deprecated */ + #if defined(AL_BUILD_LIBRARY) || defined (_OPENAL32LIB) + #define ALC_API __declspec(dllexport) + #else + #define ALC_API __declspec(dllimport) + #endif +#else + #define ALC_API extern +#endif + +#if defined(_WIN32) + #define ALC_APIENTRY __cdecl +#else + #define ALC_APIENTRY +#endif + +#if TARGET_OS_MAC + #pragma export on +#endif + +/* The ALCAPI, and ALCAPIENTRY macros are deprecated, but are included for applications porting code + from AL 1.0 */ +#define ALCAPI ALC_API +#define ALCAPIENTRY ALC_APIENTRY + +#define ALC_VERSION_0_1 1 + +typedef struct ALCdevice_struct ALCdevice; +typedef struct ALCcontext_struct ALCcontext; + + +/** 8-bit boolean */ +typedef char ALCboolean; + +/** character */ +typedef char ALCchar; + +/** signed 8-bit 2's complement integer */ +typedef char ALCbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALCubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALCshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALCushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALCint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALCuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALCsizei; + +/** enumerated 32-bit value */ +typedef int ALCenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALCfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALCdouble; + +/** void type (for opaque pointers only) */ +typedef void ALCvoid; + + +/* Enumerant values begin at column 50. No tabs. */ + +/* bad value */ +#define ALC_INVALID 0 + +/* Boolean False. */ +#define ALC_FALSE 0 + +/* Boolean True. */ +#define ALC_TRUE 1 + +/** + * followed by <int> Hz + */ +#define ALC_FREQUENCY 0x1007 + +/** + * followed by <int> Hz + */ +#define ALC_REFRESH 0x1008 + +/** + * followed by AL_TRUE, AL_FALSE + */ +#define ALC_SYNC 0x1009 + +/** + * followed by <int> Num of requested Mono (3D) Sources + */ +#define ALC_MONO_SOURCES 0x1010 + +/** + * followed by <int> Num of requested Stereo Sources + */ +#define ALC_STEREO_SOURCES 0x1011 + +/** + * errors + */ + +/** + * No error + */ +#define ALC_NO_ERROR ALC_FALSE + +/** + * No device + */ +#define ALC_INVALID_DEVICE 0xA001 + +/** + * invalid context ID + */ +#define ALC_INVALID_CONTEXT 0xA002 + +/** + * bad enum + */ +#define ALC_INVALID_ENUM 0xA003 + +/** + * bad value + */ +#define ALC_INVALID_VALUE 0xA004 + +/** + * Out of memory. + */ +#define ALC_OUT_OF_MEMORY 0xA005 + + +/** + * The Specifier string for default device + */ +#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 +#define ALC_DEVICE_SPECIFIER 0x1005 +#define ALC_EXTENSIONS 0x1006 + +#define ALC_MAJOR_VERSION 0x1000 +#define ALC_MINOR_VERSION 0x1001 + +#define ALC_ATTRIBUTES_SIZE 0x1002 +#define ALC_ALL_ATTRIBUTES 0x1003 + +/** + * Capture extension + */ +#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 +#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 +#define ALC_CAPTURE_SAMPLES 0x312 + + +/* FIXME: no way to parse both the prototypes and the function pointer typedefs. */ +/* GlueGen requires both in order to recognize a function as dynamically linked. */ +/* #if !defined(ALC_NO_PROTOTYPES) */ + +/* + * Context Management + */ +ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist ); + +ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context ); + +ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context ); + +ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context ); + +ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context ); + +ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( ALCvoid ); + +ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context ); + + +/* + * Device Management + */ +ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename ); + +ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device ); + + +/* + * Error support. + * Obtain the most recent Context error + */ +ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device ); + + +/* + * Extension support. + * Query for the presence of an extension, and obtain any appropriate + * function pointers and enum values. + */ +ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname ); + +ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname ); + +ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname ); + + +/* + * Query functions + */ +ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param ); + +ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data ); + + +/* + * Capture functions + */ +ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); + +ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device ); + +ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device ); + +ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device ); + +ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + +/* FIXME: see above */ +/* #else */ /* ALC_NO_PROTOTYPES */ + +typedef ALCcontext * (ALC_APIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist); +typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context ); +typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context ); +typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context ); +typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context ); +typedef ALCcontext * (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)( ALCvoid ); +typedef ALCdevice * (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context ); +typedef ALCdevice * (ALC_APIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename ); +typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device ); +typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)( ALCdevice *device ); +typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname ); +typedef void * (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname ); +typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); +typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); +typedef void (ALC_APIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); +typedef ALCdevice * (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); +typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device ); +typedef void (ALC_APIENTRY *LPALCCAPTURESTART)( ALCdevice *device ); +typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)( ALCdevice *device ); +typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + +/* FIXME: see above */ +/* #endif */ /* ALC_NO_PROTOTYPES */ + +#if TARGET_OS_MAC + #pragma export off +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* AL_ALC_H */ diff --git a/make/stub_includes/openal/alut.h b/make/stub_includes/openal/alut.h new file mode 100755 index 0000000..7a33ccb --- /dev/null +++ b/make/stub_includes/openal/alut.h @@ -0,0 +1,68 @@ +#ifndef _AL_ALUT_H +#define _AL_ALUT_H + +#include <al.h> + +#if defined(_WIN32) && !defined(_XBOX) && 0 + #if defined (_OPENAL32LIB) + #define ALUTAPI __declspec(dllexport) + #else + #define ALUTAPI __declspec(dllimport) + #endif +#else + #define ALUTAPI extern +#endif + +#if defined(_WIN32) + #define ALUTAPIENTRY __cdecl +#else + #define ALUTAPIENTRY +#endif + +#if TARGET_OS_MAC + #pragma export on +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +#if !defined(ALUT_NO_PROTOTYPES) + +ALUTAPI void ALUTAPIENTRY alutInit( int *argc, char *argv[] ); +ALUTAPI void ALUTAPIENTRY alutExit( void ); + +#if defined(MACINTOSH_AL) +/* Windows and Linux versions have a loop parameter, Macintosh doesn't */ +ALUTAPI void ALUTAPIENTRY alutLoadWAVFile( const ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq ); +ALUTAPI void ALUTAPIENTRY alutLoadWAVMemory( const ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq ); +#else +ALUTAPI void ALUTAPIENTRY alutLoadWAVFile( const ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop ); +ALUTAPI void ALUTAPIENTRY alutLoadWAVMemory( const ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop ); +#endif +ALUTAPI void ALUTAPIENTRY alutUnloadWAV( ALenum format, ALvoid *data, ALsizei size, ALsizei freq ); + +#else /* ALUT_NO_PROTOTYPES */ + +ALUTAPI void (ALUTAPIENTRY *alutInit)( int *argc, char *argv[] ); +ALUTAPI void (ALUTAPIENTRY *alutExit)( void ); +#if defined(MACINTOSH_AL) +ALUTAPI void (ALUTAPIENTRY *alutLoadWAVFile)( const ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq ); +ALUTAPI void (ALUTAPIENTRY *alutLoadWAVMemory)( const ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq ); +#else +ALUTAPI void (ALUTAPIENTRY *alutLoadWAVFile)( const ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop ); +ALUTAPI void (ALUTAPIENTRY *alutLoadWAVMemory)( const ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop ); +#endif +ALUTAPI void (ALUTAPIENTRY *alutUnloadWAV)( ALenum format, ALvoid *data, ALsizei size, ALsizei freq ); + +#endif /* ALUT_NO_PROTOTYPES */ + +#if TARGET_OS_MAC + #pragma export off +#endif + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/make/stub_includes/openal/eax.h b/make/stub_includes/openal/eax.h new file mode 100644 index 0000000..bf0d9b6 --- /dev/null +++ b/make/stub_includes/openal/eax.h @@ -0,0 +1,32 @@ +#ifndef _EAX_H +#define _EAX_H + +#ifdef _WIN32 +#include "windows.h" +#endif + +#include "al.h" + +#ifdef _WIN32 +DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties, + 0x306a6a8, + 0xb224, + 0x11d2, + 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7, 0x22); + +DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties, + 0x306a6a7, + 0xb224, + 0x11d2, + 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7, 0x22); +#endif + +#ifdef _WIN32 +typedef ALenum (*EAXSet)(const GUID*, ALuint, ALuint, ALvoid*, ALuint); +typedef ALenum (*EAXGet)(const GUID*, ALuint, ALuint, ALvoid*, ALuint); + +extern EAXSet eaxSet; +extern EAXGet eaxGet; +#endif + +#endif /* _EAX_H */ diff --git a/make/validate-properties.xml b/make/validate-properties.xml new file mode 100755 index 0000000..8fc9e33 --- /dev/null +++ b/make/validate-properties.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + - A validator for all of the user-defined properties. It will be called + - from build.xml in the "init" task. + --> +<project name="Configuration validator" default="validate"> + + <!-- ================================================================== --> + <!-- + - Ensure that "antlr.jar" is set. + --> + <target name="antlr.jar.validate" unless="antlr.jar"> + <fail> + + ***************************************************************** + ** The property "antlr.jar" was not set in the JOAL properties ** + ** file ** + ** "${user.properties.file}" ** + ** (or this file was not found). ** + ** ** + ** Please set "antlr.jar" to to the full path of the ANTLR jar ** + ** including the jar itself. ** + ***************************************************************** + </fail> + </target> + + <!-- + - Ensure that "java.home.dir" is set. + - NOTE: "java.home" is an internal property for ANT that is not + - typically set to what the build needs it to be. + --> + <target name="java.home.dir.validate" unless="java.home.dir"> + <fail> + + ************************************************************* + ** The property "java.home.dir" was not set in the JOGL ** + ** properties file ** + ** "${user.properties.file}" ** + ** (or this file was not found). ** + ** ** + ** Please set "java.home.dir" to your JAVA_HOME directory. ** + ************************************************************* + </fail> + </target> + + <!-- + - Make sure that jogl.jar is not on the CLASSPATH; this can cause + - builds to fail since if this Java process has the jar file open + - we can not overwrite it. + --> + <target name="test.for.jogl.jar"> + <available property="jogl.jar.on.class.path" classname="net.java.games.jogl.GL" /> + </target> + <target name="java.class.path.validate" depends="test.for.jogl.jar" if="jogl.jar.on.class.path"> + <fail> + + ****************************************************************** + ** Your CLASSPATH environment variable appears to be set (some ** + ** JOGL classes are currently visible to the build.) This can ** + ** cause the build to fail. Please unset your CLASSPATH ** + ** variable and restart the build. ** + ****************************************************************** + </fail> + </target> + + <!-- ================================================================== --> + <!-- + - Validate the required properties + --> + <target name="validate" depends="antlr.jar.validate, java.home.dir.validate, java.class.path.validate" + description="Validate required properties" /> + +</project> diff --git a/src/java/net/java/games/joal/AL.java b/src/java/net/java/games/joal/AL.java deleted file mode 100644 index ab1c66b..0000000 --- a/src/java/net/java/games/joal/AL.java +++ /dev/null @@ -1,1260 +0,0 @@ -/* -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal; - -import java.nio.ByteBuffer; - - -/** - * This class contains the core OpenAL functions - * - * @author Athomas Goldberg - */ -public interface AL extends ALConstants { - // AL_BUFFER RELATED METHODS - - /** - * This method generates one or more buffers. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGenBuffers(ALsizei n, ALuint *buffers);</pre> - * - * @param n the number of buffers to be generated - * @param buffers an IntBuffer to contain the ids of the new buffers. - * IntBuffer must be a direct, non-null buffer, and buffer capacity - * must be equal to or greater than the number of buffers to be - * generated. Use BufferUtils.newIntBuffer(int capacity) to create - * an appropriate buffer. - */ -// public void alGenBuffers(int n, IntBuffer buffers); - - /** - * This method generates one or more buffers. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGenBuffers(ALsizei n, ALuint *buffers);</pre> - * - * @param n the number of buffers to be generated - * @param buffers an int array to hold the IDs of the new buffers. Array - * must be non-null, and length must be equal to or greater than - * the number of buffers to be generated. - */ - public void alGenBuffers(int n, int[] buffers); - - /** - * This method deletes one or more buffers. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alDeleteBuffers(ALsizei n, ALuint *buffers);</pre> - * - * @param n number of buffers to be deleted. - * @param buffers a direct, non-null IntBuffer containing buffer names to - * be deleted. - */ -// public void alDeleteBuffers(int n, IntBuffer buffers); - - /** - * This method deletes one or more buffers. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alDeleteBuffers(ALsizei n, ALuint *buffers);</pre> - * - * @param n number of buffers to be deleted. - * @param buffers a direct, non-null IntBuffer containing buffer names to - * be deleted. - */ - public void alDeleteBuffers(int n, int[] buffers); - - /** - * This method tests if a buffer id is valid. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALboolean alIsBuffer(ALuint buffer);</pre> - * - * @param bufferID the name of the buffer. - * - * @return true if the buffer ID is valid - */ - public boolean alIsBuffer(int bufferID); - - /** - * This method fills a buffer with audio data. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alBufferData(ALuint buffer, ALenum format, ALvoid *data, ALsizei size, ALsizei freq);</pre> - * - * @param bufferID name of buffer to be filled with data - * @param format the format type from among the following: AL_MONO8, AL_MONO16, - * AL_STEREO8, AL_STEREO16. - * @param data the audio data, must be non-null array - * @param frequency the frequency of the audio data - */ - public void alBufferData( - int bufferID, - int format, - byte[] data, - int size, - int frequency - ); - - /** - * This method fills a buffer with audio data. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alBufferData(ALuint buffer, ALenum format, ALvoid *data, ALsizei size, ALsizei freq);</pre> - * - * @param bufferID name of buffer to be filled with data - * @param format the format type from among the following: AL_MONO8, AL_MONO16, - * AL_STEREO8, AL_STEREO16. - * @param data the audio data Must be non-null, direct ByteBuffer - * @param frequency the frequency of the audio data - */ - public void alBufferData( - int bufferID, - int format, - ByteBuffer data, - int size, - int frequency - ); - - /** - * This method retrieves a floating point property of a buffer. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGetBufferf(ALuint buffer, ALuint pname, float value);</pre> - * <br><br> - * - * @param bufferID Buffer ID whose attribute is being retrieved - * @param pname the name of the attribute to be retrieved - * @param retValue a single-element array to hold the retrieved value. - */ - public void alGetBufferf(int bufferID, int pname, float[] retValue); - - /** - * This method retrieves a floating point property of a buffer. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGetBufferf(ALuint buffer, ALuint pname, ALfloat *value);</pre> - * - * @param bufferID Buffer ID whose attribute is being retrieved - * @param pname the name of the attribute to be retrieved - * @param retValue a single-element buffer to hold the retrieved value. - */ -// public void alGetBufferf(int bufferID, int pname, FloatBuffer retValue); - - /** - * This method retrieves a floating point property of a buffer. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGetBufferf(ALuint buffer, ALuint pname, ALfloat *value);</pre> - * - * @param bufferID Buffer ID whose attribute is being retrieved - * @param pname the name of the attribute to be retrieved - * - * @return retValue the retrieved value. - */ - public float alGetBufferf(int bufferID, int pname); - - /** - * This method retrieves a integer property of a buffer. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGetBufferi(ALuint buffer, ALuint pname, ALint *value);</pre> - * - * @param bufferID Buffer ID whose attribute is being retrieved - * @param pname the name of the attribute to be retrieved - * @param retValue a single-element array to hold the retrieved value. - */ - public void alGetBufferi(int bufferID, int pname, int[] retValue); - - /** - * This method retrieves a integer property of a buffer. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGetBufferi(ALuint buffer, ALuint pname, ALint value);</pre> - * - * @param bufferID Buffer ID whose attribute is being retrieved - * @param pname the name of the attribute to be retrieved - * @param retValue a single-element IntBuffer to hold the retrieved value. - */ -// public void alGetBufferi(int bufferID, int pname, IntBuffer retValue); - - /** - * This method retrieves a integer property of a buffer. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGetBufferi(ALuint buffer, ALuint pname, ALint *value);</pre> - * - * @param bufferID Buffer ID whose attribute is being retrieved - * @param pname the name of the attribute to be retrieved - * - * @return retValue the retrieved value. - */ - public int alGetBufferi(int bufferID, int pname); - - // SOURCE RELATED METHODS - - /** - * This method generates one or more sources. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGenSources(ALsizei n, ALuint *sources);</pre> - * - * @param numSources the number of sources to be generated - * @param sources an integer array to hold the ids of the new sources - */ - public void alGenSources(int numSources, int[] sources); - - /** - * This method generates one or more sources. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alGenSources(ALsizei n, ALuint *sources);</pre> - * - * @param numSources the number of sources to be generated - * @param sources an IntBuffer to hold the IDs of the new sources - */ -// public void alGenSources(int numSources, IntBuffer sources); - - /** - * This method deletes one or more sources. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alDeleteSources(ALsizei n, ALuint *sources);</pre> - * - * @param numSources the number of sources to be generated - * @param sources an int array containing the IDs of the sources to be - * deleted - */ - public void alDeleteSources(int numSources, int[] sources); - - /** - * This method deletes one or more sources. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alDeleteSources(ALsizei n, ALuint *sources);</pre> - * - * @param numSources the number of sources to be generated - * @param sources an IntBuffer containing the IDs of the sources to be - * deleted - */ -// public void alDeleteSources(int numSources, IntBuffer sources); - - /** - * This method tests if a source ID is valid. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alDeleteSources(ALsizei n, ALuint *sources);</pre> - * - * @param sourceID a source ID to be tested for validity - * - * @return true if the source ID is valid, or false if the source ID is not - * valid - */ - public boolean alIsSource(int sourceID); - - /** - * This method sets a floating point property of a source. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid alSourcei(ALuint sourceID, ALuint pname, ALfloat value);</pre> - * - * @param sourceID source ID whose attribute is being set - * @param pname the name of the attribute to set: - * <pre> - * AL_PITCH - * AL_GAIN - * AL_MAX_DISTANCE - * AL_ROLLOFF_FACTOR - * AL_REFERENCE_DISTANCE - * AL_MIN_GAIN - * AL_MAX_GAIN - * AL_CONE_OUTER_GAIN - * </pre> - * @param value the value to set the attribute to - */ - public void alSourcef(int sourceID, int pname, float value); - - /** - * This method sets a floating-point vector property of a source. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid aSourcefv(ALuint source, ALenum pname, ALfloat *values)</pre> - * - * @param sourceID source ID whose attribute is being set - * @param pname the nameof the attribute to set: - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_DIRECTION - * </pre> - * @param value a float array containing the vector to set the attribute to. - */ - public void alSourcefv(int sourceID, int pname, float[] value); - - /** - * This method sets a floating-point vector property of a source. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid aSourcefv(ALuint source, ALenum pname, ALfloat *values)</pre> - * - * @param sourceID source ID whose attribute is being set - * @param pname the nameof the attribute to set: - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_DIRECTION - * </pre> - * @param value direct FloatBuffer containing the vector to set the attribute to. - */ -// public void alSourcefv(int sourceID, int pname, FloatBuffer value); - - - /** - * This method sets a source property requiring three floating point values. <br> - * <br> - * <b>Interface to C lanuage function:</b> - * <pre>ALvoid alSource3f (ALuint source, ALenum pname, ALfloat v1, ALfloat v2, ALfloat v3);</pre> - * - * @param sourceID the id of the source whose atribute is being set. - * @param pname the name of the attribute being set. - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_DIRECTION - * </pre> - * @param v1 the first float value which the attribute will be set to - * @param v2 the second float value which the attribute will be set to - * @param v3 the third float value which the attribute will be set to - */ - public void alSource3f( - int sourceID, - int pname, - float v1, - float v2, - float v3 - ); - - /** - * This method sets a integer property of a source. <br> - * <br> - * <b>Interface to C language function:</b> - * <pre>ALvoid aSourcei(ALuint source, ALenum pname, ALint value)</pre> - * - * @param sourceID source ID whose attribute is being set - * @param pname the nameof the attribute to set: - * <pre> - * AL_SOURCE_RELATIVE - * AL_LOOPING - * AL_BUFFER - * AL_SOURCE_STATE - * </pre> - * @param value the int value to set the attribute to. - */ - public void alSourcei(int sourceID, int pname, int value); - - /** - * This methof retrieves a floating point property of a source. <br> - * <br> - * <b>Interface to C language unction:</b> - * <pre>ALvoid alGetSourcef(ALuint source, ALenum pname, ALfloat *value);</pre> - * - * @param sourceID the id of the source whose attribute is being retrieved. - * @param pname he name of the attribute to retrieve - * <pre> - * AL_PITCH - * AL_GAIN - * AL_MIN_GAIN - * AL_MAX_GAIN - * AL_MAX_DISTANCE - * AL_ROLLOFF_DISTANCE - * AL_CONE_OUTER_GAIN - * AL_CONE_INNER_ANGLE - * AL_CONE_OUTER_ANGLE - * AL_REFERENCE_DISTANCE - * </pre> - * @param retValue a single-element float array to hold the value being retrieved. - */ - public void alGetSourcef(int sourceID, int pname, float[] retValue); - - /** - * This methof retrieves a floating point property of a source. <br> - * <br> - * <b>Interface to C language unction:</b> - * <pre>ALvoid alGetSourcef(ALuint source, ALenum pname, ALfloat *value);</pre> - * - * @param sourceID the id of the source whose attribute is being retrieved. - * @param pname he name of the attribute to retrieve - * <pre> - * AL_PITCH - * AL_GAIN - * AL_MIN_GAIN - * AL_MAX_GAIN - * AL_MAX_DISTANCE - * AL_ROLLOFF_DISTANCE - * AL_CONE_OUTER_GAIN - * AL_CONE_INNER_ANGLE - * AL_CONE_OUTER_ANGLE - * AL_REFERENCE_DISTANCE - * </pre> - * @param buffer a direct FloatBuffer to hold the value being retrieved. - */ -// public void alGetSourcef(int sourceID, int pname, FloatBuffer buffer); - - /** - * This methof retrieves a floating point property of a source. <br> - * <br> - * <b>Interface to C language unction:</b> - * <pre>ALvoid alGetSourcef(ALuint source, ALenum pname, ALfloat *value);</pre> - * - * @param sourceID the id of the source whose attribute is being retrieved. - * @param pname he name of the attribute to retrieve - * <pre> - * AL_PITCH - * AL_GAIN - * AL_MIN_GAIN - * AL_MAX_GAIN - * AL_MAX_DISTANCE - * AL_ROLLOFF_DISTANCE - * AL_CONE_OUTER_GAIN - * AL_CONE_INNER_ANGLE - * AL_CONE_OUTER_ANGLE - * AL_REFERENCE_DISTANCE - * </pre> - * @return the floating point value being retrieved. - */ - public float alGetSourcef(int sourceID, int pname); - - /** - * This method retrieves a floating point vector property of a source. <br> - * <br> - * <b>Interface to C language unction:</b> - * <pre>ALvoid alGetSourcef(ALuint source, ALenum pname, ALfloat *value);</pre> - * - * - * @param sourceID the id of the source whose attribute is being retrieved. - * @param pname the name of the attribute to retrieve - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_DIRECTION - * </pre> - * @param value a direct FloatBuffer to hold the value being retrieved - */ -// public void alGetSourcefv(int sourceID, int pname, FloatBuffer value); - - /** - * This method retrieves a floating point vector property of a source. <br> - * <br> - * <b>Interface to C language unction:</b> - * <pre>ALvoid alGetSourcef(ALuint source, ALenum pname, ALfloat *value);</pre> - * - * - * @param sourceID the id of the source whose attribute is being retrieved. - * @param pname the name of the attribute to retrieve - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_DIRECTION - * </pre> - * @param retValue a float array to hold the value being retrieved - */ - public void alGetSourcefv(int sourceID, int pname, float[] retValue); - - /** - * This method retrieves an integer property of a source. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetSourcei(ALuint source, Alenum pname, ALint *value);</pre> - * - * @param sourceID source id whose attribute is being retrieved. - * @param pname the name of the attribute being retrieved. - * <pre> - * AL_SOURCE_RELATIVE - * AL_BUFFER - * AL_LOOPING - * AL_SOURCE_STATE - * AL_BUFFERS_QUEUED - * AL_BUFFERS_PROCESSED - * </pre> - * @param retValue an int array to hold the value being retrieved - */ - public void alGetSourcei(int sourceID, int pname, int[] retValue); - - /** - * This method retrieves an integer property of a source. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetSourcei(ALuint source, Alenum pname, ALint *value);</pre> - * - * @param sourceID source id whose attribute is being retrieved. - * @param pname the name of the attribute being retrieved. - * <pre> - * AL_SOURCE_RELATIVE - * AL_BUFFER - * AL_LOOPING - * AL_SOURCE_STATE - * AL_BUFFERS_QUEUED - * AL_BUFFERS_PROCESSED - * </pre> - * @param retValue a direct IntBuffer to hold the value being retrieved - */ -// public void alGetSourcei(int sourceID, int pname, IntBuffer retValue); - - /** - * This method retrieves an integer property of a source. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetSourcei(ALuint source, Alenum pname, ALint *value);</pre> - * - * @param sourceID source id whose attribute is being retrieved. - * @param pname the name of the attribute being retrieved. - * <pre> - * AL_SOURCE_RELATIVE - * AL_BUFFER - * AL_LOOPING - * AL_SOURCE_STATE - * AL_BUFFERS_QUEUED - * AL_BUFFERS_PROCESSED - * </pre> - * @return the value being retrieved - */ - public int alGetSourcei(int sourceID, int pname); - - /** - * This method plays a source. <br> - * <br> - *<b>Interface to C Language function:</b> - *<pre>ALvoid alSourcePlay(ALuint source);</pre> - * - * @param sourceID the id of the source to be played - */ - public void alSourcePlay(int sourceID); - - /** - * This method plays a set of sources. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alSourcePlayv(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be plaed - * @param sourceIDs a direct IntBuffer containing the ids of the sources to be played. - */ -// public void alSourcePlayv(int numSources, IntBuffer sourceIDs); - - /** - * This method plays a set of sources. <br> - * <br> - * <pre>ALvoid alSourcePlayv(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be plaed - * @param sourceIDs an array containing the ids of the sources to be played. - */ - public void alSourcePlayv(int numSources, int[] sourceIDs); - - /** - * This method pauses a source. <br> - * <br> - *<b>Interface to C Language function:</b> - *<pre>ALvoid alSourcePause(ALuint source);</pre> - * - * @param sourceID the id of the source to be paused - */ - public void alSourcePause(int sourceID); - - /** - * This method pauses a set of sources. <br> - * <br> - * <pre>ALvoid alSourcePausev(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be paused - * @param sourceIDs an array containing the ids of the sources to be paused. - */ - public void alSourcePausev(int numSources, int[] sourceIDs); - - /** - * This method pauses a set of sources. <br> - * <br> - * <pre>ALvoid alSourcePausev(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be paused - * @param sourceIDs an IntBuffer containing the ids of the sources to be paused. - */ -// public void alSourcePausev(int numSources, IntBuffer sourceIDs); - - /** - * This method stops a source. <br> - * <br> - *<b>Interface to C Language function:</b> - *<pre>ALvoid alSourceStop(ALuint source);</pre> - * - * @param sourceID the id of the source to be stopped - */ - public void alSourceStop(int sourceID); - - /** - * This method stops a set of sources. <br> - * <br> - * <pre>ALvoid alSourceStopv(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be stopped - * @param sourceIDs an array containing the ids of the sources to be stopped. - */ - public void alSourceStopv(int numSources, int[] sourceIDs); - - /** - * This method stops a set of sources. <br> - * <br> - * <pre>ALvoid alSourceStopv(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be stopped - * @param sourceIDs a direct IntBuffer containing the ids of the sources to be stopped. - */ -// public void alSourceStopv(int numSources, IntBuffer sourceIDs); - - /** - * This method rewinds a source. <br> - * <br> - *<b>Interface to C Language function:</b> - *<pre>ALvoid alSourceRewind(ALuint source);</pre> - * - * @param sourceID the id of the source to be rewound - */ - public void alSourceRewind(int sourceID); - - /** - * This method rewinds a set of sources. <br> - * <br> - *<b>Interface to C Language function:</b> - * <pre>ALvoid alSourceRewindv(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be rewound - * @param sourceIDs an array containing the ids of the sources to be rewound. - */ - public void alSourceRewindv(int numSources, int[] sourceIDs); - - /** - * This method rewinds a set of sources. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alSourceRewindv(Alsizei, ALuint *sources);</pre> - * - * @param numSources the number of sources to be rewound - * @param sourceIDs a direct IntBuffercontaining the ids of the sources to be rewound. - */ -// public void alSourceRewindv(int numSources, IntBuffer sourceIDs); - - /** - * This method queues a set of buffers on a source. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>alSourceQueueBuffers(ALuint source, ALsizei n, ALuint *buffers);</pre> - * - * @param sourceID the id of the source to queue buffers onto - * @param numBuffers the number of buffers to be queued - * @param bufferIDs an array containing the list of buffer ids to be queued - */ - public void alSourceQueueBuffers( - int sourceID, - int numBuffers, - int[] bufferIDs - ); - - /** - * This method queues a set of buffers on a source. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>alSourceQueueBuffers(ALuint source, ALsizei n, ALuint *buffers);</pre> - * - * @param sourceID the id of the source to queue buffers onto - * @param numBuffers the number of buffers to be queued - * @param bufferIDs a direct IntBuffer containing the list of buffer ids to be queued - *//* - public void alSourceQueueBuffers( - int sourceID, - int numBuffers, - IntBuffer bufferIDs - );*/ - - /** - * This method unqueues a set of buffers attached to a source. - * The unqueue operation will only take place if all <i>n</i> buffers - * can be removed from the queue<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alSourceUnqueueBuffers(ALuint source, ALsizei n, ALuint *buffers);</pre> - * - * @param source the id of the source to unqueue buffers from - * @param numBuffers the number of buffers to be unqueued - * @param bufferIDs an array of buffer ids to be unqueued - */ - public void alSourceUnqueueBuffers( - int source, - int numBuffers, - int[] bufferIDs - ); - - /** - * This method unqueues a set of buffers attached to a source. - * The unqueue operation will only take place if all <i>n</i> buffers - * can be removed from the queue<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alSourceUnqueueBuffers(ALuint source, ALsizei n, ALuint *buffers);</pre> - * - * @param source the id of the source to unqueue buffers from - * @param numBuffers the number of buffers to be unqueued - * @param bufferIDs a direct IntBuffer of buffer ids to be unqueued - *//* - public void alSourceUnqueueBuffers( - int source, - int numBuffers, - IntBuffer bufferIDs - );*/ - - // LISTENER RELATED METHODS - - - /** - * This method sets a floating point property for the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alListenerf(ALenum pname, ALfloat value);</pre> - * - * @param pname the name of the attribute to be set - * @param value the value to set the attribute to. - */ - public void alListenerf(int pname, float value); - - /** - * This method sets a listener property requireing 3 floating point values. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alListener3f(ALenum pname, ALfloat v1, ALfloat v2, ALfloat v3);</pre> - * - * @param pname the name of the attribute to be set: - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_ORIENTATION - * </pre> - * @param v1 the first value to set the attribute to - * @param v2 the second value to set the attribute to - * @param v3 the third value to set the attribute to - */ - public void alListener3f(int pname, float v1, float v2, float v3); - - /** - * This method sets a floating point vector property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alListenerfv(ALenum pname, ALfloat *values);</pre> - * - * @param pname the name of the attribute to be set: - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_ORIENTATION - * </pre> - * @param values a float array containng the value to set the attribute to - */ - public void alListenerfv(int pname, float[] values); - - /** - * This method sets a floating point vector property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alListenerfv(ALenum pname, ALfloat *values);</pre> - * - * @param pname the name of the attribute to be set: - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_ORIENTATION - * </pre> - * @param values a direct FloatBuffer containng the value to set the attribute to - */ -// public void alListenerfv(int pname, FloatBuffer values); - - /** - * This method sets an integer property on the listener. - * Note: there are no integer listener attributes at this time.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alListeneri(ALenum pname, ALint value);</pre> - * - * @param pname the name of the attribute to set - * @param value the value to set the attribute to. - */ - public void alListeneri(int pname, int value); - - /** - * This method retrieves a floating point property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListenerf(ALenum pname, ALfloat *value);</pre> - * - * @param pname the name of the attribute to be retrieved: - * <pre> - * AL_GAIN - * </pre> - * @param retValue a single-element array to hold the retrieved value - */ - public void alGetListenerf(int pname, float[] retValue); - - /** - * This method retrieves a floating point property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListenerf(ALenum pname, ALfloat *value);</pre> - * - * @param pname the name of the attribute to be retrieved: - * <pre> - * AL_GAIN - * </pre> - * @param retValue a direct FloatBuffer to hold the retrieved value - */ -// public void alGetListenerf(int pname, FloatBuffer retValue); - - /** - * This method retrieves a floating point property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alListeneri(ALenum pname, ALfloat *value);</pre> - * - * @param pname the name of the attribute to be retrieved: - * <pre> - * AL_GAIN - * </pre> - * @return the retrieved value - */ - public float alGetListenerf(int pname); - - /** - * This method retrieves a 3-element floating point property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListener3f(ALenum pname, ALfloat *v1, ALfloat *v2, ALfloat *v3);</pre> - * - * @param pname the name of the attribute to be retrieved: - * <pre> - * AL_POSITION - * AL_VELOCITY - * </pre> - * - * @param v1 a FloatBuffer to hold the first value - * @param v2 a FloatBuffer to hold the second value - * @param v3 a FloatBuffer to hold the third value - */ -/* public void alGetListener3f( - int pname, - FloatBuffer v1, - FloatBuffer v2, - FloatBuffer v3 - ); -*/ - /** - * This method retrieves a 3-element floating point property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListener3f(ALenum pname, ALfloat *v1, ALfloat *v2, ALfloat *v3);</pre> - * - * @param pname the name of the attribute to be retrieved: - * <pre> - * AL_POSITION - * AL_VELOCITY - * </pre> - * - * @param v1 a single element array to hold the first value - * @param v2 a single element array to hold the second value - * @param v3 a single element array to hold the third value - */ - public void alGetListener3f(int pname, float[] v1, float[] v2, float[] v3); - - /** - * This method retrieves a floating point-vector property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListenerfv(ALenum pname, ALint *value);</pre> - * - * @param pname the nameof the atribute to be retrieved: - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_ORIENTATION - * </pre> - * @param retValue an array to hold the retrieved value - */ - public void alGetListenerfv(int pname, float[] retValue); - - /** - * This method retrieves a floating point-vector property of the listener. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListenerfv(ALenum pname, ALint *value);</pre> - * - * @param pname the nameof the atribute to be retrieved: - * <pre> - * AL_POSITION - * AL_VELOCITY - * AL_ORIENTATION - * </pre> - * @param retValue a FloatBuffer to hold the retrieved value - */ -// public void alGetListenerfv(int pname, FloatBuffer retValue); - - /** - * This method retrieves an integer property of the listener. - * Note: there are no integer listener properties at this time.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListeneri(ALenum pname, ALint *value);</pre> - * - * @param pname the nameof the attribute to be retrieved - * @param retValue an int array to hold the retrieved value. - */ - public void alGetListeneri(int pname, int[] retValue); - - /** - * This method retrieves an integer property of the listener. <br> - * Note: there are no integer listener properties at this time.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListeneri(ALenum pname, ALint *value);</pre> - * - * @param pname the nameof the attribute to be retrieved - * @param retValue an IntBuffer to hold the retrieved value. - */ -// public void alGetListeneri(int pname, IntBuffer retValue); - - /** - * This method retrieves an integer property of the listener. <br> - * Note: there are no integer listener properties at this time.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetListeneri(ALenum pname, ALint *value);</pre> - * - * @param pname the nameof the attribute to be retrieved - * - * @return the retrieved value - */ - public int alGetListeneri(int pname); - - // STATE RELATED METHODS - - /** - * This method enables a feature of the OpenAL driver. Note: at this time - * there are no features to be enabled with this feature.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alDisable(ALenum cpability);</pre> - * - * @param capability the name of the capbility to be enabled. - */ - - public void alEnable(int capability); - - /** - * This method disables a feature of the OpenAL driver. Note: at this time - * there are no features to be disabled with this feature.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alDisable(ALenum cpability);</pre> - * - * @param capability the name of the capbility to be disabled. - */ - public void alDisable(int capability); - - /** - * This method returns a bolean indicating if a specific feature is enabled - * in the OpenAL driver. Note: At this time this function always returns - * false, as there are no capabilities to be enabled<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALboolean alIsEnabled(ALenum cpability);</pre> - * - * @param capability the name of the capability to check - * - * @return true, if the capability is enabled, - * false if the capability is disabled. - */ - public boolean alIsEnabled(int capability); - - /** - * This method returs a boolean OpenAL state. Note: there are no - * boolean state values at this time.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALboolean alGetBoolean(ALenum pname);</pre> - * - * @param pname the state to be queried - * - * @return the state described by pname - */ - public boolean alGetBoolean(int pname); - - /** - * This method returns a double precision loating point OpenAL state. - * Note at the time there are no double stat values.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALdouble alGetDouble(ALEnum pname);</pre> - * - * @param pname the state to be queried - * - * @return the sate described by pname - */ - public double alGetDouble(int pname); - - /** - * This method returns a floating point OpenAL state. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALfoat alGetFloat(ALenum pname);</pre> - * - * @param pname the sateto be queried: - * <pre> - * AL_DOPPLER_FACTOR - * AL_DOPPLER_VELOCITY - * </pre> - * - * @return the state described by pname - */ - public float alGetFloat(int pname); - - /** - * This method returns an integer OpenAL state. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALint alGetInteger(ALenum pname);</pre> - * - * @param pname the name of the state to be queried: - * <pre> - * AL_DISTANCE_MODEL - * </pre> - * @return the state described by pname - */ - public int alGetInteger(int pname); - - // No Boolean Array states at the moment - // public void getBooleanv(int pname, ByteBuffer value); - - /** - * This function retrieves a boolean OpenAL state. Note: at this time - * there are no boolean state variables<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetBooleanv(ALenum pname, ALboolean *value);</pre> - * - * @param pname the name of the state to be retrieved - * @param value a single element array to hold the retrieved state - */ - public void alGetBooleanv(int pname, boolean[] value); - - /** - * This method retrieves a double precision floating point OpenAL state. - * Note: there are no double precision floating point states at this time. - * <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetDoublev(ALenum, ALdouble *value);</pre> - * - * @param pname the state to be retrieved - * @param value a DoubleBuffer to hold the retrieved state - */ -// public void alGetDoublev(int pname, DoubleBuffer value); - - /** - * This method retrieves a double precision floating point OpenAL state. - * Note: there are no double precision floating point states at this time. - * <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetDoublev(ALenum, ALdouble *value);</pre> - * - * @param pname the state to be retrieved - * @param value a single element array to hold the retrieved state - */ - public void alGetDoublev(int pname, double[] value); - - /** - * This method returns a floating point OpenAL state. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetFloatv(ALenum pname, ALfloat *value);</pre> - * - * @param pname the state to be retrieved - * <pre> - * AL_DOPPLER_FACTOR - * AL_DOPPLER_VELOCITY - * </pre> - * @param value a single element FloatBuffer to hold the retrieved value. - */ -// public void alGetFloatv(int pname, FloatBuffer value); - - /** - * This method returns a floating point OpenAL state. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetFloatv(ALenum pname, ALfloat *value);</pre> - * - * @param pname the state to be retrieved - * <pre> - * AL_DOPPLER_FACTOR - * AL_DOPPLER_VELOCITY - * </pre> - * @param value a single element float array to hold the retrieved value. - */ - public void alGetFloatv(int pname, float[] value); - - /** - * This method returns an integer OpenAL state. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetIntegerv(ALenum pname, ALint *data);</pre> - * - * @param pname the state to be returned: - * <pre> - * AL_DISTANCE_MODEL - * </pre> - * @param value a single-element IntBuffer to hold the retrieved value - */ - //public void alGetIntegerv(int pname, IntBuffer value); - - /** - * This method returns an integer OpenAL state. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alGetIntegerv(ALenum pname, ALint *data);</pre> - * - * @param pname the state to be returned: - * <pre> - * AL_DISTANCE_MODEL - * </pre> - * @param value a single-element array to hold the retrieved value - */ - public void alGetIntegerv(int pname, int[] value); - - /** - * This method retrieves an OpenAL string property. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALubyte* alGetString(int pname);</pre> - * - * @param pname the name of the state to be retrieved - * - * @return the retrieved state - */ - public String alGetString(int pname); - - /** - * This method selects the OpenAL distance model. - * The default distance model is AL_INVERSE_DISTANCE<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alDistanceModel(ALenum value);</pre> - * - * @param model the distance model to set: - * <pre> - * AL_NONE - * AL_INVERSE_DISTANCE - * AL_INVERSE_DISTANCE_CLAMPED - * </pre> - */ - public void alDistanceModel(int model); - - /** - * This method selects the OpenAL Doppler factor value. - * The default value is 1.0<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alDopplerFactor(ALfloat value);</pre> - * - * @param value the Doppler scale value to set - */ - public void alDopplerFactor(float value); - - /** - * This method selects the OpenAL Doppler velocity value. - * The default Doppler velocity value is 343.0<b> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alDopplerVelocity(ALfloat value);</pre> - * - * @param value The Doppler velocity value to set. - */ - public void alDopplerVelocity(float value); - - // ERROR RELATED METHODS - - /** - * This method returns the current error state and then clears the - * error state. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALenum alGetError(ALvoid);</pre> - * - * @return the current error state - */ - public int alGetError(); - - // EXTENSION RELATED METHODS - /** - * This ehod tests is a specific extension is available - * for the OpenAL driver. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALboolean alIsExtensionPresent(ALubyte *extName);</pre> - * - * @param extName a string describing the desired extension - * - * @return true if the extension is available, - * false if the extension is not available. - */ - public boolean alIsExtensionPresent(String extName); - - // public Method getProcAddress(String methodName); - /** - * This method returns the enumeration value of an OpenAL enum - * described by a string. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALenum alGetEnumValue(ALubyte *enumName);</pre> - * - * @param enumName a string describing an OpenAL constant - * - * @return the actual constant for the described constant. - */ - public int alGetEnumValue(String enumName); -} diff --git a/src/java/net/java/games/joal/ALC.java b/src/java/net/java/games/joal/ALC.java deleted file mode 100644 index f8855c6..0000000 --- a/src/java/net/java/games/joal/ALC.java +++ /dev/null @@ -1,263 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal; - -/** - * This class contains the context-related OpenAL functions. - * - * @author Athomas Goldberg - */ -public interface ALC extends ALCConstants { - /** - * This method opens a device by name. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALCdevice* alcOpenDevice(const ALubyte *token);</pre> - * - * @param deviceName a string describing the device - * - * @return an ALC.Device object for the opened device - */ - public Device alcOpenDevice(String deviceName); - - /** - * This method closes a device by name. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>void alcCloseDevice ALCDevice *dev);</pre> - * - * @param device the opened device to close - */ - public void alcCloseDevice(Device device); - - /** - * This method creates a context using a specified device. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>void alcCreateContext(ALCdevice *dev, ALint* attrList);</pre> - * - * @param device an opened device - * @param attrs a set of attributes: - * <pre> - * ALC_FREQUENCY - * ALC_REFRESH - * ALC_SYNC - * </pre> - * - * @return a context for the specified device. - */ - public Context alcCreateContext(Device device, int[] attrs); - - /** - * This method makes the specified context the current context.<br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALCEnum alcMakeContextCurrent(ALvoid *alcHandle);</pre> - * - * @param context the new context - * - * @return an error code on failure - */ - public int alcMakeContextCurrent(Context context); - - public void alcFreeCurrentContext(); - - /** - * This method tells a context to begin processing. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>void alcProcessContext(ALvoid *alHandle);</pre> - * - * @param context the context to be processed - */ - public void alcProcessContext(Context context); - - /** - * This method suspends processing on the current context. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>void alcSusendContext(ALvoid *alcHandle);</pre> - * - * @param context the context to be suspended. - */ - public void alcSuspendContext(Context context); - - /** - * This method destroys a context. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALCEnum alcDestroyContext(ALvoid *alcHandle);</pre> - * - * @param context the context to be destroyed - */ - public void alcDestroyContext(Context context); - - /** - * This method retrieves the current context error state. <br> - * <br> - *<b>Interface to C Language function:</b> - * <pre>ALCEnum alcGetError(ALvoid);</pre> - * @return the current context error state - */ - public int alcGetError(Device device); - - /** - * This method retrieves the current context. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>void* alcGetCurrentContext(ALvoid);</pre> - * - * @return the current context - */ - public Context alcGetCurrentContext(); - - /** - * This method returns the Device associated with the given context. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALCdevice* alcGetContextDevice(ALvoid *alcHandle);</pre> - * - * @param context the context whose device is being queried - * - * @return the device associated with the specified context. - */ - public Device alcGetContextsDevice(Context context); - - /** - * This method queries if a specified context extension is available. <br> - * <br> - *<b>Interface to C Language function:</b> - * <pre>ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName);</pre> - * - * @param device the device to be queried for an extension - * @param extName a string describing the extension - * - * @return true is the extension is available, - * false if the extension is not available - */ - public boolean alcIsExtensionPresent(Device device, String extName); - - // public Method getProcAddress(Device device, String funcName); - /** - * This method retrieves the constant value for a specified constant name. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName);</pre> - * - * @param device the device to be queried for the constant (?) - * @param enumName a string representation of the constant name - * - * @return the constant value associated with the string representation - * of the name - */ - public int alcGetEnumValue(Device device, String enumName); - - /** - * This method returns Strings related to the context. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALubyte* alcGetString(ALCDevice *device, ALenum pname);</pre> - * - * @param device the device to be queried - * @param attribute the attribute to be retrieved: - * <pre> - * ALC_DEFAULT_DEVICE_SPECIFIER - * ALC_DEVICE_SPECIFIER - * ALC_EXTENSIONS - * </pre> - * - * @return the string value of the attribute - */ - public String alcGetString(Device device, int attribute); - - /** - * This method retrieves integer properties related to the context. <br> - * <br> - * <b>Interface to C Language function:</b> - * <pre>ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei n, ALint *data);</pre> - * - * @param device the device to be queried - * @param attribute the attribute to be retrieved - * @param size the size of the destination array provided - * @param retValue an array to hold the data to be returned. - * - */ - public void alcGetIntegerv( - Device device, - int attribute, - int size, - int[] retValue); - - /** - * This class provides a reference to an OpenAL device - * - */ - public class Device { - final int pointer; - - Device(int pointer) { - this.pointer = pointer; - } - - public int hashCode() { - return (int) pointer; - } - - public boolean equals(Object obj) { - boolean result = false; - - if (obj instanceof Device && (obj.hashCode() == pointer)) { - result = true; - } - - return result; - } - } - - /** - * This class provides a reference to an OpenAL context - * - */ - public static class Context { - final ALC alcContext; - final int pointer; - - Context(ALC impl, int pointer) { - System.out.println("Pointer = " + pointer); - System.out.println("ALC = " + impl); - this.pointer = pointer; - this.alcContext = impl; - } - } -} diff --git a/src/java/net/java/games/joal/ALCConstants.java b/src/java/net/java/games/joal/ALCConstants.java deleted file mode 100644 index 47d0754..0000000 --- a/src/java/net/java/games/joal/ALCConstants.java +++ /dev/null @@ -1,95 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -* -* Created on Jun 6, 2003 -*/ - -package net.java.games.joal; - -/** - * @author Athomas Goldberg - * - */ -public interface ALCConstants { - /* Boolean False. */ - public final static int ALC_FALSE = 0; - - /* Boolean True. */ - public final static int ALC_TRUE = 1; - - /** Errors: No Error. */ - public final static int ALC_NO_ERROR = ALC_FALSE; - - public final static int ALC_MAJOR_VERSION = 0x1000; - public final static int ALC_MINOR_VERSION = 0x1001; - public final static int ALC_ATTRIBUTES_SIZE = 0x1002; - public final static int ALC_ALL_ATTRIBUTES = 0x1003; - - public final static int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004; - public final static int ALC_DEVICE_SPECIFIER = 0x1005; - public final static int ALC_EXTENSIONS = 0x1006; - - public final static int ALC_FREQUENCY = 0x1007; - public final static int ALC_REFRESH = 0x1008; - public final static int ALC_SYNC = 0x1009; - - /** - * The device argument does not name a valid dvice. - */ - public final static int ALC_INVALID_DEVICE = 0xA001; - - /** - * The context argument does not name a valid context. - */ - public final static int ALC_INVALID_CONTEXT = 0xA002; - - /** - * A function was called at inappropriate time, - * or in an inappropriate way, causing an illegal state. - * This can be an incompatible ALenum, object ID, - * and/or function. - */ - public final static int ALC_INVALID_ENUM = 0xA003; - - /** - * Illegal value passed as an argument to an AL call. - * Applies to parameter values, but not to enumerations. - */ - public final static int ALC_INVALID_VALUE = 0xA004; - - /** - * A function could not be completed, - * because there is not enough memory available. - */ - public final static int ALC_OUT_OF_MEMORY = 0xA005; - -} diff --git a/src/java/net/java/games/joal/ALCImpl.java b/src/java/net/java/games/joal/ALCImpl.java deleted file mode 100644 index e6d9d36..0000000 --- a/src/java/net/java/games/joal/ALCImpl.java +++ /dev/null @@ -1,224 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal; - -import java.util.HashMap; - -final class ALCImpl implements ALC { - private final HashMap contextMap = new HashMap(); - private static Mutex lock = new Mutex(); - - ALCImpl() { - System.loadLibrary("joal"); - // - // Fix to issue 6: Unable to terminate JOAL program with CRTL-C or kill Pid - // Shouldn't attempt to cleanup before exit, we will let the native driver - // do it. - // - } - - public Device alcOpenDevice(String deviceName) { - return openDeviceNative(deviceName); - } - - private native Device openDeviceNative(String deviceName); - - public void alcCloseDevice(Device device) { - if(device != null) { - closeDeviceNative(device.pointer); - } - } - - private native void closeDeviceNative(int pointer); - - public Context alcCreateContext(Device device, int[] attrs) { - Context result = null; - if(device != null) { - result = createContextNative(device.pointer, attrs); - contextMap.put(new Integer(result.pointer), result); - } - return result; - } - private native Context createContextNative(int pointer, int[] attrs); - - public int alcMakeContextCurrent(Context context) { - int result = 0; - int pointer = 0; - if (context != null) { - pointer = context.pointer; - } - lock.acquire(); - result = makeContextCurrentNative(pointer); - return result; - } - - public void alcFreeCurrentContext() { - makeContextCurrentNative(0); - lock.release(); - } - - private native int makeContextCurrentNative(int pointer); - - public void alcProcessContext(Context context) { - if(context != null) { - processContextNative(context.pointer); - } - } - - private native void processContextNative(int pointer); - - public void alcSuspendContext(Context context) { - if(context != null) { - suspendContextNative(context.pointer); - } - } - - private native void suspendContextNative(int pointer); - - public void alcDestroyContext(Context context) { - if(context != null) { - destroyContextNative(context.pointer); - } - } - - private native void destroyContextNative(int pointer); - - 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; - int pointer = getCurrentContextNative(); - if(pointer != 0) { - result = (Context) contextMap.get(new Integer(pointer)); - } - return result; - } - - private native int getCurrentContextNative(); - - public boolean alcIsExtensionPresent(Device device, String extName) { - boolean result = false; - - return result; - } - - // public Method getProcAddress(Device device, String funcName); - public int alcGetEnumValue(Device device, String enumName) { - return getEnumValueNative(device.pointer, enumName); - } - - private native int getEnumValueNative(int pointer, String enumValue); - - public String alcGetString(Device device, int attribute) { - String result = null; - result = alcGetStringNative(device.pointer, attribute); - return result; - } - - private native String alcGetStringNative(int pointer, int attribute); - - public void alcGetIntegerv( - Device device, - int attribute, - int size, - int[] array) { - alcGetIntegervNative(device.pointer, attribute, size, array); - } - - private native void alcGetIntegervNative( - int pointer, - int attr, - int size, - int[] arr); - - public Device alcGetContextsDevice(Context context) { - Device result = null; - if(context != null) { - int devicePtr = getContextsDeviceNative(context.pointer); - if(devicePtr != 0) { - result = new ALC.Device(devicePtr); - } - } - return result; - } - - private native int getContextsDeviceNative(int context); - - private void exit() { - - Context alcContext = alcGetCurrentContext(); - - if (alcContext != null) { - Device alcDevice = alcGetContextsDevice(alcContext); - alcMakeContextCurrent(null); - alcDestroyContext(alcContext); - alcCloseDevice(alcDevice); - } - } - - private static class Mutex { - Thread owner = null; - public synchronized void acquire() { - boolean interrupted = false; - while(owner != null && owner != Thread.currentThread()) { - try { - wait(); - } catch (InterruptedException e) { - interrupted = true; - } - } - owner = Thread.currentThread(); - if(interrupted) { - owner.interrupt(); - } - } - - public synchronized void release() { - if(!owner.equals(Thread.currentThread())) { - throw new IllegalMonitorStateException("Not Owner"); - } - owner = null; - notify(); - } - } -} diff --git a/src/java/net/java/games/joal/ALConstants.java b/src/java/net/java/games/joal/ALConstants.java deleted file mode 100644 index 4ee8e3f..0000000 --- a/src/java/net/java/games/joal/ALConstants.java +++ /dev/null @@ -1,348 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal; - -/** - * This interface contains the standard constants used by OpenAL - * @author Athomas Goldberg - */ -public interface ALConstants { - - /** Bad value */ - public static final int AL_INVALID = -1; - - /** Disable value */ - public static final int AL_NONE = 0; - - /** Boolean False */ - public static final int AL_FALSE = 0; - - /** Boolean True */ - public static final int AL_TRUE = 1; - - /** - * Indicate the type of SOURCE. - * Sources can be spatialized - */ - public static final int AL_SOURCE_TYPE = 0x200; - - /** Indicate source has absolute coordinates */ - public static final int AL_SOURCE_ABSOLUTE = 0x201; - - /** Indicate Source has listener relative coordinates */ - public static final int AL_SOURCE_RELATIVE = 0x202; - - /** - * Directional source, inner cone angle, in degrees - * Range: [0-360] - * Default: 360 - */ - public static final int AL_CONE_INNER_ANGLE = 0x1001; - - /** - * Directional source, outer cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ - public static final int AL_CONE_OUTER_ANGLE = 0x1002; - - /** - * Specify the pitch to be applied, either at source, - * or on mixer results, at listener. - * Range: [0.5-2.0] - * Default: 1.0 - */ - public static final int AL_PITCH = 0x1003; - - /** - * Specify the current location in three dimensional space. - * OpenAL, like OpenGL, uses a right handed coordinate system, - * where in a frontal default view X (thumb) points right, - * Y points up (index finger), and Z points towards the - * viewer/camera (middle finger). - * To switch from a left handed coordinate system, flip the - * sign on the Z coordinate. - * Listener position is always in the world coordinate system. - */ - public static final int AL_POSITION = 0x1004; - - /** Specify the current direction as forward vector. */ - public static final int AL_DIRECTION = 0x1005; - - /** Specify the current velocity in three dimensional space. */ - public static final int AL_VELOCITY = 0x1006; - - /** - * Indicate whether source has to loop infinite. - * Type: ALboolean - * Range: [AL_TRUE, AL_FALSE] - * Default: AL_FALSE - */ - public static final int AL_LOOPING = 0x1007; - - /** - * Indicate the buffer to provide sound samples. - * Type: ALuint. - * Range: any valid Buffer id. - */ - public static final int AL_BUFFER = 0x1009; - - /** - * Indicate the gain (volume amplification) applied. - * Type: ALfloat. - * Range: ]0.0- ] - * A value of 1.0 means un-attenuated/unchanged. - * Each division by 2 equals an attenuation of -6dB. - * Each multiplicaton with 2 equals an amplification of +6dB. - * A value of 0.0 is meaningless with respect to a logarithmic - * scale; it is interpreted as zero volume - the channel - * is effectively disabled. - */ - public static final int AL_GAIN = 0x100A; - - /** - * Indicate minimum source attenuation. - * Type: ALfloat - * Range: [0.0 - 1.0] - */ - public static final int AL_MIN_GAIN = 0x100D; - - /** - * Indicate maximum source attenuation. - * Type: ALfloat - * Range: [0.0 - 1.0] - */ - public static final int AL_MAX_GAIN = 0x100E; - - /** - * Specify the current orientation. - * Type: ALfv6 (at/up) - * Range: N/A - */ - public static final int AL_ORIENTATION = 0x100F; - - /* byte offset into source (in canon format). -1 if source - * is not playing. Don't set this, get this. - * - * Type: ALfloat - * Range: [0.0 - ] - * Default: 1.0 - */ - public static final int AL_REFERENCE_DISTANCE = 0x1020; - - /** - * Indicate the rolloff factor for the source. - * Type: ALfloat - * Range: [0.0 - ] - * Default: 1.0 - */ - public static final int AL_ROLLOFF_FACTOR = 0x1021; - - /** - * Indicate the gain (volume amplification) applied. - * Type: ALfloat. - * Range: ]0.0- ] - * A value of 1.0 means un-attenuated/unchanged. - * Each division by 2 equals an attenuation of -6dB. - * Each multiplicaton with 2 equals an amplification of +6dB. - * A value of 0.0 is meaningless with respect to a logarithmic - * scale; it is interpreted as zero volume - the channel - * is effectively disabled. - */ - public static final int AL_CONE_OUTER_GAIN = 0x1022; - - /** - * Specify the maximum distance. - * Type: ALfloat - * Range: [0.0 - ] - */ - public static final int AL_MAX_DISTANCE = 0x1023; - - /** - * Specify the channel mask. (Creative) - * Type: ALuint - * Range: [0 - 255] - */ - public static final int AL_CHANNEL_MASK = 0x3000; - - /** Source state information */ - public static final int AL_SOURCE_STATE = 0x1010; - - /** Source state information */ - public static final int AL_INITIAL = 0x1011; - - /** Source state information */ - public static final int AL_PLAYING = 0x1012; - - /** Source state information */ - public static final int AL_PAUSED = 0x1013; - - /** Source state information */ - public static final int AL_STOPPED = 0x1014; - - /** Buffer Queue params */ - public static final int AL_BUFFERS_QUEUED = 0x1015; - - /** Buffer Queue params */ - public static final int AL_BUFFERS_PROCESSED = 0x1016; - - /** Sound buffers: format specifier. */ - public static final int AL_FORMAT_MONO8 = 0x1100; - - /** Sound buffers: format specifier. */ - public static final int AL_FORMAT_MONO16 = 0x1101; - - /** Sound buffers: format specifier. */ - public static final int AL_FORMAT_STEREO8 = 0x1102; - - /** Sound buffers: format specifier. */ - public static final int AL_FORMAT_STEREO16 = 0x1103; - - /** - * Sound buffers: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ - public static final int AL_FREQUENCY = 0x2001; - - /** - * Sound buffers: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ - public static final int AL_BITS = 0x2002; - - /** - * Sound buffers: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ - public static final int AL_CHANNELS = 0x2003; - - /** - * Sound buffers: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ - public static final int AL_SIZE = 0x2004; - - /** - * Sound buffers: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ - public static final int AL_DATA = 0x2005; - - /** - * Buffer state. - * - * Not supported for public use (yet). - */ - public static final int AL_UNUSED = 0x2010; - - /** - * Buffer state. - * - * Not supported for public use (yet). - */ - public static final int AL_PENDING = 0x2011; - - /** - * Buffer state. - * - * Not supported for public use (yet). - */ - public static final int AL_PROCESSED = 0x2012; - - /** Errors: No Error. */ - public static final int AL_NO_ERROR = AL_FALSE; - - /** Illegal name passed as an argument to an AL call. */ - public static final int AL_INVALID_NAME = 0xA001; - - /** Illegal enum passed as an argument to an AL call. */ - public static final int AL_INVALID_ENUM = 0xA002; - - /** - * Illegal value passed as an argument to an AL call. - * Applies to parameter values, but not to enumerations. - */ - public static final int AL_INVALID_VALUE = 0xA003; - - /** - * A function was called at inappropriate time, - * or in an inappropriate way, causing an illegal state. - * This can be an incompatible ALenum, object ID, - * and/or function. - */ - public static final int AL_INVALID_OPERATION = 0xA004; - - /** - * A function could not be completed, - * because there is not enough memory available. - */ - public static final int AL_OUT_OF_MEMORY = 0xA005; - - /** Context strings: Vendor */ - public static final int AL_VENDOR = 0xB001; - - /** Context strings: Version */ - public static final int AL_VERSION = 0xB002; - - /** Context strings: Renderer */ - public static final int AL_RENDERER = 0xB003; - - /** Context strings: Extensions */ - public static final int AL_EXTENSIONS = 0xB004; - - /** Doppler scale. Default 1.0 */ - public static final int AL_DOPPLER_FACTOR = 0xC000; - - /** Doppler velocity. Default 1.0 */ - public static final int AL_DOPPLER_VELOCITY = 0xC001; - - /** Distance model. Default AL_INVERSE_DISTANCE_CLAMPED */ - public static final int AL_DISTANCE_MODEL = 0xD000; - - /** Distance model */ - public static final int AL_INVERSE_DISTANCE = 0xD001; - - /** Distance model */ - public static final int AL_INVERSE_DISTANCE_CLAMPED = 0xD002; -}
\ No newline at end of file diff --git a/src/java/net/java/games/joal/ALException.java b/src/java/net/java/games/joal/ALException.java new file mode 100755 index 0000000..75c6944 --- /dev/null +++ b/src/java/net/java/games/joal/ALException.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A + * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT + * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ + +package net.java.games.joal; + +/** A generic exception for OpenAL errors used throughout the binding + as a substitute for {@link RuntimeException}. */ + +public class ALException extends RuntimeException { + /** Constructs an ALException object. */ + public ALException() { + super(); + } + + /** Constructs an ALException object with the specified detail + message. */ + public ALException(String message) { + super(message); + } + + /** Constructs an ALException object with the specified detail + message and root cause. */ + public ALException(String message, Throwable cause) { + super(message, cause); + } + + /** Constructs an ALException object with the specified root + cause. */ + public ALException(Throwable cause) { + super(cause); + } +} diff --git a/src/java/net/java/games/joal/ALFactory.java b/src/java/net/java/games/joal/ALFactory.java index ae9f906..d500a83 100644 --- a/src/java/net/java/games/joal/ALFactory.java +++ b/src/java/net/java/games/joal/ALFactory.java @@ -1,111 +1,89 @@ /** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ + * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A + * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT + * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ package net.java.games.joal; +import net.java.games.joal.impl.*; + +import com.sun.gluegen.runtime.*; + /** - * This class provides factory methods for generating AL and ALC objects. The - * class must be initialized before use, and should be deinitialized when OpenAL - * functionality is no longer needed to free up native resources. + * This class provides factory methods for generating AL and ALC objects. * * @author Athomas Goldberg + * @author Kenneth Russell */ public class ALFactory { - static { - System.loadLibrary("joal"); - } + private static boolean initialized = false; + private static AL al; + private static ALC alc; - private static boolean isInitialized = false; - private static ALImpl al; - private static ALC alc; - - /** - * Initialize the OpenAL environment - * - * @return true is OpenAL was able to initialize, - * false if OpenAL was not able to intialize - */ - public static boolean initialize() throws OpenALException { - 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 { - isInitialized = init(new String[] { "/Library/Frameworks/OpenAL.framework/Versions/Current/OpenAL"}); - } - return isInitialized; + private static synchronized void initialize() throws ALException { + try { + if (!initialized) { + NativeLibLoader.load(); + initialized = true; + } + } catch (UnsatisfiedLinkError e) { + throw new ALException(e); } + } - private static native boolean init(String[] oalPaths) throws OpenALException; - - /** - * Deinitialize the OpenAL environment - * - * @return true if OpenAL was able to be deinitialized, - * false if OpenAL uas unable to be deinitialized - */ - public static native boolean deinitialize(); - - /** - * Get the default AL object. This object is used to access most of the - * OpenAL functionality. - * - * @return the AL object - */ - public static AL getAL() throws OpenALException { - if(!isInitialized) { - initialize(); - } - if (isInitialized && al == null) { - al = new ALImpl(); - } - return al; + /** + * Get the default AL object. This object is used to access most of the + * OpenAL functionality. + * + * @return the AL object + */ + public static AL getAL() throws ALException { + initialize(); + if (al == null) { + al = new ALImpl(); } + return al; + } - /** - * Get the default ALC object. This object is used to access most of the - * OpenAL context functionality. - * - * @return the ALC object - */ - public static ALC getALC() throws OpenALException{ - if(!isInitialized) { - initialize(); - } - if (isInitialized && alc == null) { - alc = new ALCImpl(); - } - return alc; + /** + * Get the default ALC object. This object is used to access most of the + * OpenAL context functionality. + * + * @return the ALC object + */ + public static ALC getALC() throws ALException{ + initialize(); + if (alc == null) { + alc = new ALCImpl(); } + return alc; + } } diff --git a/src/java/net/java/games/joal/ALImpl.java b/src/java/net/java/games/joal/ALImpl.java deleted file mode 100644 index 14362de..0000000 --- a/src/java/net/java/games/joal/ALImpl.java +++ /dev/null @@ -1,921 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -package net.java.games.joal; - -import java.nio.ByteBuffer; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; - - -final class ALImpl implements AL { - ALImpl() { - System.loadLibrary("joal"); - } - - // AL_BUFFER RELATED METHODS - - public void alGenBuffers(int n, IntBuffer buffers) { - if ( - (buffers == null) || - !buffers.isDirect() || - (n > buffers.capacity()) - ) { - throw new IllegalArgumentException( - "buffers must be direct, can not be null" + - " and buffer capacity must be greater than requested number of " + - "buffers." - ); - } else { - alGenBuffersNative(n, buffers); - } - } - - private native void alGenBuffersNative(int n, IntBuffer buffers); - - public void alGenBuffers(int n, int[] buffers) { - if ((buffers == null) || (n > buffers.length)) { - throw new IllegalArgumentException( - "buffers can not be null" + - " and array length must be greater than requested number of " + - "buffers." - ); - } else { - alGenBuffersNative(n, buffers); - } - } - - private native void alGenBuffersNative(int n, int[] buffers); - - public void alDeleteBuffers(int n, IntBuffer buffers) { - if ( - (buffers == null) || - !buffers.isDirect() || - (n > buffers.capacity()) - ) { - throw new IllegalArgumentException( - "buffers must be direct, can not be null" + - " and buffer capacity must be greater than requested number of " + - "buffers." - ); - } else { - alDeleteBuffersNative(n, buffers); - } - } - - private native void alDeleteBuffersNative(int n, IntBuffer buffers); - - public void alDeleteBuffers(int n, int[] buffers) { - if ((buffers == null) || (n > buffers.length)) { - throw new IllegalArgumentException( - "buffers can not be null" + - " and array length must be greater than requested number of " + - "buffers." - ); - } else { - alDeleteBuffersNative(n, buffers); - } - } - - private native void alDeleteBuffersNative(int n, int[] buffers); - - public native boolean alIsBuffer(int bufferName); - - public void alBufferData( - int buffername, - int format, - byte[] data, - int size, - int frequency - ) { - if (data == null) { - throw new IllegalArgumentException("data must not be null"); - } else { - alBufferDataNative(buffername, format, data, size, frequency); - } - } - - private native void alBufferDataNative( - int buffername, - int format, - byte[] data, - int size, - int frequency - ); - - public void alBufferData( - int buffername, - int format, - ByteBuffer data, - int size, - int frequency - ) { - if ((data == null) || !data.isDirect()) { - throw new IllegalArgumentException( - "data must be a direct, non-null buffer" - ); - } else { - alBufferDataNative(buffername, format, data, size, frequency); - } - } - - private native void alBufferDataNative( - int buffername, - int format, - ByteBuffer data, - int size, - int frequency - ); - - public void alGetBufferf(int bufferName, int pname, float[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException( - "Return Value argument must not be null." - ); - } else { - alGetBufferfNative(bufferName, pname, retValue); - } - } - - private native void alGetBufferfNative( - int bufferName, - int pname, - float[] retValue - ); - - public void alGetBufferf(int bufferName, int pname, FloatBuffer retValue) { - if ((retValue == null) || !retValue.isDirect()) { - throw new IllegalArgumentException( - "Return Value argument must be a direct, non-null buffer" - ); - } else { - alGetBufferfNative(bufferName, pname, retValue); - } - } - - private native void alGetBufferfNative( - int bufferName, - int pname, - FloatBuffer retValue - ); - - public native float alGetBufferf(int bufferName, int pname); - - public void alGetBufferi(int bufferName, int pname, int[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException( - "Return Value argument must not be null" - ); - } else { - alGetBufferiNative(bufferName, pname, retValue); - } - } - - private native void alGetBufferiNative( - int bufferName, - int pname, - int[] retValue - ); - - public void alGetBufferi(int bufferName, int pname, IntBuffer retValue) { - if ((retValue == null) || !retValue.isDirect()) { - throw new IllegalArgumentException( - "Return Value argument must be a direct, non-null IntBuffer" - ); - } else { - alGetBufferiNative(bufferName, pname, retValue); - } - } - - private native void alGetBufferiNative( - int bufferName, - int pname, - IntBuffer retValue - ); - - public native int alGetBufferi(int bufferName, int pname); - - // SOURCE RELATED METHODS - public void alGenSources(int numSources, int[] sources) { - if ((sources == null) || (numSources > sources.length)) { - throw new IllegalArgumentException( - "sources can not be null" + - " and array length must be greater than requested number of " + - "sources." - ); - } else { - alGenSourcesNative(numSources, sources); - } - } - - private native void alGenSourcesNative(int numSources, int[] sources); - - public void alGenSources(int numSources, IntBuffer sources) { - if ( - (sources == null) || - !sources.isDirect() || - (numSources > sources.capacity()) - ) { - throw new IllegalArgumentException( - "sources buffer must be direct, can not be null" + - " and capacity must be greater than requested number of " + - "sources." - ); - } else { - alGenSourcesNative(numSources, sources); - } - } - - private native void alGenSourcesNative(int numSources, IntBuffer sources); - - public void alDeleteSources(int numSources, int[] sources) { - if ((sources == null) || (numSources > sources.length)) { - throw new IllegalArgumentException( - "sources can not be null" + - " and array length must be greater than requested number of " + - "sources." - ); - } else { - alDeleteSourcesNative(numSources, sources); - } - } - - private native void alDeleteSourcesNative(int numSources, int[] sources); - - public void alDeleteSources(int numSources, IntBuffer sources) { - if ( - (sources == null) || - !sources.isDirect() || - (numSources > sources.capacity()) - ) { - throw new IllegalArgumentException( - "sources buffer must be direct, can not be null" + - " and capacity must be greater than requested number of " + - "sources." - ); - } else { - alDeleteSourcesNative(numSources, sources); - } - } - - private native void alDeleteSourcesNative( - int numSources, - IntBuffer sources - ); - - public native boolean alIsSource(int sourceName); - - public native void alSourcei(int sourcename, int pname, int value); - - public native void alSourcef(int sourcename, int pname, float value); - - public void alSourcefv(int sourcename, int pname, float[] value) { - alSourcefvNative(sourcename,pname,value); - } - - private native void alSourcefvNative(int sourcename, int pname, float[] value); - - public void alSourcefv(int sourcename, int pname, FloatBuffer value) { - if ((value != null) && !value.isDirect()) { - throw new IllegalArgumentException("buffer must be direct"); - } else { - alSourcefvNative(sourcename, pname, value); - } - } - - private native void alSourcefvNative( - int sourcename, - int pname, - FloatBuffer value - ); - - public native void alSource3f( - int sourcename, - int pname, - float v1, - float v2, - float v3 - ); - - public void alGetSourcef(int sourcename, int pname, float[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException("retValue must not be null"); - } else { - alGetSourcefNative(sourcename, pname, retValue); - } - } - - private native void alGetSourcefNative( - int sourcename, - int pname, - float[] retValue - ); - - public void alGetSourcef(int sourceName, int pname, FloatBuffer buffer) { - if ((buffer == null) || !buffer.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be direct and non-null" - ); - } else { - alGetSourcefNative(sourceName, pname, buffer); - } - } - - private native void alGetSourcefNative( - int sourceName, - int pname, - FloatBuffer buffer - ); - - public native float alGetSourcef(int sourceName, int pname); - - public void alGetSourcefv(int sourcename, int pname, FloatBuffer value) { - if ((value == null) || !value.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be direct and non-null" - ); - } else { - alGetSourcefvNative(sourcename, pname, value); - } - } - - private native void alGetSourcefvNative( - int sourcename, - int pname, - FloatBuffer value - ); - - - public void alGetSourcefv(int sourcename, int pname, float[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException( - "retValue arg array must not be null" - ); - } else { - alGetSourcefvNative(sourcename, pname, retValue); - } - } - - private native void alGetSourcefvNative( - int sourcename, - int pname, - float[] retValue - ); - - - public void alGetSourcei(int sourcename, int pname, int[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException( - "retValue arg array must not be null" - ); - } else { - alGetSourceiNative(sourcename, pname, retValue); - } - } - - private native void alGetSourceiNative( - int sourcename, - int pname, - int[] retValue - ); - - public void alGetSourcei(int sourcename, int pname, IntBuffer value) { - if ((value == null) || !value.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be direct and non-null" - ); - } else { - alGetSourceiNative(sourcename, pname, value); - } - } - - private native void alGetSourceiNative( - int sourcename, - int pname, - IntBuffer retValue - ); - - public native int alGetSourcei(int sourcename, int pname); - - - public native void alSourcePlay(int sourcename); - - public void alSourcePlayv(int numSources, int[] sourcenames) { - if ((sourcenames == null) || (numSources > sourcenames.length)) { - throw new IllegalArgumentException( - "sourcenames must be non-null" + - " and at least as large as the number of sources requested" - ); - } else { - alSourcePlayvNative(numSources, sourcenames); - } - } - - private native void alSourcePlayvNative(int numSources, int[] sourcenames); - - public void alSourcePlayv(int numSources, IntBuffer sourcenames) { - if ( - (sourcenames == null) || - (numSources > sourcenames.capacity()) || - !sourcenames.isDirect() - ) { - throw new IllegalArgumentException( - "sourcenames buffer must be direct, non-null and have a" + - " equals or greater capacity than the number of sources" + - " requested" - ); - } else { - alSourcePlayvNative(numSources, sourcenames); - } - } - - private native void alSourcePlayvNative( - int numSources, - IntBuffer sourcenames - ); - - public native void alSourcePause(int sourcename); - - public void alSourcePausev(int numSources, int[] sourcenames) { - if ((sourcenames == null) || (numSources > sourcenames.length)) { - throw new IllegalArgumentException( - "sourcenames must be non-null" + - " and at least as large as the number of sources requested" - ); - } else { - alSourcePausevNative(numSources, sourcenames); - } - } - - private native void alSourcePausevNative(int numSources, int[] sourcenames); - - public void alSourcePausev(int numSources, IntBuffer sourcenames) { - if ( - (sourcenames == null) || - (numSources > sourcenames.capacity()) || - !sourcenames.isDirect() - ) { - throw new IllegalArgumentException( - "sourcenames buffer must be direct, non-null and have a" + - " equals or greater capacity than the number of sources" + - " requested" - ); - } else { - alSourcePausevNative(numSources, sourcenames); - } - } - - private native void alSourcePausevNative( - int numSources, - IntBuffer sourcenames - ); - - public native void alSourceStop(int sourcename); - - public void alSourceStopv(int numSources, int[] sourcenames) { - if ((sourcenames == null) || (numSources > sourcenames.length)) { - throw new IllegalArgumentException( - "sourcenames must be non-null" + - " and at least as large as the number of sources requested" - ); - } else { - alSourceStopvNative(numSources, sourcenames); - } - } - - private native void alSourceStopvNative(int numSources, int[] sourcenames); - - public void alSourceStopv(int numSources, IntBuffer sourcenames) { - if ( - (sourcenames == null) || - (numSources > sourcenames.capacity()) || - !sourcenames.isDirect() - ) { - throw new IllegalArgumentException( - "sourcenames buffer must be direct, non-null and have a" + - " equals or greater capacity than the number of sources" + - " requested" - ); - } else { - alSourcePlayvNative(numSources, sourcenames); - } - } - - private native void alSourceStopvNative( - int numSources, - IntBuffer sourcenames - ); - - public native void alSourceRewind(int sourcename); - - public void alSourceRewindv(int numSources, int[] sourcenames) { - if ((sourcenames == null) || (numSources > sourcenames.length)) { - throw new IllegalArgumentException( - "sourcenames must be non-null" + - " and at least as large as the number of sources requested" - ); - } else { - alSourceRewindvNative(numSources, sourcenames); - } - } - - private native void alSourceRewindvNative( - int numSources, - int[] sourcenames - ); - - public void alSourceRewindv(int numSources, IntBuffer sourcenames) { - if ( - (sourcenames == null) || - (numSources > sourcenames.capacity()) || - !sourcenames.isDirect() - ) { - throw new IllegalArgumentException( - "sourcenames buffer must be direct, non-null and have a" + - " equals or greater capacity than the number of sources" + - " requested" - ); - } else { - alSourceRewindvNative(numSources, sourcenames); - } - } - - private native void alSourceRewindvNative( - int numSources, - IntBuffer sourcenames - ); - - public void alSourceQueueBuffers( - int sourcename, - int numBuffers, - int[] buffernames - ) { - if ((buffernames == null) || (numBuffers > buffernames.length)) { - throw new IllegalArgumentException( - "buffernames must be non-null and equal or greater " + - "than the numBuffers specified" - ); - } else { - alSourceQueueBuffersNative(sourcename, numBuffers, buffernames); - } - } - - private native void alSourceQueueBuffersNative( - int sourcename, - int numBuffers, - int[] buffernames - ); - - public void alSourceQueueBuffers( - int sourcename, - int numBuffers, - IntBuffer buffernames - ) { - if ( - (buffernames == null) || - !buffernames.isDirect() || - (numBuffers > buffernames.capacity()) - ) { - throw new IllegalArgumentException( - "only non-null, direct buffers of numBuffers capacity" + - " or greater may be used." - ); - } else { - alSourceQueueBuffersNative(sourcename, numBuffers, buffernames); - } - } - - private native void alSourceQueueBuffersNative( - int sourcename, - int numBuffers, - IntBuffer buffernames - ); - - public void alSourceUnqueueBuffers( - int sourcename, - int numBuffers, - int[] buffernames - ) { - if ((buffernames == null) || (numBuffers > buffernames.length)) { - throw new IllegalArgumentException( - "buffernames must be non-null and equal or greater " + - "than the numBuffers specified" - ); - } else { - alSourceUnqueueBuffersNative(sourcename, numBuffers, buffernames); - } - } - - private native void alSourceUnqueueBuffersNative( - int sourcename, - int numBuffers, - int[] buffernames - ); - - public void alSourceUnqueueBuffers( - int sourcename, - int numBuffers, - IntBuffer buffernames - ) { - if ( - (buffernames == null) || - !buffernames.isDirect() || - (numBuffers > buffernames.capacity()) - ) { - throw new IllegalArgumentException( - "only non-null, direct buffers of numBuffers capacity" + - " or greater may be used." - ); - } else { - alSourceUnqueueBuffersNative(sourcename, numBuffers, buffernames); - } - } - - private native void alSourceUnqueueBuffersNative( - int sourcename, - int numBuffers, - IntBuffer buffernames - ); - - // LISTENER RELATED METHODS - public native void alListenerf(int pname, float value); - - public native void alListener3f(int pname, float v1, float v2, float v3); - - public void alListenerfv(int pname, float[] values) { - alListenerfvNative(pname,values); - } - - private native void alListenerfvNative(int pname, float[] value); - - public void alListenerfv(int pname, FloatBuffer value) { - if ((value != null) && !value.isDirect()) { - throw new IllegalArgumentException("buffer must be direct"); - } else { - alListenerfvNative(pname, value); - } - } - - private native void alListenerfvNative(int pname, FloatBuffer value); - - public native void alListeneri(int pname, int value); - - public void alGetListenerf(int pname, float[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException( - "retValue must be non-null array" - ); - } - } - - private native void alGetListenerfNative(int pname, float[] retValue); - - public void alGetListenerf(int pname, FloatBuffer retValue) { - if ((retValue == null) || !retValue.isDirect()) { - throw new IllegalArgumentException( - "retValue must be a non-null direct buffer" - ); - } else { - alGetListenerfNative(pname, retValue); - } - } - - private native void alGetListenerfNative(int pname, FloatBuffer retValue); - - public native float alGetListenerf(int pname); - - public void alGetListener3f( - int pname, - FloatBuffer v1, - FloatBuffer v2, - FloatBuffer v3 - ) { - if ( - ((v1 == null) || !v1.isDirect()) || - ((v2 == null) || !v2.isDirect()) || - ((v3 == null) || !v3.isDirect()) - ) { - throw new IllegalArgumentException( - "buffers must be non-null and direct" - ); - } else { - alGetListener3fNative(pname, v1, v2, v3); - } - } - - private native void alGetListener3fNative( - int pname, - FloatBuffer v1, - FloatBuffer v2, - FloatBuffer v3 - ); - - public void alGetListener3f(int pname, float[] v1, float[] v2, float[] v3) { - if ((v1 == null) || (v2 == null) || (v3 == null)) { - throw new IllegalArgumentException("Arrays must be non-null"); - } else { - alGetListener3fNative(pname, v1, v2, v3); - } - } - - private native void alGetListener3fNative( - int pname, - float[] v1, - float[] v2, - float[] v3 - ); - - public void alGetListenerfv(int pname, float[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException("Array must be non-null"); - } else { - alGetListenerfvNative(pname, retValue); - } - } - - private native void alGetListenerfvNative(int pname, float[] retValue); - - public void alGetListenerfv(int pname, FloatBuffer retValue) { - if ((retValue == null) || !retValue.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be non-null and direct" - ); - } else { - alGetListenerfvNative(pname, retValue); - } - } - - private native void alGetListenerfvNative(int pname, FloatBuffer retValue); - - public void alGetListeneri(int pname, int[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException("Array must be non-null"); - } else { - alGetListeneriNative(pname, retValue); - } - } - - private native void alGetListeneriNative(int pname, int[] retValue); - - public void alGetListeneri(int pname, IntBuffer retValue) { - if ((retValue == null) || !retValue.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be non-null and direct" - ); - } else { - alGetListeneriNative(pname, retValue); - } - } - - private native void alGetListeneriNative(int pname, IntBuffer retValue); - - public native int alGetListeneri(int pname); - - // STATE RELATED METHODS - public native void alEnable(int capability); - - public native void alDisable(int capability); - - public native boolean alIsEnabled(int capability); - - public native boolean alGetBoolean(int pname); - - public native double alGetDouble(int pname); - - public native float alGetFloat(int pname); - - public native int alGetInteger(int pname); - - // No Boolean Array states at the moment - // public native void getBooleanv(int pname, ByteBuffer value); - - public void alGetBooleanv(int pname, boolean[] value) { - if (value == null) { - throw new IllegalArgumentException("Array must be non-null"); - } else { - value[0] = false; - // do nothing for now, there are no boolean vector props - // alGetBooleanvNative(pname, value); - } - } - - private native void alGetBooleanvNative(int pname, boolean[] value); - - public void alGetDoublev(int pname, double[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException("Array must be non-null"); - } else { - alGetDoublevNative(pname, retValue); - } - } - - private native void alGetDoublevNative(int pname, double[] retValue); - - public void alGetDoublev(int pname, DoubleBuffer value) { - if ((value == null) || !value.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be non-null and direct" - ); - } else { - alGetDoublevNative(pname, value); - } - } - - private native void alGetDoublevNative(int pname, DoubleBuffer value); - - public void alGetFloatv(int pname, float[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException("Array must be non-null"); - } else { - alGetFloatvNative(pname, retValue); - } - } - - private native void alGetFloatvNative(int pname, float[] retValue); - - public void alGetFloatv(int pname, FloatBuffer value) { - if ((value == null) || !value.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be non-null and direct" - ); - } else { - alGetFloatvNative(pname, value); - } - } - - private native void alGetFloatvNative(int pname, FloatBuffer value); - - public void alGetIntegerv(int pname, int[] retValue) { - if (retValue == null) { - throw new IllegalArgumentException("Array must be non-null"); - } else { - alGetIntegervNative(pname, retValue); - } - } - - private native void alGetIntegervNative(int pname, int[] retValue); - - public void alGetIntegerv(int pname, IntBuffer value) { - if ((value == null) || !value.isDirect()) { - throw new IllegalArgumentException( - "Buffer must be non-null and direct" - ); - } else { - alGetIntegervNative(pname, value); - } - } - - private native void alGetIntegervNative(int pname, IntBuffer value); - - public native String alGetString(int pname); - - public native void alDistanceModel(int model); - - public native void alDopplerFactor(float value); - - public native void alDopplerVelocity(float value); - - // ERROR RELATED METHODS - public native int alGetError(); - - // EXTENSION RELATED METHODS - public native boolean alIsExtensionPresent(String extName); - - // public native Method getProcAddress(String methodName); - public native int alGetEnumValue(String enumName); - /* (non-Javadoc) - * @see net.java.games.joal.AL#alGetBooleanv(int, boolean[]) - */ - -} diff --git a/src/java/net/java/games/joal/NativeLibLoader.java b/src/java/net/java/games/joal/NativeLibLoader.java new file mode 100755 index 0000000..394d1b4 --- /dev/null +++ b/src/java/net/java/games/joal/NativeLibLoader.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + */ + +package net.java.games.joal; + +import java.security.*; + +class NativeLibLoader { + static { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + // Workaround for problem in OpenAL32.dll, which is actually + // the "wrapper" DLL which looks for real OpenAL + // implementations like nvopenal.dll and "*oal.dll". + // joal.dll matches this wildcard and a bug in OpenAL32.dll + // causes a call through a null function pointer. + System.loadLibrary("joal_native"); + + // Workaround for 4845371. + // Make sure the first reference to the JNI GetDirectBufferAddress is done + // from a privileged context so the VM's internal class lookups will succeed. + // FIXME: need to figure out an appropriate entry point to call + // JAWT jawt = new JAWT(); + // JAWTFactory.JAWT_GetAWT(jawt); + + return null; + } + }); + } + + public static void load() { + } +} diff --git a/src/java/net/java/games/joal/OpenALException.java b/src/java/net/java/games/joal/OpenALException.java deleted file mode 100644 index f8a7732..0000000 --- a/src/java/net/java/games/joal/OpenALException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Created on Nov 22, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package net.java.games.joal; - -/** - * @author athomas - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class OpenALException extends Exception { - - /** - * - */ - public OpenALException() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * @param arg0 - */ - public OpenALException(String arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } - - /** - * @param arg0 - */ - public OpenALException(Throwable arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } - - /** - * @param arg0 - * @param arg1 - */ - public OpenALException(String arg0, Throwable arg1) { - super(arg0, arg1); - // TODO Auto-generated constructor stub - } - -} diff --git a/src/java/net/java/games/joal/eax/EAX.java b/src/java/net/java/games/joal/eax/EAX.java index 5ce2a9b..72c7cbf 100644 --- a/src/java/net/java/games/joal/eax/EAX.java +++ b/src/java/net/java/games/joal/eax/EAX.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT diff --git a/src/java/net/java/games/joal/eax/EAXConstants.java b/src/java/net/java/games/joal/eax/EAXConstants.java index 23c3400..44f1bee 100644 --- a/src/java/net/java/games/joal/eax/EAXConstants.java +++ b/src/java/net/java/games/joal/eax/EAXConstants.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT diff --git a/src/java/net/java/games/joal/eax/EAXFactory.java b/src/java/net/java/games/joal/eax/EAXFactory.java index 2547ed7..c700ce6 100644 --- a/src/java/net/java/games/joal/eax/EAXFactory.java +++ b/src/java/net/java/games/joal/eax/EAXFactory.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT diff --git a/src/java/net/java/games/joal/util/ALut.java b/src/java/net/java/games/joal/util/ALut.java index cd89e0c..71673b0 100644 --- a/src/java/net/java/games/joal/util/ALut.java +++ b/src/java/net/java/games/joal/util/ALut.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -35,15 +35,12 @@ package net.java.games.joal.util; -import java.io.IOException; +import java.io.*; import java.nio.ByteBuffer; import javax.sound.sampled.UnsupportedAudioFileException; -import net.java.games.joal.AL; -import net.java.games.joal.ALC; -import net.java.games.joal.ALFactory; -import net.java.games.joal.OpenALException; +import net.java.games.joal.*; /** * @author Athomas Goldberg @@ -51,80 +48,67 @@ import net.java.games.joal.OpenALException; */ public final class ALut { - private static ALC alc; + private static ALC alc; - private ALut() { } + private ALut() { } - public static void alutInit() throws OpenALException { - System.out.println("Go TEAM!"); - System.out.println("Entering alutInit()"); - ALFactory.initialize(); - alc = ALFactory.getALC(); - //String deviceName = null; - String deviceName = null; - /* - String os = System.getProperty("os.name"); - if (os.startsWith("Windows")) { - deviceName = "DirectSound3D"; - } - if (deviceName != null) { - */ - ALC.Context context; - ALC.Device device; - System.out.println("In alutInit(): Device Name = " + deviceName); - device = alc.alcOpenDevice(deviceName); - System.out.println("In alutInit(): Device = " + device); - context = alc.alcCreateContext(device, null); - alc.alcMakeContextCurrent(context); - /* - } else { - System.out.println( - "alutInit does not currently support " - + os - + ". " - + "You'll need to construct your device and context" - + "using the ALC functions for the time being. We apologize " - + "for the inconvenience."); - } - */ - System.out.println("Exiting alutInit()"); + /** Initializes the OpenAL Utility Toolkit, creates an OpenAL + context and makes it current on the current thread. */ + public static void alutInit() throws ALException { + alc = ALFactory.getALC(); + String deviceName = null; + ALCcontext context; + ALCdevice device; + device = alc.alcOpenDevice(deviceName); + if (device == null) { + throw new ALException("Error opening default OpenAL device"); } - - public static void alutLoadWAVFile( - String fileName, - int[] format, - ByteBuffer[] data, - int[] size, - int[] freq, - int[] loop) { - try { - WAVData wd = WAVLoader.loadFromFile(fileName); - format[0] = wd.format; - data[0] = wd.data; - size[0] = wd.size; - freq[0] = wd.freq; - loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; - } catch (IOException e) { - e.printStackTrace(); - } catch (UnsupportedAudioFileException e) { - e.printStackTrace(); - } + context = alc.alcCreateContext(device, null); + if (context == null) { + throw new ALException("Error creating OpenAL context"); + } + alc.alcMakeContextCurrent(context); + if (alc.alcGetError(device) != 0) { + throw new ALException("Error making OpenAL context current"); } + } - public static void alutUnloadWAV( - int format, - ByteBuffer data, - int size, - int freq) { - // unneeded. here for completeness. + public static void alutLoadWAVFile(String fileName, + int[] format, + ByteBuffer[] data, + int[] size, + int[] freq, + int[] loop) throws ALException { + try { + WAVData wd = WAVLoader.loadFromFile(fileName); + format[0] = wd.format; + data[0] = wd.data; + size[0] = wd.size; + freq[0] = wd.freq; + loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; + } catch (Exception e) { + throw new ALException(e); } + } - public static void alutExit() { - - ALC.Context context = alc.alcGetCurrentContext(); - ALC.Device device = alc.alcGetContextsDevice(context); - alc.alcFreeCurrentContext(); - alc.alcDestroyContext(context); - alc.alcCloseDevice(device); + public static void alutLoadWAVFile(InputStream stream, + int[] format, + ByteBuffer[] data, + int[] size, + int[] freq, + int[] loop) throws ALException { + try { + if (!(stream instanceof BufferedInputStream)) { + stream = new BufferedInputStream(stream); + } + WAVData wd = WAVLoader.loadFromStream(stream); + format[0] = wd.format; + data[0] = wd.data; + size[0] = wd.size; + freq[0] = wd.freq; + loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; + } catch (Exception e) { + throw new ALException(e); } + } } diff --git a/src/java/net/java/games/joal/util/BufferUtils.java b/src/java/net/java/games/joal/util/BufferUtils.java index 47bf3bc..05de65a 100644 --- a/src/java/net/java/games/joal/util/BufferUtils.java +++ b/src/java/net/java/games/joal/util/BufferUtils.java @@ -1,165 +1,266 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ package net.java.games.joal.util; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.CharBuffer; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.LongBuffer; -import java.nio.ShortBuffer; - - -/** - * Provides a collection of methods for generating direct Buffers of various - * types. - * - * @author Athomas Goldberg - */ +import java.nio.*; +import java.util.*; + +/** Utility routines for dealing with direct buffers. */ + public class BufferUtils { - private static final int CHAR = 2; - private static final int SHORT = 2; - private static final int INT = 4; - private static final int LONG = 8; - private static final int FLOAT = 4; - private static final int DOUBLE = 8; - - private BufferUtils() { - } - - /** - * Create a new direct ByteBuffer of the specified size. - * - * @param size (in bytes) of the returned ByteBuffer - * - * @return a new direct ByteBuffer of the specified size - */ - public static ByteBuffer newByteBuffer(int size) { - ByteBuffer result = null; - result = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder()); - - return result; - } - - /** - * Create a new direct CharBuffer of the specified size. - * - * @param size (in chars) of the returned CharBuffer - * - * @return a new direct CharBuffer of the specified size - */ - public static CharBuffer newCharBuffer(int size) { - CharBuffer result = null; - ByteBuffer temp = newByteBuffer(size * CHAR); - result = temp.asCharBuffer(); - - return result; - } - - /** - * Create a new direct ShortBuffer of the specified size. - * - * @param size (in shorts) of the returned ShortBuffer - * - * @return a new direct ShortBuffer of the specified size - */ - public static ShortBuffer newShortBuffer(int size) { - ShortBuffer result = null; - ByteBuffer temp = newByteBuffer(size * SHORT); - result = temp.asShortBuffer(); - - return result; - } - - /** - * Create a new direct IntBuffer of the specified size. - * - * @param size (in ints) of the returned IntBuffer - * - * @return a new direct IntBuffer of the specified size - */ - public static IntBuffer newIntBuffer(int size) { - IntBuffer result = null; - ByteBuffer temp = newByteBuffer(size * INT); - result = temp.asIntBuffer(); - - return result; - } - - /** - * Create a new direct LongBuffer of the specified size. - * - * @param size (in longs) of the returned LongBuffer - * - * @return a new direct LongsBuffer of the specified size - */ - public static LongBuffer newLongBuffer(int size) { - LongBuffer result = null; - ByteBuffer temp = newByteBuffer(size * LONG); - result = temp.asLongBuffer(); - - return result; - } - - /** - * Create a new direct FloatBuffer of the specified size. - * - * @param size (in floats) of the returned FloatBuffer - * - * @return a new direct FloatBuffer of the specified size - */ - public static FloatBuffer newFloatBuffer(int size) { - FloatBuffer result = null; - ByteBuffer temp = newByteBuffer(size * FLOAT); - result = temp.asFloatBuffer(); - - return result; - } - - /** - * Create a new direct DoubleBuffer of the specified size. - * - * @param size (in doubles) of the returned DoubleBuffer - * - * @return a new direct DoubleBuffer of the specified size - */ - public static DoubleBuffer newDoubleBuffer(int size) { - DoubleBuffer result = null; - ByteBuffer temp = newByteBuffer(size * DOUBLE); - result = temp.asDoubleBuffer(); - return result; - } + public static final int SIZEOF_BYTE = 1; + public static final int SIZEOF_SHORT = 2; + public static final int SIZEOF_INT = 4; + public static final int SIZEOF_FLOAT = 4; + public static final int SIZEOF_LONG = 8; + public static final int SIZEOF_DOUBLE = 8; + + //---------------------------------------------------------------------- + // Allocation routines + // + + /** Allocates a new direct ByteBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static ByteBuffer newByteBuffer(int numElements) { + ByteBuffer bb = ByteBuffer.allocateDirect(numElements); + bb.order(ByteOrder.nativeOrder()); + return bb; + } + + /** Allocates a new direct DoubleBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static DoubleBuffer newDoubleBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_DOUBLE); + return bb.asDoubleBuffer(); + } + + /** Allocates a new direct FloatBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static FloatBuffer newFloatBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); + return bb.asFloatBuffer(); + } + + /** Allocates a new direct IntBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static IntBuffer newIntBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); + return bb.asIntBuffer(); + } + + /** Allocates a new direct LongBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static LongBuffer newLongBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_LONG); + return bb.asLongBuffer(); + } + + /** Allocates a new direct ShortBuffer with the specified number of + elements. The returned buffer will have its byte order set to + the host platform's native byte order. */ + public static ShortBuffer newShortBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_SHORT); + return bb.asShortBuffer(); + } + + //---------------------------------------------------------------------- + // Copy routines (type-to-type) + // + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed ByteBuffer into + a newly-allocated direct ByteBuffer. The returned buffer will + have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyByteBuffer(ByteBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining()); + orig.mark(); + dest.put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed DoubleBuffer + into a newly-allocated direct DoubleBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static DoubleBuffer copyDoubleBuffer(DoubleBuffer orig) { + return copyDoubleBufferAsByteBuffer(orig).asDoubleBuffer(); + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed FloatBuffer + into a newly-allocated direct FloatBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static FloatBuffer copyFloatBuffer(FloatBuffer orig) { + return copyFloatBufferAsByteBuffer(orig).asFloatBuffer(); + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed IntBuffer + into a newly-allocated direct IntBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static IntBuffer copyIntBuffer(IntBuffer orig) { + return copyIntBufferAsByteBuffer(orig).asIntBuffer(); + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed LongBuffer + into a newly-allocated direct LongBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static LongBuffer copyLongBuffer(LongBuffer orig) { + return copyLongBufferAsByteBuffer(orig).asLongBuffer(); + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed ShortBuffer + into a newly-allocated direct ShortBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ShortBuffer copyShortBuffer(ShortBuffer orig) { + return copyShortBufferAsByteBuffer(orig).asShortBuffer(); + } + + //---------------------------------------------------------------------- + // Copy routines (type-to-ByteBuffer) + // + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed DoubleBuffer + into a newly-allocated direct ByteBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyDoubleBufferAsByteBuffer(DoubleBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_DOUBLE); + orig.mark(); + dest.asDoubleBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed FloatBuffer + into a newly-allocated direct ByteBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_FLOAT); + orig.mark(); + dest.asFloatBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed IntBuffer into + a newly-allocated direct ByteBuffer. The returned buffer will + have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_INT); + orig.mark(); + dest.asIntBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed LongBuffer into + a newly-allocated direct ByteBuffer. The returned buffer will + have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyLongBufferAsByteBuffer(LongBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_LONG); + orig.mark(); + dest.asLongBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } + + /** Copies the <i>remaining</i> elements (as defined by + <code>limit() - position()</code>) in the passed ShortBuffer + into a newly-allocated direct ByteBuffer. The returned buffer + will have its byte order set to the host platform's native byte + order. The position of the newly-allocated buffer will be zero, + and the position of the passed buffer is unchanged (though its + mark is changed). */ + public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig) { + ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_SHORT); + orig.mark(); + dest.asShortBuffer().put(orig); + orig.reset(); + dest.rewind(); + return dest; + } } diff --git a/src/java/net/java/games/joal/util/Version.java b/src/java/net/java/games/joal/util/Version.java new file mode 100755 index 0000000..51cff25 --- /dev/null +++ b/src/java/net/java/games/joal/util/Version.java @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* -Redistribution of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* -Redistribution in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* Neither the name of Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without +* specific prior written permission. +* +* This software is provided "AS IS," without a warranty of any kind. +* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS +* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT +* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR +* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, +* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS +* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +* +* You acknowledge that this software is not designed or intended for use in the +* design, construction, operation or maintenance of any nuclear facility. +*/ + +package net.java.games.joal.util; + +/** + * The version and build number of this implementation. + * Version numbers for a release are of the form: w.x.y[-a]-z, where: + * <ul> + * <li> + * w - the major version number of the release. This number should + * start at 1. Typically, a bump in the major version number + * signifies that the release breaks backwards compatibility + * with some older release. + * </li> + * <li> + * x - minor version number. This number starts at 0. A bump in + * the minor version number signifies a release that has significant + * new functionality. + * </li> + * <li> + * y - minor-minor version number number. This number starts at 0. A + * bump in the minor-minor version number signifies that new bug + * fixes have been added to the build. + * </li> + * <li> + * a - an optional build designator followed by a digit. Valid build + * designators are: + * <ul> + * <li>alpha</li> + * <li>beta</li> + * </ul> + * </li> + * <li> + * z - build number. This is used to specify the build number of the + * release. This is usually only important to people that use + * the daily build of a project. The format is the lower-case + * letter 'b' followed by a two digit number. + * </li> + * </ul> + * + * For example, the following are all valid version strings: + * <ul> + * <li>1.1.2-b02</li> + * <li>1.3.5-alpha1-b19</li> + * <li>4.7.1-beta3-b20</li> + * </ul> + * + */ +public final class Version { + + /** + * Private constructor - no need for user to create + * an instance of this class. + */ + private Version() { + } + + /** + * Version string of this build. + */ + private static final String version = "1.1.0-b01"; + + /** + * Returns the version string and build number of + * this implementation. See the class description + * for the version string format. + * + * @return The version string of this implementation. + */ + public static String getVersion() { + return version; + } +} diff --git a/src/java/net/java/games/joal/util/WAVData.java b/src/java/net/java/games/joal/util/WAVData.java index 9ab9e46..c0584e9 100644 --- a/src/java/net/java/games/joal/util/WAVData.java +++ b/src/java/net/java/games/joal/util/WAVData.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT diff --git a/src/java/net/java/games/joal/util/WAVLoader.java b/src/java/net/java/games/joal/util/WAVLoader.java index 4cb2836..e7a5257 100644 --- a/src/java/net/java/games/joal/util/WAVLoader.java +++ b/src/java/net/java/games/joal/util/WAVLoader.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -33,20 +33,12 @@ package net.java.games.joal.util; -import net.java.games.joal.ALConstants; - -import java.io.File; -import java.io.IOException; - -import java.nio.ByteBuffer; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; - -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.*; +import java.nio.*; +import java.nio.channels.*; +import javax.sound.sampled.*; +import net.java.games.joal.*; /** * A Loader utility for (.wav) files. Creates a WAVData object containing the @@ -74,6 +66,31 @@ public class WAVLoader implements ALConstants { WAVData result = null; File soundFile = new File(filename); AudioInputStream aIn = AudioSystem.getAudioInputStream(soundFile); + return readFromStream(aIn); + } + + /** + * This method loads a (.wav) file into a WAVData object. + * + * @param stream An InputStream for the .WAV file. + * + * @return a WAVData object containing the audio data + * + * @throws UnsupportedAudioFileException if the format of the audio if not + * supported. + * @throws IOException If the file can no be found or some other IO error + * occurs + */ + public static WAVData loadFromStream(InputStream stream) + throws UnsupportedAudioFileException, IOException { + WAVData result = null; + AudioInputStream aIn = AudioSystem.getAudioInputStream(stream); + return readFromStream(aIn); + } + + + private static WAVData readFromStream(AudioInputStream aIn) + throws UnsupportedAudioFileException, IOException { ReadableByteChannel aChannel = Channels.newChannel(aIn); AudioFormat fmt = aIn.getFormat(); int numChannels = fmt.getChannels(); @@ -93,8 +110,24 @@ public class WAVLoader implements ALConstants { int freq = Math.round(fmt.getSampleRate()); int size = aIn.available(); ByteBuffer buffer = ByteBuffer.allocateDirect(size); - aChannel.read(buffer); - result = new WAVData(buffer, format, size, freq, false); + while (buffer.remaining() > 0) { + aChannel.read(buffer); + } + buffer.rewind(); + + // Must byte swap on big endian platforms + // Thanks to swpalmer on javagaming.org forums for hint at fix + if ((bits == 16) && (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)) { + int len = buffer.remaining(); + for (int i = 0; i < len; i += 2) { + byte a = buffer.get(i); + byte b = buffer.get(i+1); + buffer.put(i, b); + buffer.put(i+1, a); + } + } + + WAVData result = new WAVData(buffer, format, size, freq, false); aIn.close(); return result; diff --git a/src/java/net/java/games/sound3d/AudioSystem3D.java b/src/java/net/java/games/sound3d/AudioSystem3D.java index 8dc4ba3..ea1affa 100644 --- a/src/java/net/java/games/sound3d/AudioSystem3D.java +++ b/src/java/net/java/games/sound3d/AudioSystem3D.java @@ -1,42 +1,39 @@ /** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING + * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A + * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT + * OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ package net.java.games.sound3d; -import net.java.games.joal.AL; -import net.java.games.joal.ALC; -import net.java.games.joal.ALFactory; -import net.java.games.joal.OpenALException; +import net.java.games.joal.*; import net.java.games.joal.util.WAVData; import net.java.games.joal.util.WAVLoader; @@ -52,180 +49,175 @@ import javax.sound.sampled.UnsupportedAudioFileException; * @author Athomas Goldberg */ public class AudioSystem3D { - private static AL al; - private static ALC alc; - private static Listener listener; - - /** - * Iniitalize the Sound3D environment. This must be called before - * other methods in the class can be used. - */ - public static void init() throws Sound3DException { - try { - ALFactory.initialize(); - al = ALFactory.getAL(); - alc = ALFactory.getALC(); - } catch (OpenALException e) { - throw new Sound3DException("Could not initialize AudioSystem3D: ",e); - } - } - - /** - * Creates a new Sound3D Context for a specified device. - * - * @param device The device the Context is being created for. - * - * @return The new Sound3D context. - */ - public static Context createContext(Device device) { - Context result = null; - ALC.Context realContext = alc.alcCreateContext(device.realDevice, null); - result = new Context(alc, realContext, device); - return result; + private static AL al; + private static ALC alc; + private static Listener listener; + + /** + * Iniitalize the Sound3D environment. This must be called before + * other methods in the class can be used. + */ + public static void init() throws ALException { + al = ALFactory.getAL(); + alc = ALFactory.getALC(); + } + + /** + * Creates a new Sound3D Context for a specified device. + * + * @param device The device the Context is being created for. + * + * @return The new Sound3D context. + */ + public static Context createContext(Device device) { + Context result = null; + ALCcontext realContext = alc.alcCreateContext(device.realDevice, null); + result = new Context(alc, realContext, device); + return result; + } + + /** + * Makes the specified context the current context. + * + * @param context the context to make current. + */ + public static void makeContextCurrent(Context context) { + ALCcontext realContext = null; + + if (context != null) { + realContext = context.realContext; } - /** - * Makes the specified context the current context. - * - * @param context the context to make current. - */ - public static void makeContextCurrent(Context context) { - ALC.Context realContext = null; - - if (context != null) { - realContext = context.realContext; - } - - alc.alcMakeContextCurrent(realContext); + alc.alcMakeContextCurrent(realContext); + } + + /** + * Opens the specifified audio device. + * + * @param deviceName The specified device name, On windows this will be + * DirectSound3D. We will be automating device discovery in upcoming versions + * of this class. + * + * @return The device described by the specifed name. + */ + public static Device openDevice(String deviceName) { + Device result = null; + ALCdevice realDevice = alc.alcOpenDevice(deviceName); + result = new Device(alc, realDevice); + + return result; + } + + /** + * Generate an array of Sound3D buffers. + * + * @param numBuffers The number of Sound3D buffers to generate. + * + * @return an array of (initially enpty) Sound3D buffers. + */ + public static Buffer[] generateBuffers(int numBuffers) { + Buffer[] result = new Buffer[numBuffers]; + int[] arr = new int[numBuffers]; + al.alGenBuffers(numBuffers, arr, 0); + + for (int i = 0; i < numBuffers; i++) { + result[i] = new Buffer(al, arr[i]); } - /** - * Opens the specifified audio device. - * - * @param deviceName The specified device name, On windows this will be - * DirectSound3D. We will be automating device discovery in upcoming versions - * of this class. - * - * @return The device described by the specifed name. - */ - public static Device openDevice(String deviceName) { - Device result = null; - ALC.Device realDevice = alc.alcOpenDevice(deviceName); - result = new Device(alc, realDevice); - - return result; + return result; + } + + /** + * Loads a Sound3D buffer with the specified audio file. + * + * @param filename the name of the file to load. + * + * @return a new Sound3D buffer containing the audio data from the + * specified file. + * + * @throws IOException If the file cannot be found or some other IO error + * occurs. + * @throws UnsupportedAudioFileException If the format of the sudio data is + * not supported + */ + public static Buffer loadBuffer(String filename) + throws IOException, UnsupportedAudioFileException { + Buffer result; + Buffer[] tmp = generateBuffers(1); + result = tmp[0]; + + WAVData wd = WAVLoader.loadFromFile(filename); + result.configure(wd.data, wd.format, wd.freq); + + return result; + } + + /** + * Loads a Sound3D Source with the specified audio file. This is + * functionally equivelant to generateSource(loadBuffer(fileName)); + * + * @param filename the name of the file to load. + * + * @return a new Sound3D Source containing the audio data from the + * specified file. + * + * @throws IOException If the file cannot be found or some other IO error + * occurs. + * @throws UnsupportedAudioFileException If the format of the sudio data is + * not supported + */ + public static Source loadSource(String filename) + throws IOException, UnsupportedAudioFileException { + Buffer buffer = loadBuffer(filename); + + return generateSource(buffer); + } + + /** + * Generates a set of uninitialized Source3D sources + * + * @param numSources the number of Sound3D sources to generate. + * + * @return an array of uninitialized sources. + */ + public static Source[] generateSources(int numSources) { + Source[] result = new Source[numSources]; + int[] arr = new int[numSources]; + al.alGenSources(numSources, arr, 0); + + for (int i = 0; i < numSources; i++) { + result[i] = new Source(al, arr[i]); } - /** - * Generate an array of Sound3D buffers. - * - * @param numBuffers The number of Sound3D buffers to generate. - * - * @return an array of (initially enpty) Sound3D buffers. - */ - public static Buffer[] generateBuffers(int numBuffers) { - Buffer[] result = new Buffer[numBuffers]; - int[] arr = new int[numBuffers]; - al.alGenBuffers(numBuffers, arr); - - for (int i = 0; i < numBuffers; i++) { - result[i] = new Buffer(al, arr[i]); - } - - return result; + return result; + } + + /** + * Generate a Sound3D source from an initialized Buffer. + * + * @param buff The buffer to generate the source from. + * + * @return the newly generated Source. + */ + public static Source generateSource(Buffer buff) { + Source result = null; + Source[] tmp = generateSources(1); + result = tmp[0]; + result.setBuffer(buff); + + return result; + } + + /** + * Get the listener object associated with this Sound3D environment. + * + * @return The listener object. + */ + public static Listener getListener() { + if (listener == null) { + listener = new Listener(al); } - /** - * Loads a Sound3D buffer with the specified audio file. - * - * @param filename the name of the file to load. - * - * @return a new Sound3D buffer containing the audio data from the - * specified file. - * - * @throws IOException If the file cannot be found or some other IO error - * occurs. - * @throws UnsupportedAudioFileException If the format of the sudio data is - * not supported - */ - public static Buffer loadBuffer(String filename) - throws IOException, UnsupportedAudioFileException { - Buffer result; - Buffer[] tmp = generateBuffers(1); - result = tmp[0]; - - WAVData wd = WAVLoader.loadFromFile(filename); - result.configure(wd.data, wd.format, wd.freq); - - return result; - } - - /** - * Loads a Sound3D Source with the specified audio file. This is - * functionally equivelant to generateSource(loadBuffer(fileName)); - * - * @param filename the name of the file to load. - * - * @return a new Sound3D Source containing the audio data from the - * specified file. - * - * @throws IOException If the file cannot be found or some other IO error - * occurs. - * @throws UnsupportedAudioFileException If the format of the sudio data is - * not supported - */ - public static Source loadSource(String filename) - throws IOException, UnsupportedAudioFileException { - Buffer buffer = loadBuffer(filename); - - return generateSource(buffer); - } - - /** - * Generates a set of uninitialized Source3D sources - * - * @param numSources the number of Sound3D sources to generate. - * - * @return an array of uninitialized sources. - */ - public static Source[] generateSources(int numSources) { - Source[] result = new Source[numSources]; - int[] arr = new int[numSources]; - al.alGenSources(numSources, arr); - - for (int i = 0; i < numSources; i++) { - result[i] = new Source(al, arr[i]); - } - - return result; - } - - /** - * Generate a Sound3D source from an initialized Buffer. - * - * @param buff The buffer to generate the source from. - * - * @return the newly generated Source. - */ - public static Source generateSource(Buffer buff) { - Source result = null; - Source[] tmp = generateSources(1); - result = tmp[0]; - result.setBuffer(buff); - - return result; - } - - /** - * Get the listener object associated with this Sound3D environment. - * - * @return The listener object. - */ - public static Listener getListener() { - if (listener == null) { - listener = new Listener(al); - } - - return listener; - } + return listener; + } } diff --git a/src/java/net/java/games/sound3d/Buffer.java b/src/java/net/java/games/sound3d/Buffer.java index cd666ae..70ad188 100644 --- a/src/java/net/java/games/sound3d/Buffer.java +++ b/src/java/net/java/games/sound3d/Buffer.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -81,7 +81,7 @@ public class Buffer { */ public void delete() { data = null; - al.alDeleteBuffers(1, new int[] { bufferID }); + al.alDeleteBuffers(1, new int[] { bufferID }, 0); } /** @@ -91,7 +91,7 @@ public class Buffer { */ public int getBitDepth() { int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_BITS, i); + al.alGetBufferi(bufferID, AL.AL_BITS, i, 0); return i[0]; } @@ -103,7 +103,7 @@ public class Buffer { */ public int getNumChannels() { int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_CHANNELS, i); + al.alGetBufferi(bufferID, AL.AL_CHANNELS, i, 0); return i[0]; } @@ -124,7 +124,7 @@ public class Buffer { */ public int getFrequency() { int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_FREQUENCY, i); + al.alGetBufferi(bufferID, AL.AL_FREQUENCY, i, 0); return i[0]; } @@ -136,7 +136,7 @@ public class Buffer { */ public int getSize() { int[] i = new int[1]; - al.alGetBufferi(bufferID, AL.AL_SIZE, i); + al.alGetBufferi(bufferID, AL.AL_SIZE, i, 0); return i[0]; } diff --git a/src/java/net/java/games/sound3d/Context.java b/src/java/net/java/games/sound3d/Context.java index 8b442a6..49344cd 100644 --- a/src/java/net/java/games/sound3d/Context.java +++ b/src/java/net/java/games/sound3d/Context.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -33,7 +33,7 @@ package net.java.games.sound3d; -import net.java.games.joal.ALC; +import net.java.games.joal.*; /** @@ -43,10 +43,10 @@ import net.java.games.joal.ALC; */ public class Context { private final ALC alc; - final ALC.Context realContext; + final ALCcontext realContext; final Device device; - Context(ALC alc, ALC.Context realContext, Device device) { + Context(ALC alc, ALCcontext realContext, Device device) { this.alc = alc; this.realContext = realContext; this.device = device; diff --git a/src/java/net/java/games/sound3d/Device.java b/src/java/net/java/games/sound3d/Device.java index 44879a3..96c352b 100644 --- a/src/java/net/java/games/sound3d/Device.java +++ b/src/java/net/java/games/sound3d/Device.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -33,7 +33,7 @@ package net.java.games.sound3d; -import net.java.games.joal.ALC; +import net.java.games.joal.*; /** @@ -43,9 +43,9 @@ import net.java.games.joal.ALC; */ public class Device { private final ALC alc; - final ALC.Device realDevice; + final ALCdevice realDevice; - Device(ALC alc, ALC.Device realDevice) { + Device(ALC alc, ALCdevice realDevice) { this.alc = alc; this.realDevice = realDevice; } diff --git a/src/java/net/java/games/sound3d/Listener.java b/src/java/net/java/games/sound3d/Listener.java index d80c8d0..b25320c 100644 --- a/src/java/net/java/games/sound3d/Listener.java +++ b/src/java/net/java/games/sound3d/Listener.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -68,7 +68,7 @@ public class Listener { */ public float getGain() { float[] f = new float[1]; - al.alGetListenerf(AL.AL_GAIN, f); + al.alGetListenerf(AL.AL_GAIN, f, 0); return f[0]; } @@ -109,7 +109,7 @@ public class Listener { public Vec3f getPosition() { Vec3f result = null; float[] tmp = new float[3]; - al.alGetListenerfv(AL.AL_POSITION, tmp); + al.alGetListenerfv(AL.AL_POSITION, tmp, 0); result = new Vec3f(tmp[0], tmp[1], tmp[2]); return result; @@ -136,7 +136,7 @@ public class Listener { public Vec3f getVelocity() { Vec3f result = null; float[] tmp = new float[3]; - al.alGetListenerfv(AL.AL_VELOCITY, tmp); + al.alGetListenerfv(AL.AL_VELOCITY, tmp, 0); result = new Vec3f(tmp[0], tmp[1], tmp[2]); return result; @@ -151,7 +151,7 @@ public class Listener { * look-at vector. */ public void setOrientation(float[] orientation) { - al.alListenerfv(AL.AL_ORIENTATION, orientation); + al.alListenerfv(AL.AL_ORIENTATION, orientation, 0); } /** @@ -165,7 +165,7 @@ public class Listener { */ public float[] getOrientation() { float[] tmp = new float[6]; - al.alGetListenerfv(AL.AL_ORIENTATION, tmp); + al.alGetListenerfv(AL.AL_ORIENTATION, tmp, 0); return tmp; } } diff --git a/src/java/net/java/games/sound3d/Sound3DException.java b/src/java/net/java/games/sound3d/Sound3DException.java deleted file mode 100644 index 6b927ca..0000000 --- a/src/java/net/java/games/sound3d/Sound3DException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Created on Nov 22, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package net.java.games.sound3d; - -/** - * @author athomas - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class Sound3DException extends Exception { - - /** - * - */ - public Sound3DException() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * @param arg0 - */ - public Sound3DException(String arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } - - /** - * @param arg0 - */ - public Sound3DException(Throwable arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } - - /** - * @param arg0 - * @param arg1 - */ - public Sound3DException(String arg0, Throwable arg1) { - super(arg0, arg1); - // TODO Auto-generated constructor stub - } - -} diff --git a/src/java/net/java/games/sound3d/Source.java b/src/java/net/java/games/sound3d/Source.java index 5e4183d..f5655be 100644 --- a/src/java/net/java/games/sound3d/Source.java +++ b/src/java/net/java/games/sound3d/Source.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -85,7 +85,7 @@ public final class Source { * Delete this source, freeing its resources. */ public void delete() { - al.alDeleteSources(1, new int[] { sourceID }); + al.alDeleteSources(1, new int[] { sourceID }, 0); } /** @@ -106,7 +106,7 @@ public final class Source { */ public float getPitch() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_PITCH, result); + al.alGetSourcef(sourceID, AL.AL_PITCH, result, 0); return result[0]; } @@ -129,7 +129,7 @@ public final class Source { */ public float getGain() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_GAIN, result); + al.alGetSourcef(sourceID, AL.AL_GAIN, result, 0); return result[0]; } @@ -152,7 +152,7 @@ public final class Source { */ public float getMaxDistance() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_MAX_DISTANCE, result); + al.alGetSourcef(sourceID, AL.AL_MAX_DISTANCE, result, 0); return result[0]; } @@ -173,7 +173,7 @@ public final class Source { */ public float getRolloffFactor() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_ROLLOFF_FACTOR, result); + al.alGetSourcef(sourceID, AL.AL_ROLLOFF_FACTOR, result, 0); return result[0]; } @@ -196,7 +196,7 @@ public final class Source { */ public float getReferenceDistance() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_REFERENCE_DISTANCE, result); + al.alGetSourcef(sourceID, AL.AL_REFERENCE_DISTANCE, result, 0); return result[0]; } @@ -217,7 +217,7 @@ public final class Source { */ public float getMinGain() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_MIN_GAIN, result); + al.alGetSourcef(sourceID, AL.AL_MIN_GAIN, result, 0); return result[0]; } @@ -238,7 +238,7 @@ public final class Source { */ public float getMaxGain() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_MAX_GAIN, result); + al.alGetSourcef(sourceID, AL.AL_MAX_GAIN, result, 0); return result[0]; } @@ -259,7 +259,7 @@ public final class Source { */ public float getConeOuterGain() { float[] result = new float[1]; - al.alGetSourcef(sourceID, AL.AL_CONE_OUTER_GAIN, result); + al.alGetSourcef(sourceID, AL.AL_CONE_OUTER_GAIN, result, 0); return result[0]; } @@ -299,7 +299,7 @@ public final class Source { public Vec3f getPosition() { Vec3f result = null; float[] pos = new float[3]; - al.alGetSourcefv(sourceID, AL.AL_POSITION, pos); + al.alGetSourcefv(sourceID, AL.AL_POSITION, pos, 0); result = new Vec3f(pos[0], pos[1], pos[2]); return result; @@ -338,7 +338,7 @@ public final class Source { public Vec3f getVelocity() { Vec3f result = null; float[] vel = new float[3]; - al.alGetSourcefv(sourceID, AL.AL_VELOCITY, vel); + al.alGetSourcefv(sourceID, AL.AL_VELOCITY, vel, 0); result = new Vec3f(vel[0], vel[1], vel[2]); return result; @@ -377,7 +377,7 @@ public final class Source { public Vec3f getDirection() { Vec3f result = null; float[] dir = new float[3]; - al.alGetSourcefv(sourceID, AL.AL_DIRECTION, dir); + al.alGetSourcefv(sourceID, AL.AL_DIRECTION, dir, 0); result = new Vec3f(dir[0], dir[1], dir[2]); return result; @@ -404,7 +404,7 @@ public final class Source { */ public boolean isSourceRelative() { int[] result = new int[1]; - al.alGetSourcei(sourceID, AL.AL_SOURCE_RELATIVE, result); + al.alGetSourcei(sourceID, AL.AL_SOURCE_RELATIVE, result, 0); return result[0] == 1; } @@ -427,7 +427,7 @@ public final class Source { public boolean getLooping() { boolean result = false; int[] tmp = new int[1]; - al.alGetSourcei(sourceID, AL.AL_LOOPING, tmp); + al.alGetSourcei(sourceID, AL.AL_LOOPING, tmp, 0); return tmp[0] == AL.AL_TRUE; } @@ -438,7 +438,7 @@ public final class Source { */ public int getBuffersQueued() { int[] result = new int[1]; - al.alGetSourcei(sourceID, AL.AL_BUFFERS_QUEUED, result); + al.alGetSourcei(sourceID, AL.AL_BUFFERS_QUEUED, result, 0); return result[0]; } @@ -449,7 +449,7 @@ public final class Source { */ public int getBuffersProcessed() { int[] result = new int[1]; - al.alGetSourcei(sourceID, AL.AL_BUFFERS_PROCESSED, result); + al.alGetSourcei(sourceID, AL.AL_BUFFERS_PROCESSED, result, 0); return result[0]; } @@ -487,7 +487,7 @@ public final class Source { arr[i] = buffers[i].bufferID; } - al.alSourceQueueBuffers(sourceID, numBuffers, arr); + al.alSourceQueueBuffers(sourceID, numBuffers, arr, 0); } /** @@ -503,6 +503,6 @@ public final class Source { arr[i] = buffers[i].bufferID; } - al.alSourceUnqueueBuffers(sourceID, numBuffers, arr); + al.alSourceUnqueueBuffers(sourceID, numBuffers, arr, 0); } } diff --git a/src/java/net/java/games/sound3d/Vec3f.java b/src/java/net/java/games/sound3d/Vec3f.java index f6f494b..71b1d92 100644 --- a/src/java/net/java/games/sound3d/Vec3f.java +++ b/src/java/net/java/games/sound3d/Vec3f.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT diff --git a/src/native/albind.c b/src/native/albind.c deleted file mode 100644 index 023f235..0000000 --- a/src/native/albind.c +++ /dev/null @@ -1,720 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - - -#include "albind.h" -#include "extal.h" - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenBuffersNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numBuffers, jobject buffers) { - if(buffers == 0) { - - } - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,buffers); - alGenBuffers((ALsizei)numBuffers,p); -} -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenBuffersNative__I_3I - (JNIEnv *env, jobject obj, jint numBuffers, jintArray buffers) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,buffers,0); - if(p) { - alGenBuffers((ALsizei)numBuffers,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,buffers,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteBuffersNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numBuffers, jobject buffers) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,buffers); - if(p) { - alDeleteBuffers((ALsizei)numBuffers,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteBuffersNative__I_3I - (JNIEnv *env, jobject obj, jint numBuffers, jintArray buffers) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,buffers,0); - if(p) { - alDeleteBuffers((ALsizei)numBuffers,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,buffers,p,0); -} - -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsBuffer - (JNIEnv *env, jobject obj, jint bufferName) { - jboolean result; - result = alIsBuffer((ALuint)bufferName); - return result; -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alBufferDataNative__IILjava_nio_ByteBuffer_2II - (JNIEnv *env, - jobject obj, - jint bufferName, - jint format, - jobject data, - jint size, - jint frequency) { - ALvoid *p = (ALvoid*)(*env)->GetDirectBufferAddress(env,data); - if(p) { - alBufferData((ALuint)bufferName, - (ALenum)format, - p, - (ALsizei)size, - (ALsizei)frequency); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alBufferDataNative__II_3BII - (JNIEnv *env, - jobject obj, - jint bufferName, - jint format, - jbyteArray data, - jint size, - jint frequency) { - ALvoid *p = (ALvoid*)(*env)->GetPrimitiveArrayCritical(env,data,0); - if(p) { - alBufferData((ALuint)bufferName, - (ALenum)format, - p, - (ALsizei)size, - (ALsizei)frequency); - } - (*env)->ReleasePrimitiveArrayCritical(env,data,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferfNative__II_3F - (JNIEnv *env, jobject obj, jint buffer, jint pname, jfloatArray rv) { - ALfloat *result = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,rv,0); - alGetBufferf((ALuint)buffer, (ALenum)pname, result); - (*env)->ReleasePrimitiveArrayCritical(env,rv,result,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferfNative__IILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint buffer, jint pname, jobject rv) { - ALfloat *p = (ALfloat*)(*env)->GetDirectBufferAddress(env,rv); - if(p) { - alGetBufferf((ALuint)buffer, (ALenum)pname, p); - } -} - -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetBufferf__II - (JNIEnv *env, jobject obj, jint buffer, jint pname) { - jfloat result; - alGetBufferf((ALuint)buffer, (ALenum)pname, &result); - return result; -} - - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferiNative__II_3I - (JNIEnv *env, jobject obj, jint buffer, jint pname, jintArray rv) { - ALint *p = (ALint*)(*env)->GetPrimitiveArrayCritical(env,rv,0); - if(p) { - alGetBufferi((ALuint)buffer, (ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,rv,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferiNative__IILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint buffer, jint pname, jobject rv) { - ALint *p = (ALint*)(*env)->GetDirectBufferAddress(env,rv); - if(p) { - alGetBufferi((ALuint)buffer, (ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,rv,p,0); -} - -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetBufferi__II - (JNIEnv *env, jobject obj, jint buffer, jint pname) { - ALint result; - alGetBufferi((ALuint)buffer, (ALenum)pname, &result); - return (jint)result; -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenSourcesNative__I_3I - (JNIEnv *env, jobject obj, jint numSources, jintArray sources) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,sources,0); - if(p) { - alGenSources((ALsizei)numSources,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,sources,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenSourcesNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numSources, jobject sources) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,sources); - if(p) { - alGenSources((ALsizei)numSources,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteSourcesNative__I_3I - (JNIEnv *env, jobject obj, jint numSources, jintArray sources) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,sources,0); - if(p) { - alDeleteSources((ALsizei)numSources, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,sources,p,0); -} - -/* - * Class: net_java_games_joal_AL - * Method: alDeleteSources - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteSourcesNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numSources, jobject sources) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,sources); - if(p) { - alDeleteSources((ALsizei)numSources, p); - } -} - -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsSource - (JNIEnv *env, jobject obj, jint sourceName) { - alIsSource((ALuint)sourceName); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcei - (JNIEnv *env, jobject obj, jint source, jint pname, jint value) { - alSourcei((ALuint)source,(ALenum)pname, (ALint)value); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcef - (JNIEnv *env, jobject obj, jint source, jint pname, jfloat value) { - alSourcef((ALuint)source,(ALenum)pname, (ALfloat)value); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcefvNative__II_3F - (JNIEnv *env, jobject obj, jint source, jint pname, jfloatArray value) { - ALfloat *p = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,value,0); - if(p) { - alSourcefv((ALuint)source, (ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,value,p,0); -} - -/* - * Class: net_java_games_joal_AL - * Method: alSourcefv - * Signature: (IILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcefvNative__IILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint source, jint pname, jobject value) { - ALfloat *p = (ALfloat*)(*env)->GetDirectBufferAddress(env,value); - alSourcefv((ALuint)source, (ALenum)pname, p); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSource3f - (JNIEnv *env, - jobject obj, - jint source, - jint pname, - jfloat v1, - jfloat v2, - jfloat v3) { - alSource3f((ALuint)source, - (ALenum)pname, - (ALfloat)v1, - (ALfloat)v2, - (ALfloat)v3); -} - - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefNative__II_3F - (JNIEnv *env, jobject obj, jint source, jint pname, jfloatArray rv) { - ALfloat *p = (*env)->GetPrimitiveArrayCritical(env,rv,0); - if(p) { - alGetSourcef((ALuint)source, (ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,rv,p,0); -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetSourcef - * Signature: (IILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefNative__IILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint source, jint pname, jobject rv) { - ALfloat *p = (*env)->GetDirectBufferAddress(env,rv); - if(p) { - alGetSourcef((ALuint)source, (ALenum)pname, p); - } -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetSourcef - * Signature: (II)F - */ -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetSourcef__II - (JNIEnv *env, jobject obj, jint source, jint pname) { - jfloat result; - alGetSourcef((ALuint)source, (ALenum)pname, &result); - return result; -} - - - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefvNative__IILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint source, jint pname, jobject value) { - ALfloat *p = (ALfloat*)(*env)->GetDirectBufferAddress(env,value); - if(p) { - alGetSourcefv((ALuint)source, (ALenum)pname, p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefvNative__II_3F - (JNIEnv *env, jobject obj, jint source, jint pname, jfloatArray value) { - ALfloat *p = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,value,0); - if(p) { - alGetSourcefv((ALuint)source, (ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,value,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourceiNative__II_3I - (JNIEnv *env, jobject obj, jint source, jint pname, jintArray rv) { - ALint *p = (ALint*)(*env)->GetPrimitiveArrayCritical(env,rv,0); - if(p) { - alGetSourcei((ALuint)source, (ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,rv,p,0); -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetSourcei - * Signature: (IILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourceiNative__IILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint source, jint pname, jobject rv) { - ALint *p = (ALint*)(*env)->GetDirectBufferAddress(env,rv); - if(p) { - alGetSourcei((ALuint)source, (ALenum)pname, p); - } -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetSourcei - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetSourcei__II - (JNIEnv *env, jobject obj, jint source, jint pname) { - ALint result; - alGetSourcei((ALuint)source, (ALenum)pname, &result); - return (jint)result; -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePlay - (JNIEnv *env, jobject obj, jint source) { - alSourcePlay((ALuint)source); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePlayvNative__I_3I - (JNIEnv *env, jobject obj, jint numSources, jintArray sources) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,sources,0); - if(p) { - alSourcePlayv((ALsizei)numSources,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,sources,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePlayvNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numSources, jobject sources) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,sources); - if(p) { - alSourcePlayv((ALsizei)numSources,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePause - (JNIEnv *env, jobject obj, jint source) { - alSourcePause((ALuint)source); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePausevNative__I_3I - (JNIEnv *env, jobject obj, jint numSources, jintArray sources) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,sources,0); - if(p) { - alSourcePausev((ALsizei)numSources,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,sources,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePausevNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numSources, jobject sources) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,sources); - if(p) { - alSourcePausev((ALsizei)numSources,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceStop - (JNIEnv *env, jobject obj, jint source) { - alSourceStop((ALuint)source); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceStopvNative__I_3I - (JNIEnv *env, jobject obj, jint numSources, jintArray sources) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,sources,0); - if(p) { - alSourceStopv((ALsizei)numSources,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,sources,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceStopvNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numSources, jobject sources) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,sources); - if(p) { - alSourceStopv((ALsizei)numSources,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceRewind - (JNIEnv *env, jobject obj, jint source) { - alSourceRewind((ALuint)source); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceRewindvNative__I_3I - (JNIEnv *env, jobject obj, jint numSources, jintArray sources) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,sources,0); - if(p) { - alSourceRewindv((ALsizei)numSources,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,sources,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceRewindvNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint numSources, jobject sources) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,sources); - if(p) { - alSourceRewindv((ALsizei)numSources,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceQueueBuffersNative__IILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint source, jint numBuffers, jobject buffers) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,buffers); - if(p) { - alSourceQueueBuffers((ALuint)source, (ALsizei)numBuffers, p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceQueueBuffersNative__II_3I - (JNIEnv *env, jobject obj, jint source, jint numBuffers, jintArray buffers) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,buffers,0); - if(p) { - alSourceQueueBuffers((ALuint)source, (ALsizei)numBuffers, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,buffers,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceUnqueueBuffersNative__II_3I - (JNIEnv *env, jobject obj, jint source, jint numBuffers, jintArray buffers) { - ALuint *p = (ALuint*)(*env)->GetPrimitiveArrayCritical(env,buffers,0); - if(p) { - alSourceUnqueueBuffers((ALuint)source, (ALsizei)numBuffers, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,buffers,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceUnqueueBuffersNative__IILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint source, jint numBuffers, jobject buffers) { - ALuint *p = (ALuint*)(*env)->GetDirectBufferAddress(env,buffers); - if(p) { - alSourceUnqueueBuffers((ALuint)source, (ALsizei)numBuffers, p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListenerf - (JNIEnv *env, jobject obj, jint pname, jfloat value) { - alListenerf((ALenum)pname,(ALfloat)value); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListener3f - (JNIEnv *env, jobject obj, jint pname, jfloat v1, jfloat v2, jfloat v3) { - alListener3f((ALenum)pname, (ALfloat)v1, (ALfloat)v2, (ALfloat)v3); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListenerfvNative__I_3F - (JNIEnv *env, jobject obj, jint pname, jfloatArray rv) { - ALfloat *p = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,rv,0); - alListenerfv((ALenum)pname, p); - (*env)->ReleasePrimitiveArrayCritical(env,rv,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListenerfvNative__ILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject value) { - ALfloat *p = (ALfloat*)(*env)->GetDirectBufferAddress(env,value); - alListenerfv((ALenum)pname, p); -} - - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfNative__I_3F - (JNIEnv *env, jobject obj, jint pname, jfloatArray rv) { - ALfloat *p = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,rv,0); - if(p) { - alGetListenerf((ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,rv,p,0); -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetListenerf - * Signature: (ILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfNative__ILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject rv) { - ALfloat *p = (ALfloat*)(*env)->GetDirectBufferAddress(env,rv); - if(p) { - alGetListenerf((ALenum)pname, p); - } -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetListenerf - * Signature: (I)F - */ -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetListenerf__I - (JNIEnv *env, jobject object, jint pname) { - jfloat result; - alGetListenerf((ALenum)pname, &result); - return result; -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListener3fNative__I_3F_3F_3F - (JNIEnv *env, jobject obj, jint pname, jfloatArray v1, jfloatArray v2, jfloatArray v3) { - ALfloat *p1 = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,v1,0); - ALfloat *p2 = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,v2,0); - ALfloat *p3 = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,v3,0); - if(p1 && p2 && p3) { - alGetListener3f((ALenum)pname, p1, p2, p3); - } - (*env)->ReleasePrimitiveArrayCritical(env,v3,p3,0); - (*env)->ReleasePrimitiveArrayCritical(env,v2,p2,0); - (*env)->ReleasePrimitiveArrayCritical(env,v1,p1,0); -} - - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListener3fNative__ILjava_nio_FloatBuffer_2Ljava_nio_FloatBuffer_2Ljava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject v1, jobject v2, jobject v3) { - ALfloat *p1 = (ALfloat*)(*env)->GetDirectBufferAddress(env,v1); - ALfloat *p2 = (ALfloat*)(*env)->GetDirectBufferAddress(env,v2); - ALfloat *p3 = (ALfloat*)(*env)->GetDirectBufferAddress(env,v3); - if(p1 && p2 && p3) { - alGetListener3f((ALenum)pname, p1, p2, p3); - } -} - - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfvNative__I_3F - (JNIEnv *env, jobject obj, jint pname, jfloatArray value) { - ALfloat *p = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,value,0); - if(p) { - alGetListenerfv((ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,value,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfvNative__ILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject value) { - ALfloat *p = (ALfloat*)(*env)->GetDirectBufferAddress(env,value); - if(p) { - alGetListenerfv((ALenum)pname, p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListeneriNative__I_3I - (JNIEnv *env, jobject obj, jint pname, jintArray value) { - ALint *p = (ALint*)(*env)->GetPrimitiveArrayCritical(env,value,0); - if(p) { - alGetListeneri((ALenum)pname, p); - } - (*env)->ReleasePrimitiveArrayCritical(env,value,p,0); - -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetListeneri - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListeneriNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject value) { - ALint *p = (ALint*)(*env)->GetDirectBufferAddress(env,value); - if(p) { - alGetListeneri((ALenum)pname, p); - } -} - -/* - * Class: net_java_games_joal_AL - * Method: alGetListeneri - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetListeneri__I - (JNIEnv *env, jobject obj, jint pname) { - ALint result; - alGetListeneri((ALenum)pname, &result); - return (jint)result; -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alEnable - (JNIEnv *env, jobject obj, jint capability) { - alEnable((ALenum)capability); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDisable - (JNIEnv *env, jobject obj, jint capability) { - alDisable((ALenum)capability); -} - -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsEnabled - (JNIEnv *env, jobject obj, jint pname) { - return alIsEnabled((ALenum)pname); -} - -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alGetBoolean - (JNIEnv *env, jobject obj, jint pname) { - return alGetBoolean((ALenum)pname); -} - -JNIEXPORT jdouble JNICALL Java_net_java_games_joal_ALImpl_alGetDouble - (JNIEnv *env, jobject obj, jint pname) { - return alGetDouble((ALenum)pname); -} - -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetFloat - (JNIEnv *env, jobject obj, jint pname) { - return alGetFloat((ALenum)pname); -} - -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetInteger - (JNIEnv *env, jobject obj, jint pname) { - return alGetInteger((ALenum)pname); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetDoublevNative__I_3D - (JNIEnv *env, jobject obj, jint pname, jdoubleArray value) { - ALdouble *p = (ALdouble*)(*env)->GetPrimitiveArrayCritical(env,value,0); - if(p) { - alGetDoublev((ALenum)pname,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,value,p,0); - -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetDoublevNative__ILjava_nio_DoubleBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject value) { - ALdouble *p = (ALdouble*)(*env)->GetDirectBufferAddress(env,value); - if(p) { - alGetDoublev((ALenum)pname,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetFloatvNative__I_3F - (JNIEnv *env, jobject obj, jint pname, jfloatArray value) { - ALfloat *p = (ALfloat*)(*env)->GetPrimitiveArrayCritical(env,value,0); - if(p) { - alGetFloatv((ALenum)pname,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,value,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetFloatvNative__ILjava_nio_FloatBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject value) { - ALfloat *p = (ALfloat*)(*env)->GetDirectBufferAddress(env,value); - if(p) { - alGetFloatv((ALenum)pname,p); - } -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetIntegervNative__I_3I - (JNIEnv *env, jobject obj, jint pname, jintArray value) { - ALint *p = (ALint*)(*env)->GetPrimitiveArrayCritical(env,value,0); - if(p) { - alGetIntegerv((ALenum)pname,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,value,p,0); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetIntegervNative__ILjava_nio_IntBuffer_2 - (JNIEnv *env, jobject obj, jint pname, jobject value) { - ALint *p = (ALint*)(*env)->GetDirectBufferAddress(env,value); - if(p) { - alGetIntegerv((ALenum)pname,p); - } -} - - -JNIEXPORT jstring JNICALL Java_net_java_games_joal_ALImpl_alGetString - (JNIEnv *env, jobject obj, jint pname) { - ALubyte* p = alGetString((ALenum)pname); - return (*env)->NewStringUTF(env, p); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDistanceModel - (JNIEnv *env, jobject obj, jint value) { - alDistanceModel((ALenum)value); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDopplerFactor - (JNIEnv *env, jobject obj, jfloat value) { - alDopplerFactor((ALfloat)value); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDopplerVelocity - (JNIEnv *env, jobject obj, jfloat value) { - alDopplerVelocity((ALfloat)value); -} - -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetError - (JNIEnv *env, jobject obj) { - return alGetError(); -} - -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsExtensionPresent - (JNIEnv *env, jobject obj, jstring extName) { - ALubyte *str; - str = (ALubyte*)(*env)->GetStringUTFChars(env, extName, NULL); - if(!str) { - return 0; - } - return alIsExtensionPresent(str); -} diff --git a/src/native/albind.h b/src/native/albind.h deleted file mode 100644 index fd64846..0000000 --- a/src/native/albind.h +++ /dev/null @@ -1,703 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - - -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class net_java_games_joal_ALImpl */ - -#ifndef _Included_net_java_games_joal_ALImpl -#define _Included_net_java_games_joal_ALImpl -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: net_java_games_joal_ALImpl - * Method: alGenBuffersNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenBuffersNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGenBuffersNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenBuffersNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDeleteBuffersNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteBuffersNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDeleteBuffersNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteBuffersNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alIsBuffer - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsBuffer - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alBufferDataNative - * Signature: (II[BII)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alBufferDataNative__II_3BII - (JNIEnv *, jobject, jint, jint, jbyteArray, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alBufferDataNative - * Signature: (IILjava/nio/ByteBuffer;II)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alBufferDataNative__IILjava_nio_ByteBuffer_2II - (JNIEnv *, jobject, jint, jint, jobject, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetBufferfNative - * Signature: (II[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferfNative__II_3F - (JNIEnv *, jobject, jint, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetBufferfNative - * Signature: (IILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferfNative__IILjava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetBufferf - * Signature: (II)F - */ -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetBufferf - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetBufferiNative - * Signature: (II[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferiNative__II_3I - (JNIEnv *, jobject, jint, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetBufferiNative - * Signature: (IILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetBufferiNative__IILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetBufferi - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetBufferi - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGenSourcesNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenSourcesNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGenSourcesNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGenSourcesNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDeleteSourcesNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteSourcesNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDeleteSourcesNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDeleteSourcesNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alIsSource - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsSource - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcei - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcei - (JNIEnv *, jobject, jint, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcef - * Signature: (IIF)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcef - (JNIEnv *, jobject, jint, jint, jfloat); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcefv - * Signature: (II[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcefv - (JNIEnv *, jobject, jint, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcefvNative - * Signature: (IILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcefvNative - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSource3f - * Signature: (IIFFF)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSource3f - (JNIEnv *, jobject, jint, jint, jfloat, jfloat, jfloat); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourcefNative - * Signature: (II[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefNative__II_3F - (JNIEnv *, jobject, jint, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourcefNative - * Signature: (IILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefNative__IILjava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourcef - * Signature: (II)F - */ -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetSourcef - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourcefvNative - * Signature: (IILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefvNative__IILjava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourcefvNative - * Signature: (II[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourcefvNative__II_3F - (JNIEnv *, jobject, jint, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourceiNative - * Signature: (II[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourceiNative__II_3I - (JNIEnv *, jobject, jint, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourceiNative - * Signature: (IILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetSourceiNative__IILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetSourcei - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetSourcei - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcePlay - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePlay - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcePlayvNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePlayvNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcePlayvNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePlayvNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcePause - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePause - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcePausevNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePausevNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourcePausevNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourcePausevNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceStop - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceStop - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceStopvNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceStopvNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceStopvNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceStopvNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceRewind - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceRewind - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceRewindvNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceRewindvNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceRewindvNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceRewindvNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceQueueBuffersNative - * Signature: (II[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceQueueBuffersNative__II_3I - (JNIEnv *, jobject, jint, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceQueueBuffersNative - * Signature: (IILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceQueueBuffersNative__IILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceUnqueueBuffersNative - * Signature: (II[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceUnqueueBuffersNative__II_3I - (JNIEnv *, jobject, jint, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alSourceUnqueueBuffersNative - * Signature: (IILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alSourceUnqueueBuffersNative__IILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alListenerf - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListenerf - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alListener3f - * Signature: (IFFF)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListener3f - (JNIEnv *, jobject, jint, jfloat, jfloat, jfloat); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alListenerfv - * Signature: (I[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListenerfv__I_3F - (JNIEnv *, jobject, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alListenerfv - * Signature: (ILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListenerfv__ILjava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alListeneri - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alListeneri - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListenerfNative - * Signature: (I[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfNative__I_3F - (JNIEnv *, jobject, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListenerfNative - * Signature: (ILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfNative__ILjava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListenerf - * Signature: (I)F - */ -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetListenerf - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListener3fNative - * Signature: (ILjava/nio/FloatBuffer;Ljava/nio/FloatBuffer;Ljava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListener3fNative__ILjava_nio_FloatBuffer_2Ljava_nio_FloatBuffer_2Ljava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jobject, jobject, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListener3fNative - * Signature: (I[F[F[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListener3fNative__I_3F_3F_3F - (JNIEnv *, jobject, jint, jfloatArray, jfloatArray, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListenerfvNative - * Signature: (I[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfvNative__I_3F - (JNIEnv *, jobject, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListenerfvNative - * Signature: (ILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListenerfvNative__ILjava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListeneriNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListeneriNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListeneriNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetListeneriNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetListeneri - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetListeneri - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alEnable - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alEnable - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDisable - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDisable - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alIsEnabled - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsEnabled - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetBoolean - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alGetBoolean - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetDouble - * Signature: (I)D - */ -JNIEXPORT jdouble JNICALL Java_net_java_games_joal_ALImpl_alGetDouble - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetFloat - * Signature: (I)F - */ -JNIEXPORT jfloat JNICALL Java_net_java_games_joal_ALImpl_alGetFloat - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetInteger - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetInteger - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetDoublevNative - * Signature: (I[D)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetDoublevNative__I_3D - (JNIEnv *, jobject, jint, jdoubleArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetDoublevNative - * Signature: (ILjava/nio/DoubleBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetDoublevNative__ILjava_nio_DoubleBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetFloatvNative - * Signature: (I[F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetFloatvNative__I_3F - (JNIEnv *, jobject, jint, jfloatArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetFloatvNative - * Signature: (ILjava/nio/FloatBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetFloatvNative__ILjava_nio_FloatBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetIntegervNative - * Signature: (I[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetIntegervNative__I_3I - (JNIEnv *, jobject, jint, jintArray); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetIntegervNative - * Signature: (ILjava/nio/IntBuffer;)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alGetIntegervNative__ILjava_nio_IntBuffer_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetString - * Signature: (I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_net_java_games_joal_ALImpl_alGetString - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDistanceModel - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDistanceModel - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDopplerFactor - * Signature: (F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDopplerFactor - (JNIEnv *, jobject, jfloat); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alDopplerVelocity - * Signature: (F)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALImpl_alDopplerVelocity - (JNIEnv *, jobject, jfloat); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetError - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetError - (JNIEnv *, jobject); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alIsExtensionPresent - * Signature: (Ljava/lang/String;)Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALImpl_alIsExtensionPresent - (JNIEnv *, jobject, jstring); - -/* - * Class: net_java_games_joal_ALImpl - * Method: alGetEnumValue - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALImpl_alGetEnumValue - (JNIEnv *, jobject, jstring); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/native/alcbind.c b/src/native/alcbind.c deleted file mode 100644 index af5b2af..0000000 --- a/src/native/alcbind.c +++ /dev/null @@ -1,235 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - - -#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) { - printf("Entering openDeviceNative()\n"); - printf("In openDeviceNative() test 1\n"); - jint result; - ALubyte *str; - ALCdevice *device; - if(deviceName != NULL) { - printf("In openDeviceNative() test 2a.1\n"); - str = (ALubyte*)(*env)->GetStringUTFChars(env,deviceName,NULL); - printf("In openDeviceNative() test 2a.2 -- %i\n", *alcOpenDevice); - device = alcOpenDevice(str); - printf("In openDeviceNative() test 2a.3 -- %s - %i\n", str, (jint)device); - (*env)->ReleaseStringUTFChars(env,deviceName,str); - } else { - printf("In openDeviceNative() test 2b.1\n"); - device = alcOpenDevice(NULL); - printf("In openDeviceNative() test 2b.2 -- NULL - %i\n", (jint)device); - } - result = (jint)device; - printf("In openDeviceNative() test 3\n"); - printf("Exiting openDeviceNative()\n"); - return result; -} -*/ -JNIEXPORT jobject JNICALL Java_net_java_games_joal_ALCImpl_openDeviceNative - (JNIEnv *env, jobject obj, jstring deviceName) { - const char * tokenstring; - - jboolean isCopy = JNI_FALSE; - if(deviceName != NULL) { - tokenstring = ((*env)->GetStringUTFChars(env, deviceName, &isCopy)); - } else { - tokenstring = NULL; - } - - /* get device */ - ALCdevice* device = alcOpenDevice((ALubyte *) tokenstring); - - /* if error - cleanup and get out */ - if(device == NULL) { - if(tokenstring != NULL) { - // (*env)->ReleaseStringUTFChars(env, deviceName, tokenstring); - } - return NULL; - } - - /* get ready to create ALCdevice instance */ - jobject alcDevice_object = NULL; - jclass alcDevice_class = NULL; - jmethodID alcDevice_method = NULL; - - /* find class and constructor */ - alcDevice_class = (*env)->FindClass(env, "net/java/games/joal/ALC$Device"); - alcDevice_method = (*env)->GetMethodID(env, alcDevice_class, "<init>", "(I)V"); - - /* create instance */ - alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (int) device); - - /* clean up */ - if (tokenstring != NULL) - // (*env)->ReleaseStringUTFChars(env, deviceName, tokenstring); - - return alcDevice_object; -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_closeDeviceNative - (JNIEnv *env, jobject obj, jint pointer) { - ALCdevice* device = (ALCdevice*)pointer; - alcCloseDevice(device); -} -/* -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_createContextNative - (JNIEnv *env, jobject obj, jint pointer, jintArray attrs) { - ALCdevice* device = (ALCdevice*)pointer; - ALint* attrList = NULL; - if(attrs != NULL) { - attrList = (ALint*)(*env)->GetPrimitiveArrayCritical(env,attrs,0); - jint ctxPtr = (jint)alcCreateContext(device,attrList); - (*env)->ReleasePrimitiveArrayCritical(env,attrs,attrList,0); - return ctxPtr; - } else { - jint ctxPtr = (jint)alcCreateContext(device,NULL); - return ctxPtr; - } -} -*/ - -JNIEXPORT jobject JNICALL Java_net_java_games_joal_ALCImpl_createContextNative - (JNIEnv *env, jobject obj, jint deviceAddress, jintArray attrs) { - ALint* address = NULL; - - if(attrs != NULL) { - address = (ALint*)(*env)->GetPrimitiveArrayCritical(env,attrs,0); - } - ALCcontext* context = alcCreateContext((ALCdevice*)deviceAddress, address); - if(address != NULL) { - (*env)->ReleasePrimitiveArrayCritical(env,attrs,address,0); - } - /* if error - get out */ - if(context == NULL) { - return NULL; - } - - /* get ready to create ALCcontext instance */ - jobject alcContext_object = NULL; - jclass alcContext_class = NULL; - jmethodID alcContext_method = NULL; - - /* find class and constructor */ - alcContext_class = (*env)->FindClass(env, "net/java/games/joal/ALC$Context"); - alcContext_method = (*env)->GetMethodID(env, alcContext_class, "<init>", "(Lnet/java/games/joal/ALC;I)V"); - - /* create instance */ - alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, obj, (int) context); - - return alcContext_object; -} - - -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_makeContextCurrentNative - (JNIEnv *env, jobject obj, jint pointer) { - ALvoid* alcHandle = (ALvoid*)pointer; - alcMakeContextCurrent(alcHandle); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_processContextNative - (JNIEnv *env, jobject obj, jint pointer) { - ALvoid* alcHandle = (ALvoid*)pointer; - alcProcessContext(alcHandle); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_suspendContextNative - (JNIEnv *env, jobject obj, jint pointer) { - ALvoid* alcHandle = (ALvoid*)pointer; - alcSuspendContext(alcHandle); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_destroyContextNative - (JNIEnv *env, jobject obj, jint pointer) { - ALvoid* alcHandle = (ALvoid*)pointer; - alcDestroyContext(alcHandle); -} -/* -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_getError - (JNIEnv *env, jobject obj) { - jint result = 0; -// result = alcGetError(); - return result; -} -*/ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_getCurrentContextNative - (JNIEnv *env, jobject obj) { - jint result; - result = (jint)alcGetCurrentContext(); - return result; -} - -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_getEnumValueNative - (JNIEnv *env, jobject obj, jint pointer, jstring enumName) { - jint result; - ALCdevice* device = (ALCdevice*)pointer; - ALubyte* str; - str = (ALubyte*)(*env)->GetStringUTFChars(env,enumName,NULL); - result = alcGetEnumValue(device, str); - (*env)->ReleaseStringUTFChars(env,enumName,str); - return result; -} - -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_getContextsDeviceNative - (JNIEnv *env, jobject obj, jint ptr) { - jint result; - ALvoid* alcHandle = (ALvoid*)ptr; - result = (jint)alcGetContextsDevice(alcHandle); - return result; -} -JNIEXPORT jstring JNICALL Java_net_java_games_joal_ALCImpl_alcGetStringNative - (JNIEnv *env, jobject obj, jint ptr, jint pname) { - ALCdevice *device = (ALCdevice*)ptr; - ALubyte* p = alcGetString(device,(ALenum)pname); - return (*env)->NewStringUTF(env, p); -} - -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_alcGetIntegervNative - (JNIEnv *env, jobject obj, jint ptr, jint pname, jint size, jintArray data) { - ALint *p = (ALint*)(*env)->GetPrimitiveArrayCritical(env,data,0); - ALCdevice *device = (ALCdevice*)ptr; - if(p) { - alcGetIntegerv(device,(ALenum)pname,(ALsizei)size,p); - } - (*env)->ReleasePrimitiveArrayCritical(env,data,p,0); -} diff --git a/src/native/alcbind.h b/src/native/alcbind.h deleted file mode 100644 index 911940b..0000000 --- a/src/native/alcbind.h +++ /dev/null @@ -1,160 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ -#include <jni.h> -/* Header for class net_java_games_joal_ALCImpl */ - -#ifndef _Included_net_java_games_joal_ALCImpl -#define _Included_net_java_games_joal_ALCImpl -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: net_java_games_joal_ALCImpl - * Method: openDeviceNative - * Signature: (Ljava/lang/String;)I - */ - /* -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_openDeviceNative - (JNIEnv *, jobject, jstring); -*/ -/* - * Class: net_java_games_joal_ALCImpl - * Method: openDeviceNative - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jobject JNICALL Java_net_java_games_joal_ALCImpl_openDeviceNative - (JNIEnv *, jobject, jstring); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: closeDeviceNative - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_closeDeviceNative - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: createContextNative - * Signature: (I[I)I - */ -/* -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_createContextNative - (JNIEnv *, jobject, jint, jintArray); -*/ -JNIEXPORT jobject JNICALL Java_net_java_games_joal_ALCImpl_createContextNative - (JNIEnv *, jobject, jint, jintArray); -/* - * Class: net_java_games_joal_ALCImpl - * Method: makeContextCurrentNative - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_makeContextCurrentNative - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: processContextNative - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_processContextNative - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: suspendContextNative - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_suspendContextNative - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: destroyContextNative - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_destroyContextNative - (JNIEnv *, jobject, jint); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: alcGetError - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_alcGetErrorNative - (JNIEnv *, jobject, jint pointer); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: getCurrentContextNative - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_getCurrentContextNative - (JNIEnv *, jobject); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: getEnumValueNative - * Signature: (ILjava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_getEnumValueNative - (JNIEnv *, jobject, jint, jstring); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: alcGetStringNative - * Signature: (II)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_net_java_games_joal_ALCImpl_alcGetStringNative - (JNIEnv *, jobject, jint, jint); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: alcGetIntegervNative - * Signature: (III[I)V - */ -JNIEXPORT void JNICALL Java_net_java_games_joal_ALCImpl_alcGetIntegervNative - (JNIEnv *, jobject, jint, jint, jint, jintArray); - -/* - * Class: net_java_games_joal_ALCImpl - * Method: getContextDeviceNative - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_net_java_games_joal_ALCImpl_getContextDeviceNative - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/native/alfactory.c b/src/native/alfactory.c deleted file mode 100644 index a497c0c..0000000 --- a/src/native/alfactory.c +++ /dev/null @@ -1,50 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - -#include "alfactory.h" -#include "extal.h" -#include "jni.h" - -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALFactory_init - (JNIEnv *env , jclass clazz, jobjectArray oalPaths) { - printf("ALFactory.init - Native: Enter\n"); - InitializeOpenAL(env,oalPaths); - printf("ALFactory.init - Native: Exit\n"); - return 1; -} - -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALFactory_deinitialize - (JNIEnv *env, jclass clazz) { - DeInitializeOpenAL(); - return 1; -} diff --git a/src/native/alfactory.h b/src/native/alfactory.h deleted file mode 100644 index 48c301c..0000000 --- a/src/native/alfactory.h +++ /dev/null @@ -1,66 +0,0 @@ -/** -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. -*/ - - -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class net_java_games_joal_ALFactory */ - -#ifndef _Included_net_java_games_joal_ALFactory -#define _Included_net_java_games_joal_ALFactory -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: isInitialized */ -/* Inaccessible static: al */ -/* Inaccessible static: alc */ -/* - * Class: net_java_games_joal_ALFactory - * Method: initialize - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALFactory_init - (JNIEnv *, jclass, jobjectArray); - -/* - * Class: net_java_games_joal_ALFactory - * Method: deinitialize - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_net_java_games_joal_ALFactory_deinitialize - (JNIEnv *, jclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/native/build.xml b/src/native/build.xml deleted file mode 100644 index 0d26f42..0000000 --- a/src/native/build.xml +++ /dev/null @@ -1,113 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> - -<!-- -* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* -Redistribution of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* -Redistribution in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without -* specific prior written permission. -* -* This software is provided "AS IS," without a warranty of any kind. -* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING -* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS -* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A -* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT -* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR -* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, -* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS -* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -* -* You acknowledge that this software is not designed or intended for use in the -* design, construction, operation or maintenance of any nuclear facility. ---> - -<project name="Sun Games Initiative Client Technologies" basedir="." default="all"> - - <target name="init"> - <property name="cc" value ="gcc"/> - <property name="no_cygwin" value="-mno-cygwin"/> - <property name="sources" value="common_tools.c extal.c eaxfactory.c eaxbind.c alfactory.c alcbind.c albind.c"/> - <property name="specs" value="-specs='./specs.new'"/> - <condition property="isOSX"> - <and> - <os family="mac"/> - <os family="unix"/> - </and> - </condition> - <condition property="isUnix"> - <and> - <os family="unix" /> - <not> - <os family="mac" /> - </not> - </and> - </condition> - <condition property="isWindows"> - <os family="windows" /> - </condition> - </target> - - <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-jnilib" depends="init" if="isOSX"> - <echo message="Compiling shared library for OSX"/> - <antcall target="compile-native-lib"> - <param name="include" value="-I${jdk.home}/include -I${openal.home}/Headers"/> - <param name="compilerflags" value="-O3 -D_AGL -bundle "/> - <param name="output" value="../../lib/libjoal.jnilib"/> - </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, compile-jnilib"> - </target> - - <target name="javadoc" depends="init"> - <ant dir="src/java" target="javadoc"/> - </target> - - - <target name="all" depends="init,compile" description="Build everything."> - <echo message="Application built."/> - </target> - - <target name="clean" description="Clean all build products."> - <delete file="../../lib/joal.dll" /> - <delete file="../../lib/libjoal.so" /> - <delete file="../../lib/libjoal.jnilib"/> - </target> -</project> diff --git a/src/native/common_tools.c b/src/native/common_tools.c deleted file mode 100644 index c38b4b3..0000000 --- a/src/native/common_tools.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * @author elias_naur <[email protected]> - * @version $Revision$ - */ - -#include "common_tools.h" - -static void incListStart(event_queue_t *queue) { - queue->list_start = (queue->list_start + 1)%EVENT_BUFFER_SIZE; -} - -void initEventQueue(event_queue_t *event_queue) { - event_queue->list_start = 0; - event_queue->list_end = 0; -} - -void putEventElement(event_queue_t *queue, unsigned char byte) { - int next_index = (queue->list_end + 1)%EVENT_BUFFER_SIZE; - if (next_index == queue->list_start) { -#ifdef _DEBUG - printf("Event buffer overflow!\n"); -#endif - return; - } - queue->input_event_buffer[queue->list_end] = byte; - queue->list_end = next_index; -} - -static int hasMoreEvents(event_queue_t *queue) { - return queue->list_start != queue->list_end; -} - -static void copyEvent(event_queue_t *queue, int event_size, int event_index) { - int output_index = event_index*event_size; - int i; - for (i = 0; i < event_size; i++) { - queue->output_event_buffer[output_index] = queue->input_event_buffer[queue->list_start]; - incListStart(queue); - output_index++; - } -} - -int copyEvents(event_queue_t *event_queue, int event_size) { - int num_events = 0; - while (hasMoreEvents(event_queue)) { - copyEvent(event_queue, event_size, num_events); - num_events++; - } - return num_events; -} - -unsigned char *getOutputList(event_queue_t *queue) { - return queue->output_event_buffer; -} - -int getEventBufferSize(event_queue_t *event_queue) { - return EVENT_BUFFER_SIZE; -} - -static void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) { - jclass cls = (*env)->FindClass(env,exception_name); - (*env)->ThrowNew(env,cls, err); - (*env)->DeleteLocalRef(env,cls); -} - -void throwOpenALException(JNIEnv * env, const char * err) { - throwGeneralException(env, "net/java/games/joal/OpenALException", err); -} - -void throwException(JNIEnv * env, const char * err) { - throwGeneralException(env, "java/lang/Exception", err); -} diff --git a/src/native/common_tools.h b/src/native/common_tools.h deleted file mode 100644 index 2298728..0000000 --- a/src/native/common_tools.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * @author elias_naur <[email protected]> - * @version $Revision$ - */ - -#ifndef _COMMON_TOOLS_H -#define _COMMON_TOOLS_H - -#include <jni.h> - -// Must be x * max_event_size + 1 -#define EVENT_BUFFER_SIZE (25 * 4 + 1) - -typedef struct { - unsigned char input_event_buffer[EVENT_BUFFER_SIZE]; - unsigned char output_event_buffer[EVENT_BUFFER_SIZE]; - - int list_start; - int list_end; -} event_queue_t; - -extern void initEventQueue(event_queue_t *event_queue); -extern int copyEvents(event_queue_t *event_queue, int event_size); -extern void putEventElement(event_queue_t *queue, unsigned char byte); -extern unsigned char *getOutputList(event_queue_t *queue); -extern int getEventBufferSize(event_queue_t *event_queue); -extern void throwException(JNIEnv *env, const char *msg); -extern void throwOpenALException(JNIEnv * env, const char * err); - -#endif diff --git a/src/native/eaxbind.c b/src/native/eaxbind.c index b0d05e8..6b17a66 100644 --- a/src/native/eaxbind.c +++ b/src/native/eaxbind.c @@ -33,7 +33,7 @@ #include "eaxbind.h" -#include "extal.h" +#include "eax.h" #ifdef _WIN32 const GUID DSPROPSETID_EAX20_ListenerProperties = { 0x306a6a8, 0xb224, 0x11d2, { 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7, 0x22 } }; diff --git a/src/native/eaxfactory.c b/src/native/eaxfactory.c index 708ddda..d0e3e9d 100644 --- a/src/native/eaxfactory.c +++ b/src/native/eaxfactory.c @@ -33,7 +33,13 @@ #include "eaxfactory.h" -#include "extal.h" +#include "al.h" +#include "eax.h" + +#ifdef _WIN32 +EAXSet eaxSet; // EAXSet function, ret$ +EAXGet eaxGet; // EAXGet function, ret$ +#endif /* * had some problems getting this from extal.h diff --git a/src/native/extal.c b/src/native/extal.c deleted file mode 100644 index 45947dc..0000000 --- a/src/native/extal.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "stdio.h" -#include "extal.h" -#include "common_tools.h" - -#ifdef _X11 -#include "dlfcn.h" -#endif - -/** - * $Id$ - * - * This file contains the AL extension assigning mechanism - * - * @author Brian Matzon <[email protected]> - * @version $Revision$ - */ -alEnablePROC alEnable = NULL; -alDisablePROC alDisable = NULL; -alIsEnabledPROC alIsEnabled = NULL; -alHintPROC alHint = NULL; -alGetBooleanPROC alGetBoolean = NULL; -alGetIntegerPROC alGetInteger = NULL; -alGetFloatPROC alGetFloat = NULL; -alGetDoublePROC alGetDouble = NULL; -alGetBooleanvPROC alGetBooleanv = NULL; -alGetIntegervPROC alGetIntegerv = NULL; -alGetFloatvPROC alGetFloatv = NULL; -alGetDoublevPROC alGetDoublev = NULL; -alGetStringPROC alGetString = NULL; -alGetErrorPROC alGetError = NULL; -alIsExtensionPresentPROC alIsExtensionPresent = NULL; -alGetProcAddressPROC alGetProcAddress = NULL; -alGetEnumValuePROC alGetEnumValue = NULL; -alListeneriPROC alListeneri = NULL; -alListenerfPROC alListenerf = NULL; -alListener3fPROC alListener3f = NULL; -alListenerfvPROC alListenerfv = NULL; -alGetListeneriPROC alGetListeneri = NULL; -alGetListenerfPROC alGetListenerf = NULL; -alGetListener3fPROC alGetListener3f = NULL; -alGetListenerfvPROC alGetListenerfv = NULL; -alGenSourcesPROC alGenSources = NULL; -alDeleteSourcesPROC alDeleteSources = NULL; -alIsSourcePROC alIsSource = NULL; -alSourceiPROC alSourcei = NULL; -alSourcefPROC alSourcef = NULL; -alSource3fPROC alSource3f = NULL; -alSourcefvPROC alSourcefv = NULL; -alGetSourceiPROC alGetSourcei = NULL; -alGetSourcefPROC alGetSourcef = NULL; -alGetSource3fPROC alGetSource3f = NULL; -alGetSourcefvPROC alGetSourcefv = NULL; -alSourcePlayvPROC alSourcePlayv = NULL; -alSourcePausevPROC alSourcePausev = NULL; -alSourceStopvPROC alSourceStopv = NULL; -alSourceRewindvPROC alSourceRewindv = NULL; -alSourcePlayPROC alSourcePlay = NULL; -alSourcePausePROC alSourcePause = NULL; -alSourceStopPROC alSourceStop = NULL; -alSourceRewindPROC alSourceRewind = NULL; -alGenBuffersPROC alGenBuffers = NULL; -alDeleteBuffersPROC alDeleteBuffers = NULL; -alIsBufferPROC alIsBuffer = NULL; -alBufferDataPROC alBufferData = NULL; -alGetBufferiPROC alGetBufferi = NULL; -alGetBufferfPROC alGetBufferf = NULL; -alSourceQueueBuffersPROC alSourceQueueBuffers = NULL; -alSourceUnqueueBuffersPROC alSourceUnqueueBuffers = NULL; -alDistanceModelPROC alDistanceModel = NULL; -alDopplerFactorPROC alDopplerFactor = NULL; -alDopplerVelocityPROC alDopplerVelocity = NULL; -alcGetStringPROC alcGetString = NULL; -alcGetIntegervPROC alcGetIntegerv = NULL; -alcOpenDevicePROC alcOpenDevice = NULL; -alcCloseDevicePROC alcCloseDevice = NULL; -alcCreateContextPROC alcCreateContext = NULL; -alcMakeContextCurrentPROC alcMakeContextCurrent = NULL; -alcProcessContextPROC alcProcessContext = NULL; -alcGetCurrentContextPROC alcGetCurrentContext = NULL; -alcGetContextsDevicePROC alcGetContextsDevice = NULL; -alcSuspendContextPROC alcSuspendContext = NULL; -alcDestroyContextPROC alcDestroyContext = NULL; -alcGetErrorPROC alcGetError = NULL; -alcIsExtensionPresentPROC alcIsExtensionPresent = NULL; -alcGetProcAddressPROC alcGetProcAddress = NULL; -alcGetEnumValuePROC alcGetEnumValue = NULL; - -#ifdef _WIN32 -EAXSet eaxSet; // EAXSet function, ret$ -EAXGet eaxGet; // EAXGet function, ret$ - -/* Handle to OpenAL Library */ -HMODULE handleOAL; -#endif -#ifdef _X11 -void* handleOAL; -#endif -#ifdef _AGL -#include "mach-o/dyld.h" -#include "stdlib.h" -#include "string.h" -const struct mach_header* handleOAL; -#endif - -/* Loads OpenAL */ -static int LoadOpenAL(JNIEnv *env, jobjectArray oalPaths); - -/* Unloads OpenAL */ -static void UnLoadOpenAL(void); - -/* Gets a pointer to the named function */ -static void* GetFunctionPointer(const char* function); - -/* Loads OpenAL basic functions */ -static int LoadAL(void); - -/* Loads OpenAL ALC functions */ -static int LoadALC(void); - -/* Loads any extensions to OpenAL */ -static int LoadALExtensions(void); - -static void *NativeGetFunctionPointer(const char *function) { -#ifdef _WIN32 - return GetProcAddress(handleOAL, function); -#endif -#ifdef _X11 - return dlsym(handleOAL, function); -#endif -#ifdef _AGL - char *mac_symbol_name = (char *)malloc((strlen(function) + 2)*sizeof(char)); - if (mac_symbol_name == NULL) - return NULL; - mac_symbol_name[0] = '_'; - strcpy(&(mac_symbol_name[1]), function); - NSSymbol symbol = NSLookupSymbolInImage(handleOAL, mac_symbol_name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - free(mac_symbol_name); - if (symbol == NULL) - return NULL; - return NSAddressOfSymbol(symbol); -#endif -} - -/** - * Retrieves a pointer to the named function - * - * @param function Name of function - * @return pointer to named function, or NULL if not found - */ -static void* GetFunctionPointer(const char* function) { - void *p = NativeGetFunctionPointer(function); - if (p == NULL) { -#ifdef _DEBUG - printf("Could not locate symbol %s\n", function); -#endif - } - return p; -} - -/** - * Loads the OpenAL Library - */ -static int LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) { - - jsize pathcount = (*env)->GetArrayLength(env,oalPaths); -#ifdef _DEBUG - printf("Found %d OpenAL paths\n", (int)pathcount); -#endif - int i; - for(i=0;i<pathcount;i++) { - jstring path = (jstring) (*env)->GetObjectArrayElement(env,oalPaths, i); - const char *path_str = (*env)->GetStringUTFChars(env,path, NULL); -#ifdef _DEBUG - printf("Testing '%s'\n", path_str); -#endif -#ifdef _WIN32 - handleOAL = LoadLibrary(path_str); -#endif -#ifdef _X11 - handleOAL = dlopen(path_str, RTLD_LAZY); -#endif -#ifdef _AGL - handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); -#endif - if (handleOAL != NULL) { -#ifdef _DEBUG - printf("Found OpenAL at '%s'\n", path_str); -#endif - return 1; - } - (*env)->ReleaseStringUTFChars(env,path, path_str); - } - throwOpenALException(env, "Could not load openal library."); - return 0; -} - -/** - * Unloads the OpenAL Library - */ -static void UnLoadOpenAL() { -#ifdef _WIN32 - FreeLibrary(handleOAL); -#endif -#ifdef _X11 - dlclose(handleOAL); -#endif -#ifdef _AGL - // Cannot remove the image -#endif -} - -/** - * Initializes OpenAL by loading the library - */ -void InitializeOpenAL(JNIEnv *env, jobjectArray oalPaths) { - if(handleOAL != NULL) { - return; - } - - //load our library - if (!LoadOpenAL(env, oalPaths)) { - return; - } - - //load basic OpenAL functions - if(!LoadAL()) { - throwOpenALException(env, "Could not load OpenAL function pointers."); - return; - } - - //load OpenAL context functions - if(!LoadALC()) { - throwOpenALException(env, "Could not load ALC function pointers."); - return; - } - - //load OpenAL extensions - if(!LoadALExtensions()) { - throwOpenALException(env, "Could not load AL extension function pointers."); - return; - } -} - -/** - * Called to deinitialize OpenAL - */ -void DeInitializeOpenAL() { - UnLoadOpenAL(); - handleOAL = 0; -} - -/** - * Loads the basic OpenAL functions - * - * @return true if all methods were loaded, false if one of the methods could not be loaded - */ -static int LoadAL() { - alEnable = (alEnablePROC) GetFunctionPointer("alEnable"); - alDisable = (alDisablePROC) GetFunctionPointer("alDisable"); - alIsEnabled = (alIsEnabledPROC) GetFunctionPointer("alIsEnabled"); - //alHint = (alHintPROC) GetFunctionPointer("alHint"); - //alGetintean = (alGetinteanPROC) GetFunctionPointer("alGetintean"); - alGetInteger = (alGetIntegerPROC) GetFunctionPointer("alGetInteger"); - alGetFloat = (alGetFloatPROC) GetFunctionPointer("alGetFloat"); - alGetDouble = (alGetDoublePROC) GetFunctionPointer("alGetDouble"); - //alGetinteanv = (alGetinteanvPROC) GetFunctionPointer("alGetinteanv"); - alGetIntegerv = (alGetIntegervPROC) GetFunctionPointer("alGetIntegerv"); - alGetFloatv = (alGetFloatvPROC) GetFunctionPointer("alGetFloatv"); - alGetDoublev = (alGetDoublevPROC) GetFunctionPointer("alGetDoublev"); - alGetString = (alGetStringPROC) GetFunctionPointer("alGetString"); - alGetError = (alGetErrorPROC) GetFunctionPointer("alGetError"); - alIsExtensionPresent = (alIsExtensionPresentPROC) GetFunctionPointer("alIsExtensionPresent"); - alGetProcAddress = (alGetProcAddressPROC) GetFunctionPointer("alGetProcAddress"); - alGetEnumValue = (alGetEnumValuePROC) GetFunctionPointer("alGetEnumValue"); - alListeneri = (alListeneriPROC) GetFunctionPointer("alListeneri"); - alListenerf = (alListenerfPROC) GetFunctionPointer("alListenerf"); - alListener3f = (alListener3fPROC) GetFunctionPointer("alListener3f"); - alListenerfv = (alListenerfvPROC) GetFunctionPointer("alListenerfv"); - alGetListeneri = (alGetListeneriPROC) GetFunctionPointer("alGetListeneri"); - alGetListenerf = (alGetListenerfPROC) GetFunctionPointer("alGetListenerf"); - alGetListener3f = (alGetListener3fPROC) GetFunctionPointer("alGetListener3f"); - alGetListenerfv = (alGetListenerfvPROC) GetFunctionPointer("alGetListenerfv"); - alGenSources = (alGenSourcesPROC) GetFunctionPointer("alGenSources"); - alDeleteSources = (alDeleteSourcesPROC) GetFunctionPointer("alDeleteSources"); - alIsSource = (alIsSourcePROC) GetFunctionPointer("alIsSource"); - alSourcei = (alSourceiPROC) GetFunctionPointer("alSourcei"); - alSourcef = (alSourcefPROC) GetFunctionPointer("alSourcef"); - alSource3f = (alSource3fPROC) GetFunctionPointer("alSource3f"); - alSourcefv = (alSourcefvPROC) GetFunctionPointer("alSourcefv"); - alGetSourcei = (alGetSourceiPROC) GetFunctionPointer("alGetSourcei"); - alGetSourcef = (alGetSourcefPROC) GetFunctionPointer("alGetSourcef"); - alGetSource3f = (alGetSource3fPROC) GetFunctionPointer("alGetSource3f"); - alGetSourcefv = (alGetSourcefvPROC) GetFunctionPointer("alGetSourcefv"); - alSourcePlayv = (alSourcePlayvPROC) GetFunctionPointer("alSourcePlayv"); - alSourcePausev = (alSourcePausevPROC) GetFunctionPointer("alSourcePausev"); - alSourceStopv = (alSourceStopvPROC) GetFunctionPointer("alSourceStopv"); - alSourceRewindv = (alSourceRewindvPROC) GetFunctionPointer("alSourceRewindv"); - alSourcePlay = (alSourcePlayPROC) GetFunctionPointer("alSourcePlay"); - alSourcePause = (alSourcePausePROC) GetFunctionPointer("alSourcePause"); - alSourceStop = (alSourceStopPROC) GetFunctionPointer("alSourceStop"); - alSourceRewind = (alSourceRewindPROC) GetFunctionPointer("alSourceRewind"); - alGenBuffers = (alGenBuffersPROC) GetFunctionPointer("alGenBuffers"); - alDeleteBuffers = (alDeleteBuffersPROC) GetFunctionPointer("alDeleteBuffers"); - alIsBuffer = (alIsBufferPROC) GetFunctionPointer("alIsBuffer"); - alBufferData = (alBufferDataPROC) GetFunctionPointer("alBufferData"); - alGetBufferi = (alGetBufferiPROC) GetFunctionPointer("alGetBufferi"); - alGetBufferf = (alGetBufferfPROC) GetFunctionPointer("alGetBufferf"); - alSourceQueueBuffers = (alSourceQueueBuffersPROC) GetFunctionPointer("alSourceQueueBuffers"); - alSourceUnqueueBuffers = (alSourceUnqueueBuffersPROC) GetFunctionPointer("alSourceUnqueueBuffers"); - alDistanceModel = (alDistanceModelPROC) GetFunctionPointer("alDistanceModel"); - alDopplerFactor = (alDopplerFactorPROC) GetFunctionPointer("alDopplerFactor"); - alDopplerVelocity = (alDopplerVelocityPROC) GetFunctionPointer("alDopplerVelocity"); - - return - alEnable != NULL && - alDisable != NULL && - alIsEnabled != NULL && - //alHint != NULL && - //alGetintean != NULL && - alGetInteger != NULL && - alGetFloat != NULL && - alGetDouble != NULL && - //alGetinteanv != NULL && - alGetIntegerv != NULL && - alGetFloatv != NULL && - alGetDoublev != NULL && - alGetString != NULL && - alGetError != NULL && - alIsExtensionPresent != NULL && - alGetProcAddress != NULL && - alGetEnumValue != NULL && - alListeneri != NULL && - alListenerf != NULL && - alListener3f != NULL && - alListenerfv != NULL && - alGetListeneri != NULL && - alGetListenerf != NULL && - alGetListener3f != NULL && - alGetListenerfv != NULL && - alGenSources != NULL && - alDeleteSources != NULL && - alIsSource != NULL && - alSourcei != NULL && - alSourcef != NULL && - alSource3f != NULL && - alSourcefv != NULL && - alGetSourcei != NULL && - alGetSourcef != NULL && - alGetSource3f != NULL && - alGetSourcefv != NULL && - alSourcePlayv != NULL && - alSourcePausev != NULL && - alSourceStopv != NULL && - alSourceRewindv != NULL && - alSourcePlay != NULL && - alSourcePause != NULL && - alSourceStop != NULL && - alSourceRewind != NULL && - alGenBuffers != NULL && - alDeleteBuffers != NULL && - alIsBuffer != NULL && - alBufferData != NULL && - alGetBufferi != NULL && - alGetBufferf != NULL && - alSourceQueueBuffers != NULL && - alSourceUnqueueBuffers != NULL && - alDistanceModel != NULL && - alDopplerFactor != NULL && - alDopplerVelocity != NULL; -} - -/** - * Loads the context OpenAL functions - * - * @return true if all methods were loaded, false if one of the methods could not be loaded - */ -static int LoadALC() { - alcGetString = (alcGetStringPROC) GetFunctionPointer("alcGetString"); - alcGetIntegerv = (alcGetIntegervPROC) GetFunctionPointer("alcGetIntegerv"); - alcOpenDevice = (alcOpenDevicePROC) GetFunctionPointer("alcOpenDevice"); - alcCloseDevice = (alcCloseDevicePROC) GetFunctionPointer("alcCloseDevice"); - alcCreateContext = (alcCreateContextPROC) GetFunctionPointer("alcCreateContext"); - alcMakeContextCurrent = (alcMakeContextCurrentPROC) GetFunctionPointer("alcMakeContextCurrent"); - alcProcessContext = (alcProcessContextPROC) GetFunctionPointer("alcProcessContext"); - alcGetCurrentContext = (alcGetCurrentContextPROC) GetFunctionPointer("alcGetCurrentContext"); - alcGetContextsDevice = (alcGetContextsDevicePROC) GetFunctionPointer("alcGetContextsDevice"); - alcSuspendContext = (alcSuspendContextPROC) GetFunctionPointer("alcSuspendContext"); - alcDestroyContext = (alcDestroyContextPROC) GetFunctionPointer("alcDestroyContext"); - alcGetError = (alcGetErrorPROC) GetFunctionPointer("alcGetError"); - alcIsExtensionPresent = (alcIsExtensionPresentPROC) GetFunctionPointer("alcIsExtensionPresent"); - alcGetProcAddress = (alcGetProcAddressPROC) GetFunctionPointer("alcGetProcAddress"); - alcGetEnumValue = (alcGetEnumValuePROC) GetFunctionPointer("alcGetEnumValue"); - - return - alcGetString != NULL && - alcGetIntegerv != NULL && - alcOpenDevice != NULL && - alcCloseDevice != NULL && - alcCreateContext != NULL && - alcMakeContextCurrent != NULL && - alcProcessContext != NULL && - alcGetCurrentContext != NULL && - alcGetContextsDevice != NULL && - alcSuspendContext != NULL && - alcDestroyContext != NULL && - alcGetError != NULL && - alcIsExtensionPresent != NULL && - alcGetProcAddress != NULL && - alcGetEnumValue != NULL; -} - -/** - * Loads the OpenAL extensions functions - * - * @return true if all methods were loaded, false if one of the methods could not be loaded - */ -static int LoadALExtensions() { - return 1; -} diff --git a/src/native/extal.h b/src/native/extal.h deleted file mode 100644 index 361c2d7..0000000 --- a/src/native/extal.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (c) 2002 Light Weight Java Game Library Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'Light Weight Java Game Library' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AL_TEST_H -#define _AL_TEST_H - -#ifdef _WIN32 -#include "windows.h" -#endif - -#ifdef _X11 -#include "AL/altypes.h" -#include "AL/alctypes.h" -#endif -#ifdef _WIN32 -#include "altypes.h" -#include "alctypes.h" -#endif -#ifdef _AGL -#include "OpenAL/alctypes.h" -#include "OpenAL/altypes.h" -#endif - -#include <jni.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 - #ifdef _OPENAL32LIB - #define ALCAPI __declspec(dllexport) - #else - #define ALCAPI __declspec(dllimport) - #endif - - typedef struct ALCdevice_struct ALCdevice; - typedef struct ALCcontext_struct ALCcontext; - - #define ALCAPIENTRY __cdecl -#else - #ifdef _AGL - #if _AGL - typedef struct ALCdevice_struct ALCdevice; - typedef struct ALCcontext_struct ALCcontext; - - #endif - #endif - #define ALCAPI - #define ALCAPIENTRY - -/** ALC boolean type. */ -typedef char ALCboolean; - -/** ALC 8bit signed byte. */ -typedef char ALCbyte; - -/** ALC 8bit unsigned byte. */ -typedef unsigned char ALCubyte; - -/** ALC 16bit signed short integer type. */ -typedef short ALCshort; - -/** ALC 16bit unsigned short integer type. */ -typedef unsigned short ALCushort; - -/** ALC 32bit unsigned integer type. */ -typedef unsigned ALCuint; - -/** ALC 32bit signed integer type. */ -typedef int ALCint; - -/** ALC 32bit floating point type. */ -typedef float ALCfloat; - -/** ALC 64bit double point type. */ -typedef double ALCdouble; - -/** ALC 32bit type. */ -typedef unsigned int ALCsizei; - -/** ALC void type */ -typedef void ALCvoid; - -#endif - -#ifdef _WIN32 - #ifdef _OPENAL32LIB - #define ALAPI __declspec(dllexport) - #else - #define ALAPI __declspec(dllimport) - #endif - #define ALAPIENTRY __cdecl - #define AL_CALLBACK -#else - #define ALAPI - #define ALAPIENTRY - #define AL_CALLBACK -#endif - -#ifdef _WIN32 -DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties, - 0x306a6a8, - 0xb224, - 0x11d2, - 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7, 0x22); - -DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties, - 0x306a6a7, - 0xb224, - 0x11d2, - 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7, 0x22); -#endif - -#define INITGUID -#define OPENAL - -void InitializeOpenAL(JNIEnv *env, jobjectArray oalPaths); -void DeInitializeOpenAL(); - -//alc -typedef ALCubyte* (ALCAPIENTRY *alcGetStringPROC)(ALCdevice *device,ALCenum param); -typedef ALCvoid (ALCAPIENTRY *alcGetIntegervPROC)(ALCdevice *device,ALCenum param,ALCsizei size,ALCint *data); -typedef ALCdevice* (ALCAPIENTRY *alcOpenDevicePROC)(ALCubyte *deviceName); -typedef ALCvoid (ALCAPIENTRY *alcCloseDevicePROC)(ALCdevice *device); -typedef ALCcontext* (ALCAPIENTRY *alcCreateContextPROC)(ALCdevice *device,ALCint *attrList); -typedef ALCboolean (ALCAPIENTRY *alcMakeContextCurrentPROC)(ALCcontext *context); -typedef ALCvoid (ALCAPIENTRY *alcProcessContextPROC)(ALCcontext *context); -typedef ALCcontext* (ALCAPIENTRY *alcGetCurrentContextPROC)(ALCvoid); -typedef ALCdevice* (ALCAPIENTRY *alcGetContextsDevicePROC)(ALCcontext *context); -typedef ALCvoid (ALCAPIENTRY *alcSuspendContextPROC)(ALCcontext *context); -typedef ALCvoid (ALCAPIENTRY *alcDestroyContextPROC)(ALCcontext *context); -typedef ALCenum (ALCAPIENTRY *alcGetErrorPROC)(ALCdevice *device); -typedef ALCboolean (ALCAPIENTRY *alcIsExtensionPresentPROC)(ALCdevice *device,ALCubyte *extName); -typedef ALCvoid* (ALCAPIENTRY *alcGetProcAddressPROC)(ALCdevice *device,ALCubyte *funcName); -typedef ALCenum (ALCAPIENTRY *alcGetEnumValuePROC)(ALCdevice *device,ALCubyte *enumName); - -//al -typedef ALvoid (ALAPIENTRY *alEnablePROC)( ALenum capability ); -typedef ALvoid (ALAPIENTRY *alDisablePROC)( ALenum capability ); -typedef ALboolean (ALAPIENTRY *alIsEnabledPROC)( ALenum capability ); -typedef ALvoid (ALAPIENTRY *alHintPROC)( ALenum target, ALenum mode ); -typedef ALboolean (ALAPIENTRY *alGetBooleanPROC)( ALenum param ); -typedef ALint (ALAPIENTRY *alGetIntegerPROC)( ALenum param ); -typedef ALfloat (ALAPIENTRY *alGetFloatPROC)( ALenum param ); -typedef ALdouble (ALAPIENTRY *alGetDoublePROC)( ALenum param ); -typedef ALvoid (ALAPIENTRY *alGetBooleanvPROC)( ALenum param, ALboolean* data ); -typedef ALvoid (ALAPIENTRY *alGetIntegervPROC)( ALenum param, ALint* data ); -typedef ALvoid (ALAPIENTRY *alGetFloatvPROC)( ALenum param, ALfloat* data ); -typedef ALvoid (ALAPIENTRY *alGetDoublevPROC)( ALenum param, ALdouble* data ); -typedef ALubyte* (ALAPIENTRY *alGetStringPROC)( ALenum param ); -typedef ALenum (ALAPIENTRY *alGetErrorPROC)( ALvoid ); -typedef ALboolean (ALAPIENTRY *alIsExtensionPresentPROC)( ALubyte* fname ); -typedef ALvoid* (ALAPIENTRY *alGetProcAddressPROC)( ALubyte* fname ); -typedef ALenum (ALAPIENTRY *alGetEnumValuePROC)( ALubyte* ename ); -typedef ALvoid (ALAPIENTRY *alListeneriPROC)( ALenum param, ALint value ); -typedef ALvoid (ALAPIENTRY *alListenerfPROC)( ALenum param, ALfloat value ); -typedef ALvoid (ALAPIENTRY *alListener3fPROC)( ALenum param, ALfloat v1, ALfloat v2, ALfloat v3 ); -typedef ALvoid (ALAPIENTRY *alListenerfvPROC)( ALenum param, ALfloat* values ); -typedef ALvoid (ALAPIENTRY *alGetListeneriPROC)( ALenum param, ALint* value ); -typedef ALvoid (ALAPIENTRY *alGetListenerfPROC)( ALenum param, ALfloat* value ); -typedef ALvoid (ALAPIENTRY *alGetListener3fPROC)( ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3 ); -typedef ALvoid (ALAPIENTRY *alGetListenerfvPROC)( ALenum param, ALfloat* values ); -typedef ALvoid (ALAPIENTRY *alGenSourcesPROC)( ALsizei n, ALuint* sources ); -typedef ALvoid (ALAPIENTRY *alDeleteSourcesPROC)( ALsizei n, ALuint* sources ); -typedef ALboolean (ALAPIENTRY *alIsSourcePROC)( ALuint id ); -typedef ALvoid (ALAPIENTRY *alSourceiPROC)( ALuint source, ALenum param, ALint value ); -typedef ALvoid (ALAPIENTRY *alSourcefPROC)( ALuint source, ALenum param, ALfloat value ); -typedef ALvoid (ALAPIENTRY *alSource3fPROC)( ALuint source, ALenum param, ALfloat v1, ALfloat v2, ALfloat v3 ); -typedef ALvoid (ALAPIENTRY *alSourcefvPROC)( ALuint source, ALenum param, ALfloat* values ); -typedef ALvoid (ALAPIENTRY *alGetSourceiPROC)( ALuint source, ALenum param, ALint* value ); -typedef ALvoid (ALAPIENTRY *alGetSourcefPROC)( ALuint source, ALenum param, ALfloat* value ); -typedef ALvoid (ALAPIENTRY *alGetSource3fPROC)( ALuint source, ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3 ); -typedef ALvoid (ALAPIENTRY *alGetSourcefvPROC)( ALuint source, ALenum param, ALfloat* values ); -typedef ALvoid (ALAPIENTRY *alSourcePlayvPROC)( ALsizei n, ALuint *sources ); -typedef ALvoid (ALAPIENTRY *alSourcePausevPROC)( ALsizei n, ALuint *sources ); -typedef ALvoid (ALAPIENTRY *alSourceStopvPROC)( ALsizei n, ALuint *sources ); -typedef ALvoid (ALAPIENTRY *alSourceRewindvPROC)(ALsizei n,ALuint *sources); -typedef ALvoid (ALAPIENTRY *alSourcePlayPROC)( ALuint source ); -typedef ALvoid (ALAPIENTRY *alSourcePausePROC)( ALuint source ); -typedef ALvoid (ALAPIENTRY *alSourceStopPROC)( ALuint source ); -typedef ALvoid (ALAPIENTRY *alSourceRewindPROC)( ALuint source ); -typedef ALvoid (ALAPIENTRY *alGenBuffersPROC)( ALsizei n, ALuint* buffers ); -typedef ALvoid (ALAPIENTRY *alDeleteBuffersPROC)( ALsizei n, ALuint* buffers ); -typedef ALboolean (ALAPIENTRY *alIsBufferPROC)( ALuint buffer ); -typedef ALvoid (ALAPIENTRY *alBufferDataPROC)( ALuint buffer, - ALenum format, - ALvoid* data, - ALsizei size, - ALsizei freq ); -typedef ALvoid (ALAPIENTRY *alGetBufferiPROC)( ALuint buffer, ALenum param, ALint* value ); -typedef ALvoid (ALAPIENTRY *alGetBufferfPROC)( ALuint buffer, ALenum param, ALfloat* value ); -typedef ALvoid (ALAPIENTRY *alSourceQueueBuffersPROC)( ALuint source, ALsizei n, ALuint* buffers ); -typedef ALvoid (ALAPIENTRY *alSourceUnqueueBuffersPROC)( ALuint source, ALsizei n, ALuint* buffers ); -typedef ALvoid (ALAPIENTRY *alDistanceModelPROC)( ALenum value ); -typedef ALvoid (ALAPIENTRY *alDopplerFactorPROC)( ALfloat value ); -typedef ALvoid (ALAPIENTRY *alDopplerVelocityPROC)( ALfloat value ); - -extern alcGetStringPROC alcGetString; -extern alcGetIntegervPROC alcGetIntegerv; -extern alcOpenDevicePROC alcOpenDevice; -extern alcCloseDevicePROC alcCloseDevice; -extern alcCreateContextPROC alcCreateContext; -extern alcMakeContextCurrentPROC alcMakeContextCurrent; -extern alcProcessContextPROC alcProcessContext; -extern alcGetCurrentContextPROC alcGetCurrentContext; -extern alcGetContextsDevicePROC alcGetContextsDevice; -extern alcSuspendContextPROC alcSuspendContext; -extern alcDestroyContextPROC alcDestroyContext; -extern alcGetErrorPROC alcGetError; -extern alcIsExtensionPresentPROC alcIsExtensionPresent; -extern alcGetProcAddressPROC alcGetProcAddress; -extern alcGetEnumValuePROC alcGetEnumValue; - -extern alEnablePROC alEnable; -extern alDisablePROC alDisable; -extern alIsEnabledPROC alIsEnabled; -extern alHintPROC alHint; -extern alGetBooleanPROC alGetBoolean; -extern alGetIntegerPROC alGetInteger; -extern alGetFloatPROC alGetFloat; -extern alGetDoublePROC alGetDouble; -extern alGetBooleanvPROC alGetBooleanv; -extern alGetIntegervPROC alGetIntegerv; -extern alGetFloatvPROC alGetFloatv; -extern alGetDoublevPROC alGetDoublev; -extern alGetStringPROC alGetString; -extern alGetErrorPROC alGetError; -extern alIsExtensionPresentPROC alIsExtensionPresent; -extern alGetProcAddressPROC alGetProcAddress; -extern alGetEnumValuePROC alGetEnumValue; -extern alListeneriPROC alListeneri; -extern alListenerfPROC alListenerf; -extern alListener3fPROC alListener3f; -extern alListenerfvPROC alListenerfv; -extern alGetListeneriPROC alGetListeneri; -extern alGetListenerfPROC alGetListenerf; -extern alGetListener3fPROC alGetListener3f; -extern alGetListenerfvPROC alGetListenerfv; -extern alGenSourcesPROC alGenSources; -extern alDeleteSourcesPROC alDeleteSources; -extern alIsSourcePROC alIsSource; -extern alSourceiPROC alSourcei; -extern alSourcefPROC alSourcef; -extern alSource3fPROC alSource3f; -extern alSourcefvPROC alSourcefv; -extern alGetSourceiPROC alGetSourcei; -extern alGetSourcefPROC alGetSourcef; -extern alGetSource3fPROC alGetSource3f; -extern alGetSourcefvPROC alGetSourcefv; -extern alSourcePlayvPROC alSourcePlayv; -extern alSourcePausevPROC alSourcePausev; -extern alSourceStopvPROC alSourceStopv; -extern alSourceRewindvPROC alSourceRewindv; -extern alSourcePlayPROC alSourcePlay; -extern alSourcePausePROC alSourcePause; -extern alSourceStopPROC alSourceStop; -extern alSourceRewindPROC alSourceRewind; -extern alGenBuffersPROC alGenBuffers; -extern alDeleteBuffersPROC alDeleteBuffers; -extern alIsBufferPROC alIsBuffer; -extern alBufferDataPROC alBufferData; -extern alGetBufferiPROC alGetBufferi; -extern alGetBufferfPROC alGetBufferf; -extern alSourceQueueBuffersPROC alSourceQueueBuffers; -extern alSourceUnqueueBuffersPROC alSourceUnqueueBuffers; -extern alDistanceModelPROC alDistanceModel; -extern alDopplerFactorPROC alDopplerFactor; -extern alDopplerVelocityPROC alDopplerVelocity; - -#ifdef _WIN32 -typedef ALenum (*EAXSet)(const GUID*, ALuint, ALuint, ALvoid*, ALuint); -typedef ALenum (*EAXGet)(const GUID*, ALuint, ALuint, ALvoid*, ALuint); - -extern EAXSet eaxSet; -extern EAXGet eaxGet; -#endif - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/unit_tests/build.xml b/unit_tests/build.xml index fafdf5b..7b1f8e2 100644 --- a/unit_tests/build.xml +++ b/unit_tests/build.xml @@ -40,7 +40,7 @@ </target> <target name="compile" depends="init"> - <javac debug="true" srcdir="./src" classpath="../classes" destdir="classes"/> + <javac debug="true" srcdir="./src" classpath="../build/joal.jar;lib/junit.jar" destdir="classes"/> </target> <target name="clean"> @@ -50,22 +50,22 @@ <target name="runOpenALTest" depends="compile"> <java classname="OpenALTest" fork="true"> <classpath> - <pathelement location="../lib/joal.jar"/> + <pathelement location="../build/joal.jar"/> <pathelement location="lib/junit.jar"/> <pathelement location="classes"/> </classpath> - <jvmarg value="-Djava.library.path=${basedir}/../lib"/> + <jvmarg value="-Djava.library.path=${basedir}/../build/obj"/> </java> </target> <target name="runALTest" depends="compile"> <java classname="junit.textui.TestRunner" fork="true"> <classpath> - <pathelement location="../lib/joal.jar"/> + <pathelement location="../build/joal.jar"/> <pathelement location="lib/junit.jar"/> <pathelement location="classes"/> </classpath> - <jvmarg value="-Djava.library.path=${basedir}/../lib"/> + <jvmarg value="-Djava.library.path=${basedir}/../build/obj"/> <arg value="net.java.games.joal.ALTest" /> </java> </target> @@ -73,11 +73,11 @@ <target name="runSound3DTest" depends="compile"> <java classname="Sound3DTest" fork="true"> <classpath> - <pathelement location="../lib/joal.jar"/> + <pathelement location="../build/joal.jar"/> <pathelement location="lib/junit.jar"/> <pathelement location="classes"/> </classpath> - <jvmarg value="-Djava.library.path=${basedir}/../lib"/> + <jvmarg value="-Djava.library.path=${basedir}/../build/obj"/> </java> </target> </project> diff --git a/unit_tests/src/OpenALTest.java b/unit_tests/src/OpenALTest.java index 12745fe..5b9930a 100644 --- a/unit_tests/src/OpenALTest.java +++ b/unit_tests/src/OpenALTest.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -30,17 +30,12 @@ * You acknowledge that this software is not designed or intended for use in the * design, construction, operation or maintenance of any nuclear facility. */ -import java.nio.IntBuffer; - -import net.java.games.joal.AL; -import net.java.games.joal.ALC; -import net.java.games.joal.ALFactory; -import net.java.games.joal.OpenALException; -import net.java.games.joal.eax.EAX; -import net.java.games.joal.eax.EAXFactory; -import net.java.games.joal.util.BufferUtils; -import net.java.games.joal.util.WAVData; -import net.java.games.joal.util.WAVLoader; + +import java.nio.*; + +import net.java.games.joal.*; +import net.java.games.joal.eax.*; +import net.java.games.joal.util.*; /** * @author Athomas Goldberg @@ -49,11 +44,9 @@ import net.java.games.joal.util.WAVLoader; public class OpenALTest { public static void main(String[] args) { try { - ALFactory.initialize(); - ALC alc = ALFactory.getALC(); - ALC.Device device = alc.alcOpenDevice(null); - ALC.Context context = alc.alcCreateContext(device, null); + ALCdevice device = alc.alcOpenDevice(null); + ALCcontext context = alc.alcCreateContext(device, null); alc.alcMakeContextCurrent(context); AL al = ALFactory.getAL(); boolean eaxPresent = al.alIsExtensionPresent("EAX2.0"); @@ -62,23 +55,20 @@ public class OpenALTest { try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); WAVData wd = WAVLoader.loadFromFile("lewiscarroll.wav"); al.alBufferData(buffers[0], wd.format, wd.data, wd.size, wd.freq); int[] sources = new int[1]; - al.alGenSources(1, sources); + al.alGenSources(1, sources, 0); al.alSourcei(sources[0], AL.AL_BUFFER, buffers[0]); - System.out.println( - "Looping 1: " - + (al.alGetSourcei(sources[0], AL.AL_LOOPING) == AL.AL_TRUE)); int[] loopArray = new int[1]; - al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray); - System.out.println("Looping 2: " + (loopArray[0] == AL.AL_TRUE)); + al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray, 0); + System.out.println("Looping 1: " + (loopArray[0] == AL.AL_TRUE)); int[] loopBuffer = new int[1]; - al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer); - System.out.println("Looping 3: " + (loopBuffer[0] == AL.AL_TRUE)); + al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer, 0); + System.out.println("Looping 2: " + (loopBuffer[0] == AL.AL_TRUE)); if (eaxPresent) { IntBuffer env = BufferUtils.newIntBuffer(1); @@ -117,13 +107,13 @@ public class OpenALTest { } al.alSourceStop(sources[0]); - al.alDeleteSources(1, sources); + al.alDeleteSources(1, sources, 0); alc.alcDestroyContext(context); alc.alcCloseDevice(device); } catch (Exception e) { e.printStackTrace(); } - } catch (OpenALException e) { + } catch (ALException e) { e.printStackTrace(); } } diff --git a/unit_tests/src/Sound3DTest.java b/unit_tests/src/Sound3DTest.java index ffaefb0..f6a65a3 100644 --- a/unit_tests/src/Sound3DTest.java +++ b/unit_tests/src/Sound3DTest.java @@ -18,7 +18,7 @@ * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR -* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS +* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS * LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT @@ -30,16 +30,10 @@ * You acknowledge that this software is not designed or intended for use in the * design, construction, operation or maintenance of any nuclear facility. */ -import java.io.IOException; - -import javax.sound.sampled.UnsupportedAudioFileException; - -import net.java.games.sound3d.AudioSystem3D; -import net.java.games.sound3d.Context; -import net.java.games.sound3d.Device; -import net.java.games.sound3d.Listener; -import net.java.games.sound3d.Sound3DException; -import net.java.games.sound3d.Source; +import java.io.*; +import javax.sound.sampled.*; +import net.java.games.joal.*; +import net.java.games.sound3d.*; /** * @author Athomas Goldberg @@ -56,7 +50,7 @@ public class Sound3DTest { public static void main(String[] args) { try { AudioSystem3D.init(); - } catch (Sound3DException e) { + } catch (ALException e) { e.printStackTrace(); return; } diff --git a/unit_tests/src/net/java/games/joal/ALTest.java b/unit_tests/src/net/java/games/joal/ALTest.java index 024b856..7b25aa1 100644 --- a/unit_tests/src/net/java/games/joal/ALTest.java +++ b/unit_tests/src/net/java/games/joal/ALTest.java @@ -12,8 +12,7 @@ import java.nio.ByteBuffer; import javax.sound.sampled.UnsupportedAudioFileException; import junit.framework.TestCase; -import net.java.games.joal.util.WAVData; -import net.java.games.joal.util.WAVLoader; +import net.java.games.joal.util.*; /** * @author Athomas Goldberg @@ -24,8 +23,8 @@ public class ALTest extends TestCase { static AL al; static ALC alc; - static ALC.Context context; - static ALC.Device device; + static ALCcontext context; + static ALCdevice device; final static String TEST_FILE ="lewiscarroll.wav"; /** @@ -38,13 +37,12 @@ public class ALTest extends TestCase { public void setUp() { try { - ALFactory.initialize(); al = ALFactory.getAL(); alc = ALFactory.getALC(); device = alc.alcOpenDevice(null); context = alc.alcCreateContext(device, null); alc.alcMakeContextCurrent(context); - } catch (OpenALException e) { + } catch (ALException e) { e.printStackTrace(); } } @@ -121,7 +119,7 @@ public class ALTest extends TestCase { // try basic case try { int[] buffers = new int[7]; - al.alGenBuffers(7,buffers); + al.alGenBuffers(7,buffers, 0); for(int i = 0; i < 7; i++) { assertFalse(buffers[i] == 0); assertTrue(al.alIsBuffer(buffers[i])); @@ -134,7 +132,7 @@ public class ALTest extends TestCase { // try exceptions try { int[] buffers = null; - al.alGenBuffers(7,buffers); + al.alGenBuffers(7,buffers, 0); } catch(IllegalArgumentException e) { @@ -144,7 +142,7 @@ public class ALTest extends TestCase { ex = null; try { int[] buffers = new int[5]; - al.alGenBuffers(7,buffers); + al.alGenBuffers(7,buffers, 0); } catch(IllegalArgumentException e) { ex = e; } @@ -162,12 +160,12 @@ public class ALTest extends TestCase { // try basic case try { int[] buffers = new int[7]; - al.alGenBuffers(7,buffers); + al.alGenBuffers(7,buffers,0); for(int i = 0; i < 7; i++) { assertFalse(buffers[i] == 0); assertTrue(al.alIsBuffer(buffers[i])); } - al.alDeleteBuffers(7,buffers); + al.alDeleteBuffers(7,buffers,0); for(int i = 0; i < 7; i++) { assertFalse(al.alIsBuffer(buffers[i])); } @@ -178,7 +176,7 @@ public class ALTest extends TestCase { Exception ex = null; // try exceptions try { - al.alDeleteBuffers(7,(int[])null); + al.alDeleteBuffers(7,(int[])null, 0); } catch(IllegalArgumentException e) { ex = e; } @@ -186,8 +184,8 @@ public class ALTest extends TestCase { ex = null; try { int[] buffers = new int[5]; - al.alGenBuffers(5,buffers); - al.alDeleteBuffers(7,buffers); + al.alGenBuffers(5,buffers,0); + al.alDeleteBuffers(7,buffers,0); } catch(IllegalArgumentException e) { ex = e; } @@ -195,7 +193,7 @@ public class ALTest extends TestCase { try { int[] buffers = new int[7]; - al.alDeleteBuffers(7,buffers); + al.alDeleteBuffers(7,buffers,0); assertTrue(al.alGetError() != 0); } catch(Exception e) { fail("deleting an unfilled buffer list should generate an ALError but not an exception"); @@ -212,12 +210,12 @@ public class ALTest extends TestCase { // try basic case try { int[] buffers = new int[7]; - al.alGenBuffers(7,buffers); + al.alGenBuffers(7,buffers,0); for(int i = 0; i < 7; i++) { assertFalse(buffers[i] == 0); assertTrue(al.alIsBuffer(buffers[i])); } - al.alDeleteBuffers(7,buffers); + al.alDeleteBuffers(7,buffers,0); for(int i = 0; i < 7; i++) { assertFalse(al.alIsBuffer(buffers[i])); } @@ -228,7 +226,7 @@ public class ALTest extends TestCase { Exception ex = null; // try exceptions try { - al.alDeleteBuffers(7,(int[])null); + al.alDeleteBuffers(7,(int[])null,0); } catch(IllegalArgumentException e) { ex = e; } @@ -236,8 +234,8 @@ public class ALTest extends TestCase { ex = null; try { int[] buffers = new int[5]; - al.alGenBuffers(5,buffers); - al.alDeleteBuffers(7,buffers); + al.alGenBuffers(5,buffers,0); + al.alDeleteBuffers(7,buffers,0); } catch(IllegalArgumentException e) { ex = e; } @@ -246,7 +244,7 @@ public class ALTest extends TestCase { ex = null; try { int[] buffers = new int[5]; - al.alDeleteBuffers(7,buffers); + al.alDeleteBuffers(7,buffers,0); } catch(IllegalArgumentException e) { ex = e; } @@ -254,7 +252,7 @@ public class ALTest extends TestCase { try { int[] buffers = new int[7]; - al.alDeleteBuffers(7,buffers); + al.alDeleteBuffers(7,buffers,0); assertTrue(al.alGetError() != 0); } catch(Exception e) { fail("deleting an unfilled buffer list should generate an ALError but not an exception"); @@ -273,12 +271,12 @@ public class ALTest extends TestCase { assertFalse(al.alIsBuffer(buffers[i])); } // created - al.alGenBuffers(7,buffers); + al.alGenBuffers(7,buffers,0); for(int i = 0; i < 7; i++) { assertTrue(al.alIsBuffer(buffers[i])); } // deleted - al.alDeleteBuffers(7,buffers); + al.alDeleteBuffers(7,buffers,0); for(int i = 0; i < 7; i++) { assertFalse(al.alIsBuffer(buffers[i])); } @@ -290,63 +288,13 @@ public class ALTest extends TestCase { } /* - * Test for void alBufferData(int, int, byte[], int, int) - */ - final public void testAlBufferDataintintbyteArrayintint() { - System.out.println("begin testAlBufferDataintintbyteArrayintint"); - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); - WAVData wd = WAVLoader.loadFromFile(TEST_FILE); - int capacity = wd.data.capacity(); - int remaining = wd.data.remaining(); - - byte[] data = new byte[wd.data.capacity()]; - for(int i = 0; i < data.length; i++) { - data[i] = wd.data.get(i); - } - - al.alBufferData( - buffers[0], - wd.format, - data, - wd.size, - wd.freq - ); - - assertFalse(al.alGetBufferi(buffers[0],AL.AL_SIZE) == 0); - } catch(Exception e) { - e.printStackTrace(); - fail(e.toString()); - } - Exception ex = null; - try { - int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); - - al.alBufferData( - buffers[0], - AL.AL_FORMAT_STEREO16, - (byte[])null, - 0, - 0 - ); - } catch(IllegalArgumentException e) { - ex = e; - } - assertNotNull(ex); - - System.out.println("end testAlBufferDataintintbyteArrayintint"); - } - - /* - * Test for void alBufferData(int, int, ByteBuffer, int, int) + * Test for void alBufferData(int, int, Buffer, int, int) */ final public void testAlBufferDataintintByteBufferintint() { System.out.println("begin testAlBufferDataintintByteBufferintint"); try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); WAVData wd = WAVLoader.loadFromFile(TEST_FILE); al.alBufferData( @@ -356,19 +304,21 @@ public class ALTest extends TestCase { wd.size, wd.freq ); - assertFalse(al.alGetBufferi(buffers[0],AL.AL_SIZE) == 0); + int[] tmp = new int[1]; + al.alGetBufferi(buffers[0],AL.AL_SIZE,tmp,0); + assertFalse(tmp[0] == 0); } catch(Exception e) { fail(e.toString()); } Exception ex = null; try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); al.alBufferData( buffers[0], AL.AL_FORMAT_STEREO16, - (ByteBuffer)null, + null, 0, 0 ); @@ -420,7 +370,7 @@ public class ALTest extends TestCase { System.out.println("begin testAlGetBufferiintintintArray"); try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); WAVData wd = WAVLoader.loadFromFile(TEST_FILE); al.alBufferData( @@ -432,8 +382,8 @@ public class ALTest extends TestCase { ); int[] size = new int[1]; int[] freq = new int[1]; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size); - al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq); + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); + al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0); assertEquals(wd.size, size[0]); assertEquals(wd.freq, freq[0]); } catch(Exception e) { @@ -443,7 +393,7 @@ public class ALTest extends TestCase { Exception ex = null; try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); WAVData wd = WAVLoader.loadFromFile(TEST_FILE); al.alBufferData( @@ -454,7 +404,7 @@ public class ALTest extends TestCase { wd.freq ); int[] size = null; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size); + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); } catch (IllegalArgumentException e) { ex = e; @@ -477,7 +427,7 @@ public class ALTest extends TestCase { final public void testAlGetBufferiintintIntBuffer() { try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); WAVData wd = WAVLoader.loadFromFile(TEST_FILE); al.alBufferData( @@ -489,8 +439,8 @@ public class ALTest extends TestCase { ); int[] size = new int[1]; int[] freq = new int[1]; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size); - al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq); + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); + al.alGetBufferi(buffers[0],AL.AL_FREQUENCY, freq, 0); assertEquals(wd.size, size[0]); assertEquals(wd.freq, freq[0]); } catch(Exception e) { @@ -499,7 +449,7 @@ public class ALTest extends TestCase { Exception ex = null; try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); WAVData wd = WAVLoader.loadFromFile(TEST_FILE); al.alBufferData( @@ -510,7 +460,7 @@ public class ALTest extends TestCase { wd.freq ); int[] size = null; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size); + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); } catch (IllegalArgumentException e) { ex = e; @@ -526,7 +476,7 @@ public class ALTest extends TestCase { ex = null; try { int[] buffers = new int[1]; - al.alGenBuffers(1, buffers); + al.alGenBuffers(1, buffers, 0); WAVData wd = WAVLoader.loadFromFile(TEST_FILE); al.alBufferData( @@ -537,7 +487,7 @@ public class ALTest extends TestCase { wd.freq ); int[] size = new int[1]; - al.alGetBufferi(buffers[0],AL.AL_SIZE, size); + al.alGetBufferi(buffers[0],AL.AL_SIZE, size, 0); } catch (IllegalArgumentException e) { ex = e; diff --git a/www/README.txt b/www/README.txt index 3e44092..2f16ff6 100644 --- a/www/README.txt +++ b/www/README.txt @@ -62,7 +62,8 @@ packages and tools have been used: * Windows: -- Win32 (Win XP in the case of our machine) - -- OpenAL1.0 SDK from Creative Labs (available at ftp://opensource.creative.com/pub/sdk/OpenALSDK.exe) + -- OpenAL1.0 SDK from Creative Labs (available at http://developer.creative.com + under "Gaming -> Development Kits -> Open AL") -- MinGW 2.0.0 plus the following updates: (all available at www.mingw.org) -- binutils 2.13.90 -- w32api-2.2 diff --git a/www/index.html b/www/index.html index bc27481..5c3931d 100644 --- a/www/index.html +++ b/www/index.html @@ -80,7 +80,8 @@ <li>Windows: <ul> <li> Win32 (Win XP in the case of our machine)</li> - <li> OpenAL1.0 SDK (available at <a href="ftp://opensource.creative.com/pub/sdk/OpenALSDK.exe">ftp://opensource.creative.com/pub/sdk/OpenALSDK.exe</a>)</li> + <li> OpenAL1.0 SDK (available at <a href="http://developer.creative.com">http://developer.creative.com</a> + under "Gaming -> Development Kits -> OpenAL")</li> <li> MinGW 2.0.0 plus the following updates: (all available at <a href="http://www.mingw.org">www.mingw.org</a>) <ul> |