From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/sound__driver_8cpp-source.html | 206 ++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 docs/doxygen/nel/sound__driver_8cpp-source.html (limited to 'docs/doxygen/nel/sound__driver_8cpp-source.html') diff --git a/docs/doxygen/nel/sound__driver_8cpp-source.html b/docs/doxygen/nel/sound__driver_8cpp-source.html new file mode 100644 index 00000000..9e1d5b1d --- /dev/null +++ b/docs/doxygen/nel/sound__driver_8cpp-source.html @@ -0,0 +1,206 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

sound_driver.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "sound/driver/sound_driver.h"
+00027 #include "nel/misc/debug.h"
+00028 
+00029 
+00030 #ifdef NL_OS_WINDOWS
+00031 
+00032 #include <windows.h>
+00033 
+00034 #else // NL_OS_WINDOWS
+00035 
+00036 #include <dlfcn.h>
+00037 
+00038 #endif // NL_OS_WINDOWS
+00039 
+00040 
+00041 namespace NLSOUND
+00042 {
+00043 
+00044 
+00045 // Interface version
+00046 const uint32 ISoundDriver::InterfaceVersion = 0x04;
+00047 
+00048 typedef ISoundDriver* (*ISDRV_CREATE_PROC)(void); 
+00049 const char *IDRV_CREATE_PROC_NAME = "NLSOUND_createISoundDriverInstance";
+00050 
+00051 typedef uint32 (*ISDRV_VERSION_PROC)(void); 
+00052 const char *IDRV_VERSION_PROC_NAME = "NLSOUND_interfaceVersion";
+00053 
+00054 
+00055 
+00056 /*
+00057  * The static method which builds the sound driver instance
+00058  */
+00059 ISoundDriver    *ISoundDriver::createDriver()
+00060 {
+00061         ISDRV_CREATE_PROC       createSoundDriver = NULL;
+00062         ISDRV_VERSION_PROC      versionDriver = NULL;
+00063 
+00064 #ifdef NL_OS_WINDOWS
+00065 
+00066         // WINDOWS code.
+00067         HINSTANCE                       hInst;
+00068 
+00069         hInst = LoadLibrary(NLSOUND_DLL_NAME);
+00070 
+00071         if (!hInst)
+00072         {
+00073                 throw ESoundDriverNotFound();
+00074         }
+00075 
+00076         char buffer[1024], *ptr;
+00077         SearchPath (NULL, NLSOUND_DLL_NAME, NULL, 1023, buffer, &ptr);
+00078         nlinfo ("Using the library '"NLSOUND_DLL_NAME"' that is in the directory: '%s'", buffer);
+00079 
+00080         createSoundDriver = (ISDRV_CREATE_PROC) GetProcAddress (hInst, IDRV_CREATE_PROC_NAME);
+00081         if (createSoundDriver == NULL)
+00082         {
+00083                 nlinfo( "Error: %u", GetLastError() );
+00084                 throw ESoundDriverCorrupted();
+00085         }
+00086 
+00087         versionDriver = (ISDRV_VERSION_PROC) GetProcAddress (hInst, IDRV_VERSION_PROC_NAME);
+00088         if (versionDriver != NULL)
+00089         {
+00090                 if (versionDriver()<ISoundDriver::InterfaceVersion)
+00091                         throw ESoundDriverOldVersion();
+00092                 else if (versionDriver()>ISoundDriver::InterfaceVersion)
+00093                         throw ESoundDriverUnknownVersion();
+00094         }
+00095 
+00096 #elif defined (NL_OS_UNIX)
+00097 
+00098         // Unix code
+00099         void *handle = dlopen(NLSOUND_DLL_NAME, RTLD_NOW);
+00100 
+00101         if (handle == NULL)
+00102         {
+00103                 nlwarning ("when loading dynamic library '%s': %s", NLSOUND_DLL_NAME, dlerror());
+00104                 throw ESoundDriverNotFound();
+00105         }
+00106 
+00107         /* Not ANSI. Might produce a warning */
+00108         createSoundDriver = (ISDRV_CREATE_PROC) dlsym (handle, IDRV_CREATE_PROC_NAME);
+00109         if (createSoundDriver == NULL)
+00110         {
+00111                 nlwarning ("when getting function in dynamic library '%s': %s", NLSOUND_DLL_NAME, dlerror());
+00112                 throw ESoundDriverCorrupted();
+00113         }
+00114 
+00115         versionDriver = (ISDRV_VERSION_PROC) dlsym (handle, IDRV_VERSION_PROC_NAME);
+00116         if (versionDriver != NULL)
+00117         {
+00118                 if (versionDriver()<ISoundDriver::InterfaceVersion)
+00119                         throw ESoundDriverOldVersion();
+00120                 else if (versionDriver()>ISoundDriver::InterfaceVersion)
+00121                         throw ESoundDriverUnknownVersion();
+00122         }
+00123 
+00124 #else // NL_OS_LINUX
+00125 #error "Dynamic DLL loading not implemented!"
+00126 #endif // NL_OS_LINUX
+00127 
+00128         ISoundDriver *ret = createSoundDriver();
+00129         if ( ret == NULL )
+00130         {
+00131                 throw ESoundDriverCantCreateDriver();
+00132         }
+00133         return ret;
+00134 }
+00135 
+00136 
+00137 } // NLSOUND
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1