aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/sound__driver__al_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/sound__driver__al_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/sound__driver__al_8cpp-source.html521
1 files changed, 521 insertions, 0 deletions
diff --git a/docs/doxygen/nel/sound__driver__al_8cpp-source.html b/docs/doxygen/nel/sound__driver__al_8cpp-source.html
new file mode 100644
index 00000000..ee362760
--- /dev/null
+++ b/docs/doxygen/nel/sound__driver__al_8cpp-source.html
@@ -0,0 +1,521 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>sound_driver_al.cpp</h1><a href="sound__driver__al_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026 <font class="preprocessor">#include "<a class="code" href="stdopenal_8h.html">stdopenal.h</a>"</font>
+00027
+00028 <font class="preprocessor">#include "<a class="code" href="buffer__al_8h.html">buffer_al.h</a>"</font>
+00029 <font class="preprocessor">#include "<a class="code" href="listener__al_8h.html">listener_al.h</a>"</font>
+00030
+00031 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00032
+00033
+00034 <font class="keyword">namespace </font>NLSOUND {
+00035
+00036
+00037 <font class="preprocessor">#ifdef EAX_AVAILABLE</font>
+00038 <font class="preprocessor"></font><font class="comment">// EAXSet global function</font>
+00039 EAXSet EAXSetProp = NULL;
+00040
+00041 <font class="comment">// EAXGet global function</font>
+00042 EAXGet EAXGetProp = NULL;
+00043 <font class="preprocessor">#endif</font>
+00044 <font class="preprocessor"></font>
+00045
+00046 <font class="comment">// Currently, the OpenAL headers are different between Windows and Linux versions !</font>
+00047 <font class="comment">// AL_INVALID_XXXX are part of the spec, though.</font>
+00048 <font class="preprocessor">#ifdef NL_OS_UNIX</font>
+00049 <font class="preprocessor"></font><font class="preprocessor">#define AL_INVALID_ENUM AL_ILLEGAL_ENUM </font>
+00050 <font class="preprocessor"></font><font class="preprocessor">#define AL_INVALID_OPERATION AL_ILLEGAL_COMMAND </font>
+00051 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
+00052 <font class="preprocessor"></font>
+00053
+00054 <font class="preprocessor">#ifdef NL_DEBUG</font>
+00055 <font class="preprocessor"></font><font class="comment">// Test error in debug mode</font>
+00056 <font class="keywordtype">void</font> <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>()
+00057 {
+00058 ALuint errcode = alGetError();
+00059 <font class="keywordflow">switch</font>( errcode )
+00060 {
+00061 <font class="keywordflow">case</font> AL_NO_ERROR : <font class="keywordflow">break</font>;
+00062 <font class="keywordflow">case</font> AL_INVALID_NAME : <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"OpenAL: Invalid name"</font> );
+00063 <font class="keywordflow">case</font> AL_INVALID_ENUM : <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"OpenAL: Invalid enum"</font> );
+00064 <font class="keywordflow">case</font> AL_INVALID_VALUE : <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"OpenAL: Invalid value"</font> );
+00065 <font class="keywordflow">case</font> AL_INVALID_OPERATION : <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"OpenAL: Invalid operation"</font> );
+00066 <font class="keywordflow">case</font> AL_OUT_OF_MEMORY : <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"OpenAL: Out of memory"</font> );
+00067 <font class="comment">// alGetString( errcode ) seems to fail !</font>
+00068 }
+00069 }
+00070 <font class="preprocessor">#endif</font>
+00071 <font class="preprocessor"></font>
+00072
+<a name="l00073"></a><a class="code" href="sound__driver__al_8cpp.html#a0">00073</a> <font class="preprocessor">#define INITIAL_BUFFERS 8</font>
+<a name="l00074"></a><a class="code" href="sound__driver__al_8cpp.html#a1">00074</a> <font class="preprocessor"></font><font class="preprocessor">#define INITIAL_SOURCES 8</font>
+<a name="l00075"></a><a class="code" href="sound__driver__al_8cpp.html#a2">00075</a> <font class="preprocessor"></font><font class="preprocessor">#define BUFFER_ALLOC_RATE 8</font>
+<a name="l00076"></a><a class="code" href="sound__driver__al_8cpp.html#a3">00076</a> <font class="preprocessor"></font><font class="preprocessor">#define SOURCE_ALLOC_RATE 8</font>
+00077 <font class="preprocessor"></font>
+<a name="l00078"></a><a class="code" href="sound__driver__al_8cpp.html#a4">00078</a> <font class="preprocessor">#define ROLLOFF_FACTOR_DEFAULT 1.0f</font>
+00079 <font class="preprocessor"></font>
+00080 <font class="comment">/*</font>
+00081 <font class="comment"> * Sound driver instance creation</font>
+00082 <font class="comment"> */</font>
+00083 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00084 <font class="preprocessor"></font>
+00085 __declspec(dllexport) ISoundDriver *NLSOUND_createISoundDriverInstance()
+00086 {
+00087 CSoundDriverAL *driver = <font class="keyword">new</font> CSoundDriverAL();
+00088 driver-&gt;init();
+00089 <font class="keywordflow">return</font> driver;
+00090 }
+00091
+00092 __declspec(dllexport) <a class="code" href="types__nl_8h.html#a9">uint32</a> NLSOUND_interfaceVersion ()
+00093 {
+00094 <font class="keywordflow">return</font> ISoundDriver::InterfaceVersion;
+00095 }
+00096
+00097 <font class="preprocessor">#elif defined (NL_OS_UNIX)</font>
+00098 <font class="preprocessor"></font>
+00099 <font class="keyword">extern</font> <font class="stringliteral">"C"</font>
+00100 {
+00101 ISoundDriver* NLSOUND_createISoundDriverInstance ()
+00102 {
+00103 CSoundDriverAL *driver = <font class="keyword">new</font> CSoundDriverAL();
+00104 driver-&gt;init();
+00105 <font class="keywordflow">return</font> driver;
+00106 }
+00107
+00108 <a class="code" href="types__nl_8h.html#a9">uint32</a> NLSOUND_interfaceVersion ()
+00109 {
+00110 <font class="keywordflow">return</font> ISoundDriver::InterfaceVersion;
+00111 }
+00112 }
+00113
+00114 <font class="preprocessor">#endif // NL_OS_UNIX</font>
+00115 <font class="preprocessor"></font>
+00116
+00117 <font class="comment">// The instance of the singleton</font>
+<a name="l00118"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#r0">00118</a> CSoundDriverAL *CSoundDriverAL::_Instance = NULL;
+00119
+00120
+00121 <font class="comment">/*</font>
+00122 <font class="comment"> * Constructor</font>
+00123 <font class="comment"> */</font>
+<a name="l00124"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a0">00124</a> CSoundDriverAL::CSoundDriverAL() :
+00125 ISoundDriver(), _NbExpBuffers( 0 ), _NbExpSources( 0 ), _RolloffFactor( 1.0f )
+00126 {
+00127 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#r0">_Instance</a> == NULL )
+00128 {
+00129 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#r0">_Instance</a> = <font class="keyword">this</font>;
+00130 }
+00131 <font class="keywordflow">else</font>
+00132 {
+00133 <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"Sound driver singleton instanciated twice"</font> );
+00134 }
+00135 }
+00136
+00137
+00138 <font class="comment">/*</font>
+00139 <font class="comment"> * Destructor</font>
+00140 <font class="comment"> */</font>
+<a name="l00141"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a7">00141</a> CSoundDriverAL::~CSoundDriverAL()
+00142 {
+00143 <font class="comment">// Remove the allocated (but not exported) source and buffer names</font>
+00144 alDeleteSources( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b6">compactAliveNames</a>( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o1">_Sources</a>, alIsSource ), &amp;*<a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o1">_Sources</a>.begin() );
+00145 alDeleteBuffers( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b6">compactAliveNames</a>( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o0">_Buffers</a>, alIsBuffer ), &amp;*<a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o0">_Buffers</a>.begin() );
+00146
+00147 <font class="comment">// OpenAL exit</font>
+00148 alutExit();
+00149
+00150 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#r0">_Instance</a> = NULL;
+00151 }
+00152
+00153
+00154 <font class="comment">/*</font>
+00155 <font class="comment"> * Initialization</font>
+00156 <font class="comment"> */</font>
+<a name="l00157"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a1">00157</a> <font class="keywordtype">bool</font> CSoundDriverAL::init()
+00158 {
+00159 <font class="comment">// OpenAL initialization</font>
+00160 alutInit( NULL, NULL );
+00161
+00162 <font class="comment">// Display version information</font>
+00163 <font class="keyword">const</font> ALubyte *alversion, *alrenderer, *alvendor, *alext;
+00164 alversion = alGetString( AL_VERSION );
+00165 alrenderer = alGetString( AL_RENDERER );
+00166 alvendor = alGetString( AL_VENDOR );
+00167 alext = alGetString( AL_EXTENSIONS );
+00168 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
+00169 <a class="code" href="debug_8h.html#a1">nlinfo</a>( <font class="stringliteral">"Loading OpenAL lib: %s, %s, %s"</font>, alversion, alrenderer, alvendor );
+00170 <a class="code" href="debug_8h.html#a1">nlinfo</a>( <font class="stringliteral">"Listing extensions: %s"</font>, alext );
+00171
+00172 <font class="preprocessor">#ifdef EAX_AVAILABLE</font>
+00173 <font class="preprocessor"></font> <font class="comment">// Set EAX environment if EAX is available</font>
+00174 <font class="keywordflow">if</font> ( alIsExtensionPresent((ALubyte *)<font class="stringliteral">"EAX"</font>) == AL_TRUE ) <font class="comment">// or EAX2.0</font>
+00175 {
+00176 <a class="code" href="debug_8h.html#a1">nlinfo</a>( <font class="stringliteral">"Initializing EAX"</font> );
+00177 EAXSetProp = (EAXSet)alGetProcAddress((ALubyte*)<font class="stringliteral">"EAXSet"</font>);
+00178 EAXGetProp = (EAXGet)alGetProcAddress((ALubyte*)<font class="stringliteral">"EAXGet"</font>);
+00179 <font class="keywordflow">if</font> ( EAXSetProp != NULL )
+00180 {
+00181 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> ulEAXVal;
+00182 <font class="keywordtype">long</font> lGlobalReverb;
+00183 lGlobalReverb = 0;
+00184 EAXSetProp( &amp;DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ROOM, 0, &amp;lGlobalReverb, <font class="keyword">sizeof</font>(<font class="keywordtype">unsigned</font> <font class="keywordtype">long</font>) );
+00185 ulEAXVal = EAX_ENVIRONMENT_GENERIC;
+00186 EAXSetProp( &amp;DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENT, 0, &amp;ulEAXVal, <font class="keyword">sizeof</font>(<font class="keywordtype">unsigned</font> <font class="keywordtype">long</font>) );
+00187 }
+00188 }
+00189 <font class="keywordflow">else</font>
+00190 <font class="preprocessor">#endif</font>
+00191 <font class="preprocessor"></font> {
+00192 <a class="code" href="debug_8h.html#a1">nlinfo</a>( <font class="stringliteral">"EAX not available"</font> );
+00193 }
+00194
+00195 <font class="comment">// Choose the I3DL2 model (same as DirectSound3D)</font>
+00196 alDistanceModel( AL_INVERSE_DISTANCE_CLAMPED );
+00197 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
+00198
+00199 <font class="comment">// Initial buffers and sources allocation</font>
+00200 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b4">allocateNewItems</a>( alGenBuffers, alIsBuffer, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o0">_Buffers</a>, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o2">_NbExpBuffers</a>, <a class="code" href="sound__driver__al_8cpp.html#a0">INITIAL_BUFFERS</a> );
+00201 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b4">allocateNewItems</a>( alGenSources, alIsSource, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o1">_Sources</a>, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o3">_NbExpSources</a>, <a class="code" href="sound__driver__al_8cpp.html#a1">INITIAL_SOURCES</a> );
+00202
+00203 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00204 }
+00205
+00206
+00207 <font class="comment">/*</font>
+00208 <font class="comment"> * Allocate nb new items</font>
+00209 <font class="comment"> */</font>
+<a name="l00210"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b4">00210</a> <font class="keywordtype">void</font> CSoundDriverAL::allocateNewItems( <a class="code" href="namespaceNLSOUND.html#a12">TGenFunctionAL</a> algenfunc, <a class="code" href="namespaceNLSOUND.html#a13">TTestFunctionAL</a> altestfunc,
+00211 vector&lt;ALuint&gt;&amp; names, <a class="code" href="types__nl_8h.html#a13">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a>, <a class="code" href="types__nl_8h.html#a13">uint</a> nb )
+00212 {
+00213 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a> == names.size() );
+00214 names.resize( <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a> + nb );
+00215 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b5">generateItems</a>( algenfunc, altestfunc, nb, &amp;(names[<a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a>]) );
+00216 }
+00217
+00218
+00219 <font class="comment">/*</font>
+00220 <font class="comment"> * throwGenException</font>
+00221 <font class="comment"> */</font>
+00222 <font class="keywordtype">void</font> <a class="code" href="namespaceNLSOUND.html#a48">ThrowGenException</a>( <a class="code" href="namespaceNLSOUND.html#a12">TGenFunctionAL</a> algenfunc )
+00223 {
+00224 <font class="keywordflow">if</font> ( algenfunc == alGenBuffers )
+00225 <font class="keywordflow">throw</font> ESoundDriverGenBuf();
+00226 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( algenfunc == alGenSources )
+00227 <font class="keywordflow">throw</font> ESoundDriverGenSrc();
+00228 <font class="keywordflow">else</font>
+00229 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00230 }
+00231
+00232 <font class="comment">/*</font>
+00233 <font class="comment"> * Generate nb buffers/sources</font>
+00234 <font class="comment"> */</font>
+<a name="l00235"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b5">00235</a> <font class="keywordtype">void</font> CSoundDriverAL::generateItems( <a class="code" href="namespaceNLSOUND.html#a12">TGenFunctionAL</a> algenfunc, <a class="code" href="namespaceNLSOUND.html#a13">TTestFunctionAL</a> altestfunc, <a class="code" href="types__nl_8h.html#a13">uint</a> nb, ALuint *array )
+00236 {
+00237 algenfunc( nb, array );
+00238
+00239 <font class="comment">// Error handling</font>
+00240 <font class="keywordflow">if</font> ( alGetError() != AL_NO_ERROR )
+00241 {
+00242 <a class="code" href="namespaceNLSOUND.html#a48">ThrowGenException</a>( algenfunc );
+00243 }
+00244
+00245 <font class="comment">// Check buffers</font>
+00246 <a class="code" href="types__nl_8h.html#a13">uint</a> i;
+00247 <font class="keywordflow">for</font> ( i=0; i!=nb; i++ )
+00248 {
+00249 <font class="keywordflow">if</font> ( ! altestfunc( array[i] ) )
+00250 {
+00251 <a class="code" href="namespaceNLSOUND.html#a48">ThrowGenException</a>( algenfunc );
+00252 }
+00253 }
+00254 }
+00255
+00256
+00257 <font class="comment">/*</font>
+00258 <font class="comment"> * Create a sound buffer</font>
+00259 <font class="comment"> */</font>
+<a name="l00260"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a2">00260</a> IBuffer *CSoundDriverAL::createBuffer()
+00261 {
+00262 <font class="keywordflow">return</font> <font class="keyword">new</font> CBufferAL( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b7">createItem</a>( alGenBuffers, alIsBuffer, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o0">_Buffers</a>, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o2">_NbExpBuffers</a>, <a class="code" href="sound__driver__al_8cpp.html#a2">BUFFER_ALLOC_RATE</a> ) );
+00263 }
+00264
+00265
+00266 <font class="comment">/*</font>
+00267 <font class="comment"> * Create a source</font>
+00268 <font class="comment"> */</font>
+<a name="l00269"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a4">00269</a> ISource *CSoundDriverAL::createSource()
+00270 {
+00271 CSourceAL *sourceal = <font class="keyword">new</font> CSourceAL( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b7">createItem</a>( alGenSources, alIsSource, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o1">_Sources</a>, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o3">_NbExpSources</a>, <a class="code" href="sound__driver__al_8cpp.html#a3">SOURCE_ALLOC_RATE</a> ) );
+00272 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o4">_RolloffFactor</a> != <a class="code" href="sound__driver__al_8cpp.html#a4">ROLLOFF_FACTOR_DEFAULT</a> )
+00273 {
+00274 alSourcef( sourceal-&gt;sourceName(), AL_ROLLOFF_FACTOR, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o4">_RolloffFactor</a> );
+00275 }
+00276 <font class="keywordflow">return</font> sourceal;
+00277 }
+00278
+00279
+00280 <font class="comment">/*</font>
+00281 <font class="comment"> * Create a sound buffer or a sound source</font>
+00282 <font class="comment"> */</font>
+<a name="l00283"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b7">00283</a> ALuint CSoundDriverAL::createItem( <a class="code" href="namespaceNLSOUND.html#a12">TGenFunctionAL</a> algenfunc, <a class="code" href="namespaceNLSOUND.html#a13">TTestFunctionAL</a> altestfunc,
+00284 vector&lt;ALuint&gt;&amp; names, <a class="code" href="types__nl_8h.html#a13">uint</a>&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a>, <a class="code" href="types__nl_8h.html#a13">uint</a> allocrate )
+00285 {
+00286 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a> &lt;= names.size() );
+00287 <font class="keywordflow">if</font> ( <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a> == names.size() )
+00288 {
+00289 <font class="comment">// Generate new items</font>
+00290 <a class="code" href="types__nl_8h.html#a13">uint</a> nbalive = <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b6">compactAliveNames</a>( names, altestfunc );
+00291 <font class="keywordflow">if</font> ( nbalive == names.size() )
+00292 {
+00293 <font class="comment">// Extend vector of names</font>
+00294 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b4">allocateNewItems</a>( algenfunc, altestfunc, names, <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a>, allocrate );
+00295 }
+00296 <font class="keywordflow">else</font>
+00297 {
+00298 <font class="comment">// Take the room of the deleted names</font>
+00299 <a class="code" href="debug_8h.html#a6">nlassert</a>( nbalive &lt; names.size() );
+00300 <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a> = nbalive;
+00301 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b5">generateItems</a>( algenfunc, altestfunc, names.size() - nbalive, &amp;(names[nbalive]) );
+00302 }
+00303 }
+00304
+00305 <font class="comment">// Return the name of the item</font>
+00306 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a> &lt; names.size() );
+00307 ALuint itemname = names[<a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a>];
+00308 <a class="code" href="driver__opengl__extension__def_8h.html#a225">index</a>++;
+00309 <font class="keywordflow">return</font> itemname;
+00310 }
+00311
+00312
+00313 <font class="comment">/*</font>
+00314 <font class="comment"> * Remove names of deleted buffers and return the number of valid buffers</font>
+00315 <font class="comment"> */</font>
+<a name="l00316"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b6">00316</a> <a class="code" href="types__nl_8h.html#a13">uint</a> CSoundDriverAL::compactAliveNames( vector&lt;ALuint&gt;&amp; names, <a class="code" href="namespaceNLSOUND.html#a13">TTestFunctionAL</a> altestfunc )
+00317 {
+00318 vector&lt;ALuint&gt;::iterator iball, ibcompacted;
+00319 <font class="keywordflow">for</font> ( iball=names.begin(), ibcompacted=names.begin(); iball!=names.end(); ++iball )
+00320 {
+00321 <font class="comment">// iball is incremented every iteration</font>
+00322 <font class="comment">// ibcompacted is not incremented if a buffer is not valid anymore</font>
+00323 <font class="keywordflow">if</font> ( altestfunc( *iball ) )
+00324 {
+00325 *ibcompacted = *iball;
+00326 ++ibcompacted;
+00327 }
+00328 }
+00329 <a class="code" href="debug_8h.html#a6">nlassert</a>( ibcompacted &lt;= names.end() );
+00330 <font class="keywordflow">return</font> ibcompacted - names.begin();
+00331 }
+00332
+00333
+00334 <font class="comment">/*</font>
+00335 <font class="comment"> * Remove a buffer</font>
+00336 <font class="comment"> */</font>
+<a name="l00337"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b2">00337</a> <font class="keywordtype">void</font> CSoundDriverAL::removeBuffer( IBuffer *buffer )
+00338 {
+00339 <a class="code" href="debug_8h.html#a6">nlassert</a>( buffer != NULL );
+00340 CBufferAL *bufferAL = dynamic_cast&lt;CBufferAL*&gt;(buffer);
+00341 <font class="keywordflow">if</font> ( ! <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b8">deleteItem</a>( bufferAL-&gt;bufferName(), alDeleteBuffers, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o0">_Buffers</a> ) )
+00342 {
+00343 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"Deleting buffer: name not found"</font> );
+00344 }
+00345 }
+00346
+00347
+00348 <font class="comment">/*</font>
+00349 <font class="comment"> * Remove a source</font>
+00350 <font class="comment"> */</font>
+<a name="l00351"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b3">00351</a> <font class="keywordtype">void</font> CSoundDriverAL::removeSource( ISource *source )
+00352 {
+00353 <a class="code" href="debug_8h.html#a6">nlassert</a>( source != NULL );
+00354 CSourceAL *sourceAL = dynamic_cast&lt;CSourceAL*&gt;(source);
+00355 <font class="keywordflow">if</font> ( ! <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b8">deleteItem</a>( sourceAL-&gt;sourceName(), alDeleteSources, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o1">_Sources</a> ) )
+00356 {
+00357 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"Deleting source: name not found"</font> );
+00358 }
+00359 }
+00360
+00361
+00362 <font class="comment">/*</font>
+00363 <font class="comment"> * Delete a buffer or a source</font>
+00364 <font class="comment"> */</font>
+<a name="l00365"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#b8">00365</a> <font class="keywordtype">bool</font> CSoundDriverAL::deleteItem( ALuint name, <a class="code" href="namespaceNLSOUND.html#a12">TGenFunctionAL</a> aldeletefunc, vector&lt;ALuint&gt;&amp; names )
+00366 {
+00367 vector&lt;ALuint&gt;::iterator ibn = find( names.begin(), names.end(), name );
+00368 <font class="keywordflow">if</font> ( ibn == names.end() )
+00369 {
+00370 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00371 }
+00372 aldeletefunc( 1, &amp;*ibn );
+00373 *ibn = AL_NONE;
+00374 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
+00375 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00376 }
+00377
+00378
+00379 <font class="comment">/*</font>
+00380 <font class="comment"> * Create the listener instance</font>
+00381 <font class="comment"> */</font>
+<a name="l00382"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a3">00382</a> IListener *CSoundDriverAL::createListener()
+00383 {
+00384 <a class="code" href="debug_8h.html#a6">nlassert</a>( CListenerAL::instance() == NULL );
+00385 <font class="keywordflow">return</font> <font class="keyword">new</font> CListenerAL();
+00386 }
+00387
+00388
+00389 <font class="comment">/*</font>
+00390 <font class="comment"> * Apply changes of rolloff factor to all sources</font>
+00391 <font class="comment"> */</font>
+<a name="l00392"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a5">00392</a> <font class="keywordtype">void</font> CSoundDriverAL::applyRolloffFactor( <font class="keywordtype">float</font> f )
+00393 {
+00394 <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o4">_RolloffFactor</a> = f;
+00395 vector&lt;ALuint&gt;::iterator ibn;
+00396 <font class="keywordflow">for</font> ( ibn=<a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o1">_Sources</a>.begin(); ibn!=<a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o1">_Sources</a>.end(); ++ibn )
+00397 {
+00398 alSourcef( *ibn, AL_ROLLOFF_FACTOR, <a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#o4">_RolloffFactor</a> );
+00399 }
+00400 <a class="code" href="sound__driver__al_8h.html#a0">TestALError</a>();
+00401 }
+00402
+00403
+00404 <font class="comment">/*</font>
+00405 <font class="comment"> * Helper for loadWavFile()</font>
+00406 <font class="comment"> */</font>
+00407 <a class="code" href="namespaceNLSOUND.html#a51">TSampleFormat</a> <a class="code" href="namespaceNLSOUND.html#a49">ALtoNLSoundFormat</a>( ALenum alformat )
+00408 {
+00409 <font class="keywordflow">switch</font> ( alformat )
+00410 {
+00411 <font class="keywordflow">case</font> AL_FORMAT_MONO8 : <font class="keywordflow">return</font> <a class="code" href="namespaceNLSOUND.html#a51a8">Mono8</a>;
+00412 <font class="keywordflow">case</font> AL_FORMAT_MONO16 : <font class="keywordflow">return</font> <a class="code" href="namespaceNLSOUND.html#a51a9">Mono16</a>;
+00413 <font class="keywordflow">case</font> AL_FORMAT_STEREO8 : <font class="keywordflow">return</font> <a class="code" href="namespaceNLSOUND.html#a51a10">Stereo8</a>;
+00414 <font class="keywordflow">case</font> AL_FORMAT_STEREO16 : <font class="keywordflow">return</font> <a class="code" href="namespaceNLSOUND.html#a51a11">Stereo16</a>;
+00415 <font class="keywordflow">default</font> : <a class="code" href="debug_8h.html#a12">nlstop</a>; <font class="keywordflow">return</font> <a class="code" href="namespaceNLSOUND.html#a51a8">Mono8</a>;
+00416 }
+00417 }
+00418
+00419
+00420 <font class="comment">/*</font>
+00421 <font class="comment"> * Temp</font>
+00422 <font class="comment"> */</font>
+<a name="l00423"></a><a class="code" href="classNLSOUND_1_1CSoundDriverAL.html#a6">00423</a> <font class="keywordtype">bool</font> CSoundDriverAL::loadWavFile( IBuffer *destbuffer, <font class="keyword">const</font> <font class="keywordtype">char</font> *filename )
+00424 {
+00425 <font class="comment">// Currently, the OpenAL UT headers are different between Windows and Linux versions</font>
+00426 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00427 <font class="preprocessor"></font> ALsizei <a class="code" href="lexlang_8cpp.html#a56">size</a>,freq;
+00428 ALenum <a class="code" href="driver__opengl__extension__def_8h.html#a259">format</a>;
+00429 ALvoid *<a class="code" href="driver__opengl__extension__def_8h.html#a255">data</a>;
+00430 ALboolean loop;
+00431 alutLoadWAVFile( const_cast&lt;char*&gt;(filename), &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a259">format</a>, &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a255">data</a>, &amp;<a class="code" href="lexlang_8cpp.html#a56">size</a>, &amp;freq, &amp;loop ); <font class="comment">// last arg in some al.h</font>
+00432 <font class="preprocessor">#else</font>
+00433 <font class="preprocessor"></font> ALsizei bits;
+00434 ALsizei <a class="code" href="lexlang_8cpp.html#a56">size</a>,freq;
+00435 ALsizei <a class="code" href="driver__opengl__extension__def_8h.html#a259">format</a>;
+00436 ALvoid *<a class="code" href="driver__opengl__extension__def_8h.html#a255">data</a>;
+00437 alutLoadWAV( const_cast&lt;char*&gt;(filename), &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a255">data</a>, &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a259">format</a>, &amp;<a class="code" href="lexlang_8cpp.html#a56">size</a>, &amp;bits, &amp;freq );
+00438 <font class="preprocessor">#endif</font>
+00439 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( <a class="code" href="driver__opengl__extension__def_8h.html#a255">data</a> == NULL )
+00440 {
+00441 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00442 }
+00443 destbuffer-&gt;setFormat( <a class="code" href="namespaceNLSOUND.html#a49">ALtoNLSoundFormat</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a259">format</a>), freq );
+00444 destbuffer-&gt;fillBuffer( <a class="code" href="driver__opengl__extension__def_8h.html#a255">data</a>, <a class="code" href="lexlang_8cpp.html#a56">size</a> );
+00445 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00446 <font class="preprocessor"></font> alutUnloadWAV(<a class="code" href="driver__opengl__extension__def_8h.html#a259">format</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a255">data</a>,<a class="code" href="lexlang_8cpp.html#a56">size</a>,freq); <font class="comment">// Where is it on Linux ?!?</font>
+00447 <font class="preprocessor">#endif</font>
+00448 <font class="preprocessor"></font> <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00449 }
+00450
+00451
+00452 } <font class="comment">// NLSOUND</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>