# 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.h

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 #ifndef NL_SOUND_DRIVER_H
00027 #define NL_SOUND_DRIVER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/common.h"
00031 
00033 namespace NLSOUND {
00034 
00035 
00036 class IBuffer;
00037 class IListener;
00038 class ISource;
00039 
00040 
00041 #ifdef NL_OS_WINDOWS
00042 
00043 #if _MSC_VER >= 1300    // visual .NET, use different dll name
00044 // must test it first, because NL_DEBUG_FAST and NL_DEBUG are declared at same time.
00045 #ifdef NL_DEBUG_FAST
00046 #define NLSOUND_DLL_NAME "nldriver_openal_df.dll"
00047 #elif defined (NL_DEBUG)
00048 #define NLSOUND_DLL_NAME "nldriver_openal_d.dll"
00049 #elif defined (NL_RELEASE_DEBUG)
00050 #define NLSOUND_DLL_NAME "nldriver_openal_rd.dll"
00051 #elif defined (NL_RELEASE)
00052 #define NLSOUND_DLL_NAME "nldriver_openal_r.dll"
00053 #else
00054 #error "Unknown dll name"
00055 #endif
00056 
00057 #else
00058 
00059 // must test it first, because NL_DEBUG_FAST and NL_DEBUG are declared at same time.
00060 #ifdef NL_DEBUG_FAST
00061 #define NLSOUND_DLL_NAME "nel_drv_dsound_win_df.dll"
00062 #elif defined (NL_DEBUG)
00063 #define NLSOUND_DLL_NAME "nel_drv_dsound_win_d.dll"
00064 #elif defined (NL_RELEASE_DEBUG)
00065 #define NLSOUND_DLL_NAME "nel_drv_dsound_win_rd.dll"
00066 #elif defined (NL_RELEASE)
00067 #define NLSOUND_DLL_NAME "nel_drv_dsound_win_r.dll"
00068 #else
00069 #error "Unknown dll name"
00070 #endif
00071 
00072 #endif 
00073 
00074 #elif defined (NL_OS_UNIX)
00075 #define NLSOUND_DLL_NAME "libnel_drv_openal.so"
00076 #else
00077 #error "Unknown system"
00078 #endif
00079 
00080 
00081 
00095 class ISoundDriver
00096 {
00097 public:
00098 
00100         static const uint32             InterfaceVersion;
00101 
00106         static  ISoundDriver    *createDriver();
00107 
00109         virtual IBuffer                 *createBuffer() = 0;
00110 
00112         virtual IListener               *createListener() = 0;
00113 
00115         virtual uint                    countMaxSources() = 0;
00116 
00118         virtual ISource                 *createSource() = 0;
00119 
00121         virtual bool                    loadWavFile( IBuffer *destbuffer, const char *filename ) = 0;
00122 
00123 
00125         virtual void                    commit3DChanges() = 0;
00126 
00128         virtual void                    writeProfile(std::ostream& out) = 0;
00129 
00130         // Does not create a sound loader
00131 
00133         virtual ~ISoundDriver() {}
00134 
00135 protected:
00136 
00138         ISoundDriver() {}
00139 
00141         virtual void                    removeBuffer( IBuffer *buffer ) = 0;
00142 
00144         virtual void                    removeSource( ISource *source ) = 0;
00145 };
00146 
00147 
00151 class ESoundDriver : public NLMISC::Exception
00152 {
00153 public:
00154         ESoundDriver() : NLMISC::Exception( "Sound driver error" ) {}
00155         ESoundDriver( const char *reason ) : NLMISC::Exception( reason ) {}
00156 };
00157 
00158 
00162 class ESoundDriverNotFound : public ESoundDriver
00163 {
00164 public:
00165         ESoundDriverNotFound() : ESoundDriver( NLSOUND_DLL_NAME " or third-party library not found" ) {}
00166 };
00167 
00168 
00172 class ESoundDriverCorrupted : public ESoundDriver
00173 {
00174 public:
00175         ESoundDriverCorrupted() : ESoundDriver( "Can't get NLSOUND_createISoundDriverInstance from " NLSOUND_DLL_NAME " (Bad dll?)" ) {}
00176 };
00177 
00178 
00182 class ESoundDriverOldVersion : public ESoundDriver
00183 {
00184 public:
00185         ESoundDriverOldVersion() : ESoundDriver( NLSOUND_DLL_NAME " is a too old version. Ask for a more recent file" ) {}
00186 };
00187 
00188 
00192 class ESoundDriverUnknownVersion : public ESoundDriver
00193 {
00194 public:
00195         ESoundDriverUnknownVersion() : ESoundDriver( NLSOUND_DLL_NAME " is more recent than the application" ) {}
00196 };
00197 
00198 
00202 class ESoundDriverCantCreateDriver : public ESoundDriver
00203 {
00204 public:
00205         ESoundDriverCantCreateDriver() : ESoundDriver( NLSOUND_DLL_NAME " can't create driver" ) {}
00206 };
00207 
00208   
00212 class ESoundDriverGenBuf : public ESoundDriver
00213 {
00214 public:
00215         ESoundDriverGenBuf() : ESoundDriver( "Unable to generate sound buffers" ) {}
00216 };
00217 
00218 
00222 class ESoundDriverGenSrc : public ESoundDriver
00223 {
00224 public:
00225         ESoundDriverGenSrc() : ESoundDriver( "Unable to generate sound sources" ) {}
00226 };
00227 
00228   
00232 class ESoundDriverNotSupp : public ESoundDriver
00233 {
00234 public:
00235         ESoundDriverNotSupp() : ESoundDriver( "Operation not supported by sound driver" ) {}
00236 };
00237 
00238 
00239 } // NLSOUND
00240 
00241 
00242 #endif // NL_SOUND_DRIVER_H
00243 
00244 /* End of sound_driver.h */