aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/sound__driver__dsound_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/sound__driver__dsound_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/sound__driver__dsound_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/sound__driver__dsound_8cpp-source.html895
1 files changed, 895 insertions, 0 deletions
diff --git a/docs/doxygen/nel/sound__driver__dsound_8cpp-source.html b/docs/doxygen/nel/sound__driver__dsound_8cpp-source.html
new file mode 100644
index 00000000..380a238d
--- /dev/null
+++ b/docs/doxygen/nel/sound__driver__dsound_8cpp-source.html
@@ -0,0 +1,895 @@
+<!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_dsound.cpp</h1><a href="sound__driver__dsound_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
+00027 <font class="comment">// The one and only INITGUID</font>
+<a name="l00028"></a><a class="code" href="sound__driver__dsound_8cpp.html#a0">00028</a> <font class="preprocessor">#define INITGUID</font>
+00029 <font class="preprocessor"></font>
+00030 <font class="preprocessor">#include "<a class="code" href="stddsound_8h.html">stddsound.h</a>"</font>
+00031
+00032
+00033 <font class="preprocessor">#include "<a class="code" href="sound__driver__dsound_8h.html">sound_driver_dsound.h</a>"</font>
+00034 <font class="preprocessor">#include "<a class="code" href="listener__dsound_8h.html">listener_dsound.h</a>"</font>
+00035 <font class="preprocessor">#include &lt;math.h&gt;</font>
+00036
+00037
+00038 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00039 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00040
+00041
+00042 <font class="keyword">namespace </font>NLSOUND {
+00043
+<a name="l00044"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#r0">00044</a> CSoundDriverDSound* CSoundDriverDSound::_Instance = NULL;
+<a name="l00045"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#r1">00045</a> uint32 CSoundDriverDSound::_TimerPeriod = 100;
+00046 HINSTANCE <a class="code" href="namespaceNLSOUND.html#a25">CSoundDriverDllHandle</a> = 0;
+00047 HWND <a class="code" href="namespaceNLSOUND.html#a26">CSoundDriverWnd</a> = 0;
+00048
+00049
+00050 <font class="comment">// ******************************************************************</font>
+00051 <font class="comment">// The main entry of the DLL. It's used to get a hold of the hModule handle.</font>
+00052
+00053 BOOL WINAPI <a class="code" href="namespaceNLSOUND.html#a76">DllMain</a>(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
+00054 {
+00055 <a class="code" href="namespaceNLSOUND.html#a25">CSoundDriverDllHandle</a> = (HINSTANCE) hModule;
+00056 <font class="keywordflow">return</font> TRUE;
+00057 }
+00058
+00059
+00060 <font class="comment">// ******************************************************************</font>
+00061 <font class="comment">// The event handling procedure of the invisible window created below. </font>
+00062
+00063 <font class="keywordtype">long</font> FAR PASCAL <a class="code" href="namespaceNLSOUND.html#a77">CSoundDriverCreateWindowProc</a>(HWND hWnd, <font class="keywordtype">unsigned</font> message, WPARAM wParam, LPARAM lParam)
+00064 {
+00065 <font class="keywordflow">return</font> DefWindowProc(hWnd, message, wParam, lParam);
+00066 }
+00067
+00068 <font class="comment">// ******************************************************************</font>
+00069
+00070 <a class="code" href="namespaceNLSOUND.html#a78">__declspec</a>(dllexport) ISoundDriver *NLSOUND_createISoundDriverInstance()
+00071 {
+00072 <font class="keyword">static</font> <font class="keywordtype">bool</font> Registered = <font class="keyword">false</font>;
+00073
+00074 <font class="keywordflow">if</font> (!Registered)
+00075 {
+00076 <font class="comment">// Don't ask me why we have to create a window to do sound!</font>
+00077 <font class="comment">// echo &lt;your comment&gt; | mail support@microsoft.com -s "F#%@cking window"</font>
+00078 WNDCLASS myClass;
+00079 myClass.hCursor = LoadCursor( NULL, IDC_ARROW );
+00080 myClass.hIcon = NULL;
+00081 myClass.lpszMenuName = (LPSTR) NULL;
+00082 myClass.lpszClassName = (LPSTR) <font class="stringliteral">"CSoundDriver"</font>;
+00083 myClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
+00084 myClass.hInstance = <a class="code" href="namespaceNLSOUND.html#a25">CSoundDriverDllHandle</a>;
+00085 myClass.style = CS_GLOBALCLASS;
+00086 myClass.lpfnWndProc = <a class="code" href="namespaceNLSOUND.html#a77">CSoundDriverCreateWindowProc</a>;
+00087 myClass.cbClsExtra = 0;
+00088 myClass.cbWndExtra = 0;
+00089
+00090 <font class="keywordflow">if</font> (!RegisterClass(&amp;myClass))
+00091 {
+00092 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Failed to initialize the sound driver (RegisterClass)"</font>);
+00093 <font class="keywordflow">return</font> 0;
+00094 }
+00095
+00096 Registered = <font class="keyword">true</font>;
+00097 }
+00098
+00099 <a class="code" href="namespaceNLSOUND.html#a26">CSoundDriverWnd</a> = CreateWindow((LPSTR) <font class="stringliteral">"CSoundDriver"</font>, (LPSTR) <font class="stringliteral">"CSoundDriver"</font>, WS_OVERLAPPEDWINDOW,
+00100 CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, (HMENU) NULL,
+00101 <a class="code" href="namespaceNLSOUND.html#a25">CSoundDriverDllHandle</a>, (LPSTR) NULL);
+00102
+00103 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLSOUND.html#a26">CSoundDriverWnd</a> == NULL)
+00104 {
+00105 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Failed to initialize the sound driver (CreateWindow)"</font>);
+00106 <font class="keywordflow">return</font> 0;
+00107 }
+00108
+00109 CSoundDriverDSound *driver = <font class="keyword">new</font> CSoundDriverDSound();
+00110 driver-&gt;init(<a class="code" href="namespaceNLSOUND.html#a26">CSoundDriverWnd</a>);
+00111
+00112 <font class="keywordflow">return</font> driver;
+00113 }
+00114
+00115 <font class="comment">// ******************************************************************</font>
+00116
+00117 <a class="code" href="namespaceNLSOUND.html#a78">__declspec</a>(dllexport) uint32 NLSOUND_interfaceVersion()
+00118 {
+00119 <font class="keywordflow">return</font> ISoundDriver::InterfaceVersion;
+00120 }
+00121
+00122 <font class="comment">// ******************************************************************</font>
+00123
+00124 <a class="code" href="namespaceNLSOUND.html#a78">__declspec</a>(dllexport) <font class="keywordtype">void</font> NLSOUND_outputProfile(ostream &amp;out)
+00125 {
+00126 CSoundDriverDSound::instance()-&gt;writeProfile(out);
+00127 }
+00128
+00129
+00130
+00131
+00132
+00133 <font class="comment">// ******************************************************************</font>
+00134
+<a name="l00135"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a0">00135</a> CSoundDriverDSound::CSoundDriverDSound() : ISoundDriver()
+00136 {
+00137 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#r0">_Instance</a> == NULL )
+00138 {
+00139 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#r0">_Instance</a> = <font class="keyword">this</font>;
+00140
+00141 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a> = NULL;
+00142 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> = NULL;
+00143 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o4">_SourceCount</a> = 0;
+00144 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o5">_TimerID</a> = NULL;
+00145
+00146 <font class="preprocessor">#if NLSOUND_PROFILE</font>
+00147 <font class="preprocessor"></font> _TimerIntervalCount = 0;
+00148 _TotalTime = 0.0;
+00149 _TotalUpdateTime = 0.0;
+00150 _UpdateCount = 0;
+00151 _UpdateSources = 0;
+00152 _UpdateExec = 0;
+00153 <font class="preprocessor">#endif</font>
+00154 <font class="preprocessor"></font>
+00155 }
+00156 <font class="keywordflow">else</font>
+00157 {
+00158 <a class="code" href="debug_8h.html#a3">nlerror</a>(<font class="stringliteral">"Sound driver singleton instanciated twice"</font>);
+00159 }
+00160 }
+00161
+00162 <font class="comment">// ******************************************************************</font>
+00163
+<a name="l00164"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a1">00164</a> CSoundDriverDSound::~CSoundDriverDSound()
+00165 {
+00166 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Destroying DirectSound driver"</font>);
+00167
+00168 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o5">_TimerID</a> != NULL)
+00169 {
+00170 timeKillEvent(<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o5">_TimerID</a>);
+00171 timeEndPeriod(<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o6">_TimerResolution</a>);
+00172 }
+00173
+00174
+00175 <font class="comment">// Assure that the remaining sources have released all their DSBuffers </font>
+00176 <font class="comment">// before closing down DirectSound</font>
+00177 set&lt;CSourceDSound*&gt;::iterator iter;
+00178
+00179 <font class="keywordflow">for</font> (iter = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.begin(); iter != <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.end(); iter++)
+00180 {
+00181 (*iter)-&gt;release();
+00182 }
+00183
+00184
+00185 <font class="comment">// Assure that the listener has released all resources before closing </font>
+00186 <font class="comment">// down DirectSound</font>
+00187 <font class="keywordflow">if</font> (CListenerDSound::instance() != 0)
+00188 {
+00189 CListenerDSound::instance()-&gt;release();
+00190 }
+00191
+00192
+00193 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> != NULL)
+00194 {
+00195 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a>-&gt;Release();
+00196 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> = NULL;
+00197 }
+00198
+00199 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a> != NULL)
+00200 {
+00201 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;Release();
+00202 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a> = NULL;
+00203 }
+00204
+00205 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#r0">_Instance</a> = 0;
+00206 }
+00207
+00208 <font class="comment">// ******************************************************************</font>
+00209
+<a name="l00210"></a><a class="code" href="classNLSOUND_1_1CDeviceDescription.html">00210</a> <font class="keyword">class </font>CDeviceDescription
+00211 {
+00212 <font class="keyword">public</font>:
+00213
+00214 <font class="keyword">static</font> <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#a0">CDeviceDescription</a>* <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#p0">_List</a>;
+00215
+<a name="l00216"></a><a class="code" href="classNLSOUND_1_1CDeviceDescription.html#a0">00216</a> <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#a0">CDeviceDescription</a>(LPGUID guid, <font class="keyword">const</font> <font class="keywordtype">char</font>* descr)
+00217 {
+00218 <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m2">_Guid</a> = guid;
+00219 <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m0">_Description</a> = strdup(descr);
+00220 <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m1">_Next</a> = _List;
+00221 _List = <font class="keyword">this</font>;
+00222 }
+00223
+<a name="l00224"></a><a class="code" href="classNLSOUND_1_1CDeviceDescription.html#a1">00224</a> <font class="keyword">virtual</font> <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#a1">~CDeviceDescription</a>()
+00225 {
+00226 <font class="keywordflow">if</font> (_Description)
+00227 {
+00228 free(<a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m0">_Description</a>);
+00229 }
+00230 <font class="keywordflow">if</font> (_Next)
+00231 {
+00232 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m1">_Next</a>;
+00233 }
+00234 }
+00235
+<a name="l00236"></a><a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m0">00236</a> <font class="keywordtype">char</font>* <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m0">_Description</a>;
+<a name="l00237"></a><a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m1">00237</a> <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#a0">CDeviceDescription</a>* <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m1">_Next</a>;
+<a name="l00238"></a><a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m2">00238</a> LPGUID <a class="code" href="classNLSOUND_1_1CDeviceDescription.html#m2">_Guid</a>;
+00239 };
+00240
+<a name="l00241"></a><a class="code" href="classNLSOUND_1_1CDeviceDescription.html#p0">00241</a> CDeviceDescription* CDeviceDescription::_List = 0;
+00242
+00243
+00244 BOOL CALLBACK <a class="code" href="namespaceNLSOUND.html#a79">CSoundDriverDSoundEnumCallback</a>(LPGUID guid, LPCSTR description, PCSTR module, LPVOID context)
+00245 {
+00246 <font class="keyword">new</font> CDeviceDescription(guid, description);
+00247 <font class="keywordflow">return</font> TRUE;
+00248 }
+00249
+00250 <font class="comment">// ******************************************************************</font>
+00251
+<a name="l00252"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a3">00252</a> <font class="keywordtype">bool</font> CSoundDriverDSound::init(HWND wnd)
+00253 {
+00254 <font class="keywordflow">if</font> (FAILED(DirectSoundEnumerate(<a class="code" href="namespaceNLSOUND.html#a79">CSoundDriverDSoundEnumCallback</a>, <font class="keyword">this</font>)))
+00255 {
+00256 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to enumerate the DirectSound devices"</font>);
+00257 }
+00258
+00259 <font class="comment">// Create a DirectSound object and set the cooperative level.</font>
+00260
+00261 <font class="keywordflow">if</font> (DirectSoundCreate(NULL, &amp;<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>, NULL) != DS_OK)
+00262 {
+00263 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to create the DirectSound object"</font>);
+00264 }
+00265
+00266
+00267 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;SetCooperativeLevel(wnd, DSSCL_PRIORITY) != DS_OK)
+00268 {
+00269 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to set the cooperative level"</font>);
+00270 }
+00271
+00272
+00273 <font class="comment">// Analyse the capabilities of the sound driver/device</font>
+00274
+00275 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o2">_Caps</a>.dwSize = <font class="keyword">sizeof</font>(_Caps);
+00276
+00277 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;GetCaps(&amp;<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o2">_Caps</a>) != DS_OK)
+00278 {
+00279 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to query the sound device caps"</font>);
+00280 }
+00281
+00282
+00283 <font class="comment">// Create primary buffer </font>
+00284
+00285 DSBUFFERDESC desc;
+00286
+00287 ZeroMemory(&amp;desc, <font class="keyword">sizeof</font>(DSBUFFERDESC));
+00288 desc.dwSize = <font class="keyword">sizeof</font>(DSBUFFERDESC);
+00289
+00290
+00291 <font class="comment">// First, try to allocate a 3D hardware buffer.</font>
+00292 <font class="comment">// If we can't get a 3D hardware buffer, use a 2D hardware buffer.</font>
+00293 <font class="comment">// As last option, use a 2D software buffer.</font>
+00294
+00295 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a9">countHw3DBuffers</a>() &gt; 0)
+00296 {
+00297 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Primary buffer: Allocating 3D buffer in hardware"</font>);
+00298 desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCHARDWARE | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME;
+00299 }
+00300 <font class="keywordflow">else</font>
+00301 {
+00302 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Primary buffer: Allocating 3D buffer in software"</font>);
+00303 desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME;
+00304 desc.guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION;
+00305 }
+00306
+00307
+00308 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;CreateSoundBuffer(&amp;desc, &amp;<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a>, NULL) != DS_OK)
+00309 {
+00310
+00311 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Primary buffer: Failed to create a buffer with 3D capabilities."</font>);
+00312
+00313 ZeroMemory(&amp;desc, <font class="keyword">sizeof</font>(DSBUFFERDESC));
+00314 desc.dwSize = <font class="keyword">sizeof</font>(DSBUFFERDESC);
+00315
+00316 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a10">countHw2DBuffers</a>() &gt; 0)
+00317 {
+00318 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Primary buffer: Allocating 2D buffer in hardware"</font>);
+00319 desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCHARDWARE | DSBCAPS_CTRLVOLUME;
+00320 }
+00321 <font class="keywordflow">else</font>
+00322 {
+00323 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Primary buffer: Allocating 2D buffer in software"</font>);
+00324 desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRLVOLUME;
+00325 }
+00326
+00327 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;CreateSoundBuffer(&amp;desc, &amp;<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a>, NULL) != DS_OK)
+00328 {
+00329 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to create the primary buffer"</font>);
+00330 }
+00331 }
+00332
+00333
+00334 <font class="comment">// Set the format of the primary buffer</font>
+00335
+00336 WAVEFORMATEX <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>;
+00337
+00338 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.cbSize = <font class="keyword">sizeof</font>(WAVEFORMATEX);
+00339
+00340 <font class="comment">// Make sure the sound card accepts the default settings.</font>
+00341 <font class="comment">// For now, only the default settings are accepted. Fallback</font>
+00342 <font class="comment">// strategy will be handled later.</font>
+00343
+00344 <font class="keywordflow">if</font> ((<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o2">_Caps</a>.dwMinSecondarySampleRate &gt; 22050) &amp;&amp; (22050 &gt; <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o2">_Caps</a>.dwMaxSecondarySampleRate)) {
+00345 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Unsupported sample rate range"</font>);
+00346 }
+00347
+00348 <font class="keywordflow">if</font> ((<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o2">_Caps</a>.dwFlags &amp; DSCAPS_PRIMARY16BIT) == 0) {
+00349 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Unsupported sample size [16bits]"</font>);
+00350 }
+00351
+00352 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.wBitsPerSample = 16;
+00353 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.nChannels = 1;
+00354 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.nSamplesPerSec = 22050;
+00355 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.nBlockAlign = <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.nChannels * <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.wBitsPerSample / 8;
+00356 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.nAvgBytesPerSec = <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.nSamplesPerSec * <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.nBlockAlign;
+00357 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>.wFormatTag = WAVE_FORMAT_PCM;
+00358
+00359
+00360 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a>-&gt;SetFormat(&amp;<a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>) != DS_OK)
+00361 {
+00362 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to create set the format of the primary buffer"</font>);
+00363 }
+00364
+00365
+00366 uint32 numBuffers = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a9">countHw3DBuffers</a>();
+00367 <font class="keywordflow">if</font> (numBuffers == 0)
+00368 {
+00369 numBuffers = 31;
+00370 }
+00371
+00372 <font class="comment">/*</font>
+00373 <font class="comment"> _Sources = new CSourceDSound*[numBuffers];</font>
+00374 <font class="comment"></font>
+00375 <font class="comment"></font>
+00376 <font class="comment"> for (uint i = 0; i &lt; numBuffers; i++) </font>
+00377 <font class="comment"> {</font>
+00378 <font class="comment"> _Sources[i] = 0;</font>
+00379 <font class="comment"> }</font>
+00380 <font class="comment"></font>
+00381 <font class="comment"> try</font>
+00382 <font class="comment"> {</font>
+00383 <font class="comment"> for (i = 0; i &lt; numBuffers; i++) </font>
+00384 <font class="comment"> {</font>
+00385 <font class="comment"> _Sources[i] = new CSourceDSound(i);</font>
+00386 <font class="comment"> _Sources[i]-&gt;init(_DirectSound);</font>
+00387 <font class="comment"> _SourceCount++;</font>
+00388 <font class="comment"> }</font>
+00389 <font class="comment"> }</font>
+00390 <font class="comment"> catch (ESoundDriver&amp; e)</font>
+00391 <font class="comment"> {</font>
+00392 <font class="comment"> // Okay, here's the situation: I'm listening to WinAmp while debugging.</font>
+00393 <font class="comment"> // The caps told me there were 31 buffers available. In reality, there were</font>
+00394 <font class="comment"> // only 30 available because WinAmp was using one. Somehow DirectSound didn't</font>
+00395 <font class="comment"> // notice. So when creating buffer 31, an exception was thrown. </font>
+00396 <font class="comment"> // If something like this happens, don't bother and go on with the buffers we've </font>
+00397 <font class="comment"> // got. If no buffers are created at all, throw the exception again.</font>
+00398 <font class="comment"></font>
+00399 <font class="comment"> if (_Sources == 0)</font>
+00400 <font class="comment"> {</font>
+00401 <font class="comment"> throw e;</font>
+00402 <font class="comment"> }</font>
+00403 <font class="comment"> }</font>
+00404 <font class="comment"></font>
+00405 <font class="comment">*/</font>
+00406
+00407
+00408 TIMECAPS tcaps;
+00409
+00410 timeGetDevCaps(&amp;tcaps, <font class="keyword">sizeof</font>(TIMECAPS));
+00411 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o6">_TimerResolution</a> = (tcaps.wPeriodMin &gt; 10)? tcaps.wPeriodMin : 10;
+00412 timeBeginPeriod(<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o6">_TimerResolution</a>);
+00413
+00414
+00415
+00416 <font class="preprocessor">#if NLSOUND_PROFILE</font>
+00417 <font class="preprocessor"></font> <font class="keywordflow">for</font> (uint i = 0; i &lt; 1024; i++)
+00418 {
+00419 _TimerInterval[i] = 0;
+00420 }
+00421
+00422 _TimerDate = CTime::getPerformanceTime();
+00423 <font class="preprocessor">#endif</font>
+00424 <font class="preprocessor"></font>
+00425
+00426
+00427
+00428 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o5">_TimerID</a> = timeSetEvent(<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#r1">_TimerPeriod</a>, 0, &amp;CSoundDriverDSound::TimerCallback, (DWORD)<font class="keyword">this</font>, TIME_CALLBACK_FUNCTION | TIME_PERIODIC);
+00429
+00430 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o5">_TimerID</a> == NULL)
+00431 {
+00432 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to create the timer"</font>);
+00433 }
+00434
+00435
+00436
+00437
+00438 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00439 }
+00440
+00441 <font class="comment">// ******************************************************************</font>
+00442
+<a name="l00443"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a8">00443</a> uint CSoundDriverDSound::countMaxSources()
+00444 {
+00445 <font class="comment">// Try the hardware 3d buffers first</font>
+00446 uint n = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a9">countHw3DBuffers</a>();
+00447 <font class="keywordflow">if</font> (n &gt; 0)
+00448 {
+00449 <font class="keywordflow">return</font> n;
+00450 }
+00451
+00452 <font class="comment">// If not, try the hardware 2d buffers first</font>
+00453 n = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a10">countHw2DBuffers</a>();
+00454 <font class="keywordflow">if</font> (n &gt; 0)
+00455 {
+00456 <font class="keywordflow">return</font> n;
+00457 }
+00458
+00459 <font class="comment">// Okay, we'll use 32 software buffers</font>
+00460 <font class="keywordflow">return</font> 32;
+00461 }
+00462
+00463 <font class="comment">// ******************************************************************</font>
+00464
+<a name="l00465"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a13">00465</a> <font class="keywordtype">void</font> CSoundDriverDSound::writeProfile(ostream&amp; out)
+00466 {
+00467 <font class="comment">// Write the available sound devices</font>
+00468 CDeviceDescription* list = CDeviceDescription::_List;
+00469 <font class="keywordflow">while</font> (list) {
+00470 out &lt;&lt; list-&gt;_Description &lt;&lt; <font class="stringliteral">"\n"</font>;
+00471 list = list-&gt;_Next;
+00472 }
+00473
+00474 out &lt;&lt; <font class="stringliteral">"\n"</font>;
+00475
+00476 <font class="comment">// Write the buffers sizes</font>
+00477 out &lt;&lt; <font class="stringliteral">"buffer size: "</font> &lt;&lt; CSourceDSound::_SecondaryBufferSize &lt;&lt; <font class="stringliteral">"\n"</font>;
+00478 out &lt;&lt; <font class="stringliteral">"copy size: "</font> &lt;&lt; CSourceDSound::_UpdateCopySize &lt;&lt; <font class="stringliteral">"\n"</font>;
+00479 out &lt;&lt; <font class="stringliteral">"swap size: "</font> &lt;&lt; CSourceDSound::_SwapCopySize &lt;&lt; <font class="stringliteral">"\n"</font>;
+00480 out &lt;&lt; <font class="stringliteral">"\n"</font>;
+00481
+00482 <font class="comment">// Write the number of hardware buffers </font>
+00483 DSCAPS caps;
+00484 caps.dwSize = <font class="keyword">sizeof</font>(caps);
+00485 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;GetCaps(&amp;caps);
+00486
+00487 cout &lt;&lt; <font class="stringliteral">"3d hw buffers: "</font> &lt;&lt; caps.dwMaxHw3DAllBuffers &lt;&lt; <font class="stringliteral">"\n"</font>;
+00488 cout &lt;&lt; <font class="stringliteral">"2d hw buffers: "</font> &lt;&lt; caps.dwMaxHwMixingAllBuffers &lt;&lt; <font class="stringliteral">"\n"</font>;
+00489 out &lt;&lt; <font class="stringliteral">"\n"</font>;
+00490
+00491 <font class="comment">// Write the number of hardware buffers </font>
+00492 <font class="preprocessor">#if NLSOUND_PROFILE</font>
+00493 <font class="preprocessor"></font> out &lt;&lt; <font class="stringliteral">"update time total --- "</font> &lt;&lt; getAverageUpdateTime()&lt;&lt; <font class="stringliteral">"\n"</font>;
+00494 out &lt;&lt; <font class="stringliteral">"update time source --- "</font> &lt;&lt; CSourceDSound::getAverageUpdateTime() &lt;&lt; <font class="stringliteral">"\n"</font>;
+00495 out &lt;&lt; <font class="stringliteral">"update --- t: "</font> &lt;&lt; CSourceDSound::getAverageCumulTime();
+00496 out &lt;&lt; <font class="stringliteral">" - p: "</font> &lt;&lt; CSourceDSound::getAveragePosTime();
+00497 out &lt;&lt; <font class="stringliteral">" - l: "</font> &lt;&lt; CSourceDSound::getAverageLockTime();
+00498 out &lt;&lt; <font class="stringliteral">" - c: "</font> &lt;&lt; CSourceDSound::getAverageCopyTime();
+00499 out &lt;&lt; <font class="stringliteral">" - u: "</font> &lt;&lt; CSourceDSound::getAverageUnlockTime() &lt;&lt; <font class="stringliteral">"\n"</font>;
+00500 out &lt;&lt; <font class="stringliteral">"update percentage: --- "</font> &lt;&lt; getUpdatePercentage() &lt;&lt; <font class="stringliteral">"\n"</font>;
+00501 out &lt;&lt; <font class="stringliteral">"update num sources --- "</font> &lt;&lt; getAverageUpdateSources() &lt;&lt; <font class="stringliteral">"\n"</font>;
+00502 out &lt;&lt; <font class="stringliteral">"update byte size --- "</font> &lt;&lt; CSourceDSound::getAverageUpdateSize() &lt;&lt; <font class="stringliteral">"\n"</font>;
+00503 out &lt;&lt; <font class="stringliteral">"swap time --- "</font> &lt;&lt; CSourceDSound::getTestAverage() &lt;&lt; <font class="stringliteral">"\n"</font>;
+00504 out &lt;&lt; <font class="stringliteral">"src --- "</font> &lt;&lt; <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a11">countPlayingSources</a>() &lt;&lt; <font class="stringliteral">"\n"</font>;
+00505 <font class="preprocessor">#endif</font>
+00506 <font class="preprocessor"></font>}
+00507
+00508
+<a name="l00509"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#f0">00509</a> <font class="keywordtype">void</font> CALLBACK CSoundDriverDSound::TimerCallback(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
+00510 {
+00511 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a0">CSoundDriverDSound</a>* driver = (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a0">CSoundDriverDSound</a>*) dwUser;
+00512 driver-&gt;update();
+00513 }
+00514
+00515 <font class="comment">// ******************************************************************</font>
+00516
+<a name="l00517"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a12">00517</a> <font class="keywordtype">void</font> CSoundDriverDSound::update()
+00518 {
+00519 <font class="preprocessor">#if NLSOUND_PROFILE</font>
+00520 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a184">TTicks</a> now = CTime::getPerformanceTime();
+00521 <font class="preprocessor">#endif</font>
+00522 <font class="preprocessor"></font>
+00523 set&lt;CSourceDSound*&gt;::iterator iter;
+00524
+00525 iter = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.begin();
+00526
+00527 <font class="keywordflow">if</font> ((iter != <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.end()) &amp;&amp; (*iter)-&gt;needsUpdate())
+00528 {
+00529 <font class="keywordflow">while</font> (iter != <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.end())
+00530 {
+00531 <font class="keywordflow">if</font> ((*iter)-&gt;update2()) {
+00532 <font class="preprocessor">#if NLSOUND_PROFILE</font>
+00533 <font class="preprocessor"></font> _UpdateSources++;
+00534 <font class="preprocessor">#endif</font>
+00535 <font class="preprocessor"></font> }
+00536 iter++;
+00537 }
+00538 }
+00539
+00540
+00541 <font class="preprocessor">#if NLSOUND_PROFILE</font>
+00542 <font class="preprocessor"></font> _TotalUpdateTime += 1000.0 * CTime::ticksToSecond(CTime::getPerformanceTime() - now);
+00543 _UpdateCount++;
+00544 <font class="preprocessor">#endif</font>
+00545 <font class="preprocessor"></font>}
+00546
+00547 <font class="comment">// ******************************************************************</font>
+00548
+<a name="l00549"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a9">00549</a> uint CSoundDriverDSound::countHw3DBuffers()
+00550 {
+00551 DSCAPS caps;
+00552 caps.dwSize = <font class="keyword">sizeof</font>(caps);
+00553
+00554 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;GetCaps(&amp;caps) != DS_OK)
+00555 {
+00556 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to query the sound device caps"</font>);
+00557 }
+00558
+00559 <font class="keywordflow">return</font> caps.dwFreeHw3DStreamingBuffers;
+00560 }
+00561
+00562 <font class="comment">// ******************************************************************</font>
+00563
+<a name="l00564"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a10">00564</a> uint CSoundDriverDSound::countHw2DBuffers()
+00565 {
+00566 DSCAPS caps;
+00567 caps.dwSize = <font class="keyword">sizeof</font>(caps);
+00568
+00569 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;GetCaps(&amp;caps) != DS_OK)
+00570 {
+00571 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to query the sound device caps"</font>);
+00572 }
+00573
+00574 <font class="keywordflow">return</font> caps.dwFreeHwMixingStreamingBuffers;
+00575 }
+00576
+00577 <font class="comment">// ******************************************************************</font>
+00578
+<a name="l00579"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a2">00579</a> IListener *CSoundDriverDSound::createListener()
+00580 {
+00581 LPDIRECTSOUND3DLISTENER dsoundListener;
+00582
+00583 <font class="keywordflow">if</font> (CListenerDSound::instance() != NULL)
+00584 {
+00585 <font class="keywordflow">return</font> CListenerDSound::instance();
+00586 }
+00587
+00588 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> == 0)
+00589 {
+00590 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Corrupt driver"</font>);
+00591 }
+00592
+00593 <font class="keywordflow">if</font> (FAILED(<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a>-&gt;QueryInterface(IID_IDirectSound3DListener, (LPVOID *) &amp;dsoundListener)))
+00594 {
+00595 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"The 3D listener interface is not available."</font>);
+00596 <font class="keywordflow">return</font> <font class="keyword">new</font> CListenerDSound(NULL);
+00597 }
+00598
+00599 <font class="keywordflow">return</font> <font class="keyword">new</font> CListenerDSound(dsoundListener);
+00600 }
+00601
+00602 <font class="comment">// ******************************************************************</font>
+00603
+<a name="l00604"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a4">00604</a> IBuffer *CSoundDriverDSound::createBuffer()
+00605 {
+00606 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> == 0)
+00607 {
+00608 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Corrupt driver"</font>);
+00609 }
+00610
+00611
+00612 <font class="comment">// FIXME: set buffer ID</font>
+00613 <font class="keywordflow">return</font> <font class="keyword">new</font> CBufferDSound();
+00614 }
+00615
+00616 <font class="comment">// ******************************************************************</font>
+00617
+<a name="l00618"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#c2">00618</a> <font class="keywordtype">void</font> CSoundDriverDSound::removeBuffer(IBuffer *buffer)
+00619 {
+00620 }
+00621
+00622 <font class="comment">// ******************************************************************</font>
+00623
+<a name="l00624"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a5">00624</a> <font class="keywordtype">bool</font> CSoundDriverDSound::loadWavFile(IBuffer *destbuffer, <font class="keyword">const</font> <font class="keywordtype">char</font> *filename)
+00625 {
+00626 <font class="keywordflow">return</font> ((CBufferDSound*) destbuffer)-&gt;loadWavFile(filename);
+00627 }
+00628
+00629 <font class="comment">// ******************************************************************</font>
+00630
+<a name="l00631"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a6">00631</a> ISource *CSoundDriverDSound::createSource()
+00632 {
+00633 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> == 0)
+00634 {
+00635 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Corrupt driver"</font>);
+00636 }
+00637
+00638
+00639 CSourceDSound* <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> = <font class="keyword">new</font> CSourceDSound(0);
+00640 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;init(<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>);
+00641 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.insert(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>);
+00642
+00643 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>;
+00644 }
+00645
+00646
+00647 <font class="comment">// ******************************************************************</font>
+00648
+<a name="l00649"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#c3">00649</a> <font class="keywordtype">void</font> CSoundDriverDSound::removeSource(ISource *source)
+00650 {
+00651 <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.erase((CSourceDSound*) source);
+00652 }
+00653
+00654 <font class="comment">// ******************************************************************</font>
+00655
+<a name="l00656"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a7">00656</a> <font class="keywordtype">void</font> CSoundDriverDSound::commit3DChanges()
+00657 {
+00658 CListenerDSound* listener = CListenerDSound::instance();
+00659 listener-&gt;commit3DChanges();
+00660
+00661
+00662 <font class="keyword">const</font> CVector &amp;origin = listener-&gt;getPos();
+00663
+00664 set&lt;CSourceDSound*&gt;::iterator iter;
+00665
+00666 <font class="comment">// We handle the volume of the source according to the distance</font>
+00667 <font class="comment">// ourselves. Call updateVolume() to, well..., update the volume</font>
+00668 <font class="comment">// according to, euh ..., the new distance!</font>
+00669 <font class="keywordflow">for</font> (iter = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.begin(); iter != <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.end(); iter++)
+00670 {
+00671 <font class="keywordflow">if</font> ((*iter)-&gt;isPlaying())
+00672 {
+00673 (*iter)-&gt;updateVolume(origin);
+00674 }
+00675 }
+00676 }
+00677
+00678
+00679 <font class="comment">// ******************************************************************</font>
+00680
+<a name="l00681"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a11">00681</a> uint CSoundDriverDSound::countPlayingSources()
+00682 {
+00683 uint n = 0;
+00684 set&lt;CSourceDSound*&gt;::iterator iter;
+00685
+00686 <font class="keywordflow">for</font> (iter = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.begin(); iter != <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o3">_Sources</a>.end(); iter++)
+00687 {
+00688 <font class="keywordflow">if</font> ((*iter)-&gt;isPlaying())
+00689 {
+00690 n++;
+00691 }
+00692 }
+00693
+00694 <font class="keywordflow">return</font> n;
+00695 }
+00696
+00697
+00698 <font class="comment">// ******************************************************************</font>
+00699
+<a name="l00700"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a14">00700</a> <font class="keywordtype">void</font> CSoundDriverDSound::setGain( <font class="keywordtype">float</font> gain )
+00701 {
+00702 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> != 0)
+00703 {
+00704 <font class="keywordflow">if</font> (gain &lt; 0.00001f)
+00705 {
+00706 gain = 0.00001f;
+00707 }
+00708
+00709 <font class="comment">/* convert from linear amplitude to hundredths of decibels */</font>
+00710 LONG volume = (LONG)(100.0 * 20.0 * log10(gain));
+00711
+00712 <font class="keywordflow">if</font> (volume &lt; DSBVOLUME_MIN)
+00713 {
+00714 volume = DSBVOLUME_MIN;
+00715 }
+00716 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (volume &gt; DSBVOLUME_MAX)
+00717 {
+00718 volume = DSBVOLUME_MAX;
+00719 }
+00720
+00721 HRESULT hr = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a>-&gt;SetVolume(volume);
+00722
+00723 <font class="keywordflow">if</font> (hr != DS_OK)
+00724 {
+00725 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Failed to set the volume"</font>);
+00726 }
+00727 }
+00728 }
+00729
+00730 <font class="comment">// ******************************************************************</font>
+00731
+<a name="l00732"></a><a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#a15">00732</a> <font class="keywordtype">float</font> CSoundDriverDSound::getGain()
+00733 {
+00734 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a> != 0)
+00735 {
+00736 <font class="comment">/* convert from hundredths of decibels to linear amplitude */</font>
+00737 LONG volume;
+00738 HRESULT hr = <a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o1">_PrimaryBuffer</a>-&gt;GetVolume(&amp;volume);
+00739
+00740 <font class="keywordflow">if</font> (hr != DS_OK)
+00741 {
+00742 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Failed to get the volume"</font>);
+00743 <font class="keywordflow">return</font> 1.0;
+00744 }
+00745
+00746 <font class="keywordflow">return</font> (float) pow(10, (<font class="keywordtype">double</font>) volume / 20.0 / 100.0);
+00747 }
+00748
+00749 <font class="keywordflow">return</font> 1.0;
+00750 }
+00751
+00752
+00753
+00754 <font class="preprocessor">#if NLSOUND_PROFILE</font>
+00755 <font class="preprocessor"></font>
+00756 <font class="comment">// ******************************************************************</font>
+00757
+00758 uint CSoundDriverDSound::countTimerIntervals()
+00759 {
+00760 <font class="keywordflow">return</font> 1024;
+00761 }
+00762
+00763 <font class="comment">// ******************************************************************</font>
+00764
+00765 uint CSoundDriverDSound::getTimerIntervals(uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
+00766 {
+00767 <font class="keywordflow">return</font> _TimerInterval[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>];
+00768 }
+00769
+00770 <font class="comment">// ******************************************************************</font>
+00771
+00772 <font class="keywordtype">void</font> CSoundDriverDSound::addTimerInterval(uint32 dt)
+00773 {
+00774 <font class="keywordflow">if</font> (_TimerIntervalCount &gt;= 1024)
+00775 {
+00776 _TimerIntervalCount = 0;
+00777 }
+00778
+00779 _TimerInterval[_TimerIntervalCount++] = dt;
+00780 }
+00781
+00782 <font class="comment">// ******************************************************************</font>
+00783
+00784 <font class="keywordtype">double</font> CSoundDriverDSound::getCPULoad()
+00785 {
+00786 <font class="keywordflow">return</font> (_TotalTime &gt; 0.0)? 100.0 * _TotalUpdateTime / _TotalTime : 0.0;
+00787 }
+00788
+00789 <font class="comment">// ******************************************************************</font>
+00790
+00791 <font class="keywordtype">void</font> CSoundDriverDSound::printDriverInfo(FILE* fp)
+00792 {
+00793 CDeviceDescription* list = CDeviceDescription::_List;
+00794
+00795 <font class="keywordflow">while</font> (list) {
+00796 fprintf(fp, <font class="stringliteral">"%s\n"</font>, list-&gt;_Description);
+00797 list = list-&gt;_Next;
+00798 }
+00799
+00800 fprintf(fp, <font class="stringliteral">"\n"</font>);
+00801
+00802 fprintf(fp, <font class="stringliteral">"buffer size: %d\n"</font>
+00803 <font class="stringliteral">"copy size: %d\n"</font>
+00804 <font class="stringliteral">"swap size: %d\n"</font>,
+00805 CSourceDSound::_SecondaryBufferSize,
+00806 CSourceDSound::_UpdateCopySize,
+00807 CSourceDSound::_SwapCopySize);
+00808
+00809 fprintf(fp, <font class="stringliteral">"\n"</font>);
+00810
+00811 DSCAPS caps;
+00812 caps.dwSize = <font class="keyword">sizeof</font>(caps);
+00813
+00814 <font class="keywordflow">if</font> (<a class="code" href="classNLSOUND_1_1CSoundDriverDSound.html#o0">_DirectSound</a>-&gt;GetCaps(&amp;caps) != DS_OK)
+00815 {
+00816 <font class="keywordflow">throw</font> ESoundDriver(<font class="stringliteral">"Failed to query the sound device caps"</font>);
+00817 }
+00818
+00819
+00820 fprintf(fp, <font class="stringliteral">"3d hw buffers: %d\n"</font> <font class="stringliteral">"2d hw buffers: %d\n\n"</font>, caps.dwMaxHw3DAllBuffers, caps.dwMaxHwMixingAllBuffers);
+00821 }
+00822
+00823 <font class="preprocessor">#endif</font>
+00824 <font class="preprocessor"></font>
+00825
+00826 } <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>