diff --git a/Headers/cAudioCapture.h b/Headers/cAudioCapture.h index 5185fde..5cd5576 100644 --- a/Headers/cAudioCapture.h +++ b/Headers/cAudioCapture.h @@ -6,12 +6,9 @@ #define CAUDIOCAPTURE_H #include "../include/IAudioCapture.h" -#include #include #include #include "../Headers/cMutex.h" -#include -#include #include "../Headers/cMemoryOverride.h" #include "../Headers/cSTLAllocator.h" @@ -79,16 +76,16 @@ namespace cAudio unsigned int InternalBufferSize; int SampleSize; - std::vector > CaptureBuffer; - std::vector > AvailableDevices; - std::string DefaultDevice; - std::list > eventHandlerList; + cAudioVector::Type CaptureBuffer; + cAudioVector::Type AvailableDevices; + cAudioString DefaultDevice; + cAudioList::Type eventHandlerList; bool Supported; bool Ready; bool Capturing; - std::string DeviceName; + cAudioString DeviceName; ALCdevice* CaptureDevice; bool checkError(); diff --git a/Headers/cAudioEffects.h b/Headers/cAudioEffects.h index f611685..225ee68 100644 --- a/Headers/cAudioEffects.h +++ b/Headers/cAudioEffects.h @@ -8,7 +8,6 @@ #include "../include/IAudioEffects.h" #include "../Headers/cMutex.h" #include "../Headers/cEFXFunctions.h" -#include #include "../Headers/cSTLAllocator.h" #ifdef CAUDIO_EFX_ENABLED @@ -70,19 +69,19 @@ namespace cAudio bool SupportedEffects[EET_COUNT]; bool SupportedFilters[EFT_COUNT]; - std::map, cSTLAllocator> > EAXReverbPresets; - std::map, cSTLAllocator> > ReverbPresets; - std::map, cSTLAllocator> > ChorusPresets; - std::map, cSTLAllocator> > DistortionPresets; - std::map, cSTLAllocator> > EchoPresets; - std::map, cSTLAllocator> > FlangerPresets; - std::map, cSTLAllocator> > FrequencyShiftPresets; - std::map, cSTLAllocator> > VocalMorpherPresets; - std::map, cSTLAllocator> > PitchShifterPresets; - std::map, cSTLAllocator> > RingModulatorPresets; - std::map, cSTLAllocator> > AutowahPresets; - std::map, cSTLAllocator> > CompressorPresets; - std::map, cSTLAllocator> > EqualizerPresets; + cAudioMap::Type EAXReverbPresets; + cAudioMap::Type ReverbPresets; + cAudioMap::Type ChorusPresets; + cAudioMap::Type DistortionPresets; + cAudioMap::Type EchoPresets; + cAudioMap::Type FlangerPresets; + cAudioMap::Type FrequencyShiftPresets; + cAudioMap::Type VocalMorpherPresets; + cAudioMap::Type PitchShifterPresets; + cAudioMap::Type RingModulatorPresets; + cAudioMap::Type AutowahPresets; + cAudioMap::Type CompressorPresets; + cAudioMap::Type EqualizerPresets; }; }; diff --git a/Headers/cAudioManager.h b/Headers/cAudioManager.h index cbeccf3..e902b5b 100644 --- a/Headers/cAudioManager.h +++ b/Headers/cAudioManager.h @@ -5,10 +5,6 @@ #ifndef CAUDIOMANAGER_H_INCLUDED #define CAUDIOMANAGER_H_INCLUDED -#include -#include -#include - #include "cAudioSource.h" #include "../include/IAudioDecoderFactory.h" #include "cListener.h" @@ -100,17 +96,17 @@ namespace cAudio bool Initialized; //! Holds an index for fast searching of audio sources by name - std::map, cSTLAllocator > > audioIndex; - typedef std::map, cSTLAllocator > >::iterator audioIndexIterator; + cAudioMap::Type audioIndex; + typedef cAudioMap::Type::iterator audioIndexIterator; //! Holds all managed audio sources - std::vector > audioSources; + cAudioVector::Type audioSources; //! Decoder map that holds all decoders by file extension - std::map, cSTLAllocator > > decodermap; - typedef std::map, cSTLAllocator > >::iterator decodermapIterator; + cAudioMap::Type decodermap; + typedef cAudioMap::Type::iterator decodermapIterator; //! Archive map that holds all datasource types - std::map, cSTLAllocator > > datasourcemap; - typedef std::map, cSTLAllocator > >::iterator datasourcemapIterator; - std::vector< std::pair, cSTLAllocator > > dataSourcePriorityList; + cAudioMap::Type datasourcemap; + typedef cAudioMap::Type::iterator datasourcemapIterator; + cAudioVector< std::pair >::Type dataSourcePriorityList; //! The listener object cListener initlistener; @@ -121,14 +117,14 @@ namespace cAudio //! Check for OpenAL errors bool checkError(); - std::vector > AvailableDevices; - std::string DefaultDevice; + cAudioVector::Type AvailableDevices; + cAudioString DefaultDevice; //! Signals a event to all event handlers void signalEvent(Events sevent); //! List of all attached event handlers - std::list > eventHandlerList; + cAudioList::Type eventHandlerList; }; } diff --git a/Headers/cAudioSource.h b/Headers/cAudioSource.h index 7def74c..7a92946 100644 --- a/Headers/cAudioSource.h +++ b/Headers/cAudioSource.h @@ -156,7 +156,7 @@ namespace cAudio bool Valid; //! List of registered event handlers - std::list > eventHandlerList; + cAudioList::Type eventHandlerList; #ifdef CAUDIO_EFX_ENABLED //! Holds pointers to all the EFX related functions diff --git a/Headers/cLogger.h b/Headers/cLogger.h index 5054a4f..b04d2d3 100644 --- a/Headers/cLogger.h +++ b/Headers/cLogger.h @@ -5,8 +5,6 @@ #ifndef CLOGGER_H_INCLUDED #define CLOGGER_H_INCLUDED -#include -#include #include #include "../include/ILogger.h" @@ -42,8 +40,8 @@ namespace cAudio unsigned long StartTime; char TempTextBuf[2048]; LogLevel MinLogLevel; - std::map, cSTLAllocator > > Receivers; - typedef std::map, cSTLAllocator > >::iterator ReceiversIterator; + cAudioMap::Type Receivers; + typedef cAudioMap::Type::iterator ReceiversIterator; private: }; }; diff --git a/Headers/cMemoryOverride.h b/Headers/cMemoryOverride.h index ae67bb4..8ee22e4 100644 --- a/Headers/cMemoryOverride.h +++ b/Headers/cMemoryOverride.h @@ -4,18 +4,6 @@ #include #include "../include/cAudioMemory.h" -#ifdef CAUDIO_DEBUG - #define CAUDIO_NEW new (__FILE__, __LINE__, __FUNCTION__) - #define CAUDIO_DELETE delete - #define CAUDIO_MALLOC(size) cAudio::getMemoryProvider()->Allocate(size, __FILE__, __LINE__, __FUNCTION__) - #define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer) -#else - #define CAUDIO_NEW new - #define CAUDIO_DELETE delete - #define CAUDIO_MALLOC(size) cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL) - #define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer) -#endif - namespace cAudio { class cMemoryOverride diff --git a/Headers/cPluginManager.h b/Headers/cPluginManager.h index 5e43823..9a36e26 100644 --- a/Headers/cPluginManager.h +++ b/Headers/cPluginManager.h @@ -1,10 +1,6 @@ #ifndef CPLUGINMANAGER_H_INCLUDED #define CPLUGINMANAGER_H_INCLUDED -#include -#include -#include - #include "../include/IPluginManager.h" #include "../include/IAudioPlugin.h" #include "../Headers/cMutex.h" @@ -65,7 +61,7 @@ namespace cAudio virtual bool checkForPlugin(const char* name); virtual IAudioPlugin* getPlugin(const char* name); virtual unsigned int getPluginCount(); - std::vector getPluginList(); + cAudioVector::Type getPluginList(); virtual void uninstallPlugin(IAudioPlugin* plugin); virtual void uninstallPlugin(const char* name); @@ -74,11 +70,11 @@ namespace cAudio void autoLoadPlugins(); #endif protected: - std::map, cSTLAllocator > > RegisteredPlugins; - typedef std::map, cSTLAllocator > >::iterator RegisteredPluginsIterator; + cAudioMap::Type RegisteredPlugins; + typedef cAudioMap::Type::iterator RegisteredPluginsIterator; #ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT - std::map, cSTLAllocator > > DynamicallyLoadedPlugins; - typedef std::map, cSTLAllocator > >::iterator DynamicallyLoadedPluginsIterator; + cAudioMap::Type DynamicallyLoadedPlugins; + typedef cAudioMap::Type::iterator DynamicallyLoadedPluginsIterator; #endif }; }; diff --git a/Headers/cSTLAllocator.h b/Headers/cSTLAllocator.h index 02a8dcd..95f6c8b 100644 --- a/Headers/cSTLAllocator.h +++ b/Headers/cSTLAllocator.h @@ -2,33 +2,27 @@ #define CSTLALLOCATOR_H_INCLUDED #include "../include/cAudioDefines.h" -#include "../Headers/cMemoryOverride.h" +#include "../include/cAudioMemory.h" + +#include +#include +#include +#include +#include namespace cAudio { - template - struct cSTLAllocatorBase - { // base class for generic allocators - typedef T value_type; - }; - - template - struct cSTLAllocatorBase - { // base class for generic allocators for const T - typedef T value_type; - }; - - template class cSTLAllocator : public cSTLAllocatorBase +#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS + template class cSTLAllocator { public: - typedef cSTLAllocatorBase Base; - typedef typename Base::value_type value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; template struct rebind @@ -59,7 +53,7 @@ namespace cAudio return &x; } - inline pointer allocate( size_type count, typename std::allocator::const_pointer ptr = 0 ) + pointer allocate( size_type count, typename std::allocator::const_pointer ptr = 0 ) { (void)ptr; register size_type size = count*sizeof( T ); @@ -67,7 +61,7 @@ namespace cAudio return p; } - inline void deallocate( pointer p, size_type size ) + void deallocate( pointer p, size_type size ) { CAUDIO_FREE(p); } @@ -116,6 +110,21 @@ namespace cAudio { return false; } +#endif + +#ifdef CAUDIO_REROUTE_STL_ALLOCATIONS + typedef std::basic_string< char, std::char_traits, cSTLAllocator > cAudioString; + template struct cAudioMap { typedef std::map< T1, T2, std::less< T1 >, cSTLAllocator< std::pair< T1, T2 > > > Type; }; + template struct cAudioSet { typedef std::set< T, std::less< T >, cSTLAllocator< T > > Type; }; + template struct cAudioList { typedef std::list< T, cSTLAllocator< T > > Type; }; + template struct cAudioVector { typedef std::vector< T, cSTLAllocator< T > > Type; }; +#else + typedef std::string cAudioString; + template struct cAudioMap { typedef std::map< T1, T2> Type; }; + template struct cAudioSet { typedef std::set< T > Type; }; + template struct cAudioList { typedef std::list< T > Type; }; + template struct cAudioVector { typedef std::vector< T > Type; }; +#endif }; diff --git a/Headers/cUtils.h b/Headers/cUtils.h index 1b9f4ea..37acf94 100644 --- a/Headers/cUtils.h +++ b/Headers/cUtils.h @@ -5,8 +5,7 @@ #ifndef CUTILS_H_INCLUDED #define CUTILS_H_INCLUDED #include "../include/cAudioPlatform.h" -#include -#include +#include "../Headers/cSTLAllocator.h" #ifdef CAUDIO_PLATFORM_WIN # define WIN32_LEAN_AND_MEAN @@ -21,26 +20,29 @@ # include #endif -//! Grabs the current extention of a given string. -static std::string getExt(const std::string& filename) +namespace cAudio { - if(filename.find_last_of(".") == std::string::npos) return filename; + +//! Grabs the current extention of a given string. +static cAudioString getExt(const cAudioString& filename) +{ + if(filename.find_last_of(".") == cAudioString::npos) return filename; return filename.substr(filename.find_last_of(".") + 1, filename.length()-filename.find_last_of(".")-1); } -//! Prevents a bug with NULL passed into std::string. -static std::string safeCStr(const char* str) +//! Prevents a bug with NULL passed into cAudioString. +static cAudioString safeCStr(const char* str) { - if( str != NULL ) return std::string(str); - else return std::string(""); + if( str != NULL ) return cAudioString(str); + else return cAudioString(""); } //! Returns a list of files/directories in the supplied directory. Used internally for auto-installation of plugins. -static std::vector getFilesInDirectory(std::string path) +static cAudioVector::Type getFilesInDirectory(cAudioString path) { - std::vector FileList; + cAudioVector::Type FileList; #ifdef CAUDIO_PLATFORM_WIN - std::string search = path + "\\" + std::string("*.*"); + cAudioString search = path + "\\" + cAudioString("*.*"); WIN32_FIND_DATA info; HANDLE h = FindFirstFile(search.c_str(), &info); if (h != INVALID_HANDLE_VALUE) @@ -76,4 +78,6 @@ static std::vector getFilesInDirectory(std::string path) return FileList; } +}; + #endif //! CUTILS_H_INCLUDED diff --git a/Source/cAudioCapture.cpp b/Source/cAudioCapture.cpp index 28dbb41..13268e2 100644 --- a/Source/cAudioCapture.cpp +++ b/Source/cAudioCapture.cpp @@ -10,7 +10,6 @@ #include "../Headers/cPluginManager.h" #include -#include namespace cAudio { @@ -19,14 +18,14 @@ namespace cAudio //Note: OpenAL is threadsafe, so a mutex only needs to protect the class state #ifdef CAUDIO_USE_INTERNAL_THREAD static cAudioMutex AudioCaptureObjectsMutex; - static std::set, cSTLAllocator > AudioCaptureObjects; + static cAudioSet::Type AudioCaptureObjects; CAUDIO_DECLARE_THREAD_FUNCTION(AudioCaptureUpdateThread) { while(RunAudioCaptureThread) { AudioCaptureObjectsMutex.lock(); - std::set, cSTLAllocator >::iterator it; + cAudioSet::Type::iterator it; for ( it=AudioCaptureObjects.begin() ; it != AudioCaptureObjects.end(); it++ ) { (*it)->updateCaptureBuffer(); @@ -122,7 +121,7 @@ namespace cAudio { while(*deviceList) { - std::string device(deviceList); + cAudioString device(deviceList); AvailableDevices.push_back(device); deviceList += strlen(deviceList) + 1; } @@ -347,7 +346,7 @@ namespace cAudio capture->initialize(); #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT - std::vector plugins = cPluginManager::Instance()->getPluginList(); + cAudioVector::Type plugins = cPluginManager::Instance()->getPluginList(); for(unsigned int i = 0; i < plugins.size(); ++i) { plugins[i]->onCreateAudioCapture(capture); @@ -382,7 +381,7 @@ namespace cAudio #endif #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT - std::vector plugins = cPluginManager::Instance()->getPluginList(); + cAudioVector::Type plugins = cPluginManager::Instance()->getPluginList(); for(unsigned int i = 0; i < plugins.size(); ++i) { plugins[i]->onDestoryAudioCapture(capture); @@ -424,7 +423,7 @@ namespace cAudio void cAudioCapture::signalEvent(Events sevent) { cAudioMutexBasicLock lock(Mutex); - std::list >::iterator it = eventHandlerList.begin(); + cAudioList::Type::iterator it = eventHandlerList.begin(); if(it != eventHandlerList.end()){ diff --git a/Source/cAudioEffects.cpp b/Source/cAudioEffects.cpp index 45e6ee3..fbd39b8 100644 --- a/Source/cAudioEffects.cpp +++ b/Source/cAudioEffects.cpp @@ -69,7 +69,7 @@ bool cAudioEffects::isFilterSupported(const FilterTypes& type) const bool cAudioEffects::addEAXReverbEffectPreset(const char* name, const sEAXReverbParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); EAXReverbPresets[safeName] = setting; return true; } @@ -77,7 +77,7 @@ bool cAudioEffects::addEAXReverbEffectPreset(const char* name, const sEAXReverbP bool cAudioEffects::addReverbEffectPreset(const char* name, const sReverbParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); ReverbPresets[safeName] = setting; return true; } @@ -85,7 +85,7 @@ bool cAudioEffects::addReverbEffectPreset(const char* name, const sReverbParamet bool cAudioEffects::addChorusEffectPreset(const char* name, const sChorusParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); ChorusPresets[safeName] = setting; return true; } @@ -93,7 +93,7 @@ bool cAudioEffects::addChorusEffectPreset(const char* name, const sChorusParamet bool cAudioEffects::addDistortionEffectPreset(const char* name, const sDistortionParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); DistortionPresets[safeName] = setting; return true; } @@ -101,7 +101,7 @@ bool cAudioEffects::addDistortionEffectPreset(const char* name, const sDistortio bool cAudioEffects::addEchoEffectPreset(const char* name, const sEchoParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); EchoPresets[safeName] = setting; return true; } @@ -109,7 +109,7 @@ bool cAudioEffects::addEchoEffectPreset(const char* name, const sEchoParameters& bool cAudioEffects::addFlangerEffectPreset(const char* name, const sFlangerParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); FlangerPresets[safeName] = setting; return true; } @@ -117,7 +117,7 @@ bool cAudioEffects::addFlangerEffectPreset(const char* name, const sFlangerParam bool cAudioEffects::addFrequencyShiftEffectPreset(const char* name, const sFrequencyShiftParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); FrequencyShiftPresets[safeName] = setting; return true; } @@ -125,7 +125,7 @@ bool cAudioEffects::addFrequencyShiftEffectPreset(const char* name, const sFrequ bool cAudioEffects::addVocalMorpherEffectPreset(const char* name, const sVocalMorpherParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); VocalMorpherPresets[safeName] = setting; return true; } @@ -133,7 +133,7 @@ bool cAudioEffects::addVocalMorpherEffectPreset(const char* name, const sVocalMo bool cAudioEffects::addPitchShifterEffectPreset(const char* name, const sPitchShifterParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); PitchShifterPresets[safeName] = setting; return true; } @@ -141,7 +141,7 @@ bool cAudioEffects::addPitchShifterEffectPreset(const char* name, const sPitchSh bool cAudioEffects::addRingModulatorEffectPreset(const char* name, const sRingModulatorParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); RingModulatorPresets[safeName] = setting; return true; } @@ -149,7 +149,7 @@ bool cAudioEffects::addRingModulatorEffectPreset(const char* name, const sRingMo bool cAudioEffects::addAutowahEffectPreset(const char* name, const sAutowahParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); AutowahPresets[safeName] = setting; return true; } @@ -157,7 +157,7 @@ bool cAudioEffects::addAutowahEffectPreset(const char* name, const sAutowahParam bool cAudioEffects::addCompressorEffectPreset(const char* name, const sCompressorParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); CompressorPresets[safeName] = setting; return true; } @@ -165,7 +165,7 @@ bool cAudioEffects::addCompressorEffectPreset(const char* name, const sCompresso bool cAudioEffects::addEqualizerEffectPreset(const char* name, const sEqualizerParameters& setting) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); EqualizerPresets[safeName] = setting; return true; } @@ -173,8 +173,8 @@ bool cAudioEffects::addEqualizerEffectPreset(const char* name, const sEqualizerP sEAXReverbParameters cAudioEffects::getEAXReverbEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = EAXReverbPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = EAXReverbPresets.find(safeName); if(it != EAXReverbPresets.end()) { return it->second; @@ -185,8 +185,8 @@ sEAXReverbParameters cAudioEffects::getEAXReverbEffectPreset(const char* name) sReverbParameters cAudioEffects::getReverbEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = ReverbPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = ReverbPresets.find(safeName); if(it != ReverbPresets.end()) { return it->second; @@ -197,8 +197,8 @@ sReverbParameters cAudioEffects::getReverbEffectPreset(const char* name) sChorusParameters cAudioEffects::getChorusEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = ChorusPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = ChorusPresets.find(safeName); if(it != ChorusPresets.end()) { return it->second; @@ -209,8 +209,8 @@ sChorusParameters cAudioEffects::getChorusEffectPreset(const char* name) sDistortionParameters cAudioEffects::getDistortionEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = DistortionPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = DistortionPresets.find(safeName); if(it != DistortionPresets.end()) { return it->second; @@ -221,8 +221,8 @@ sDistortionParameters cAudioEffects::getDistortionEffectPreset(const char* name) sEchoParameters cAudioEffects::getEchoEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = EchoPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = EchoPresets.find(safeName); if(it != EchoPresets.end()) { return it->second; @@ -233,8 +233,8 @@ sEchoParameters cAudioEffects::getEchoEffectPreset(const char* name) sFlangerParameters cAudioEffects::getFlangerEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = FlangerPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = FlangerPresets.find(safeName); if(it != FlangerPresets.end()) { return it->second; @@ -245,8 +245,8 @@ sFlangerParameters cAudioEffects::getFlangerEffectPreset(const char* name) sFrequencyShiftParameters cAudioEffects::getFrequencyShiftEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = FrequencyShiftPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = FrequencyShiftPresets.find(safeName); if(it != FrequencyShiftPresets.end()) { return it->second; @@ -257,8 +257,8 @@ sFrequencyShiftParameters cAudioEffects::getFrequencyShiftEffectPreset(const cha sVocalMorpherParameters cAudioEffects::getVocalMorpherEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = VocalMorpherPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = VocalMorpherPresets.find(safeName); if(it != VocalMorpherPresets.end()) { return it->second; @@ -269,8 +269,8 @@ sVocalMorpherParameters cAudioEffects::getVocalMorpherEffectPreset(const char* n sPitchShifterParameters cAudioEffects::getPitchShifterEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = PitchShifterPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = PitchShifterPresets.find(safeName); if(it != PitchShifterPresets.end()) { return it->second; @@ -281,8 +281,8 @@ sPitchShifterParameters cAudioEffects::getPitchShifterEffectPreset(const char* n sRingModulatorParameters cAudioEffects::getRingModulatorEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = RingModulatorPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = RingModulatorPresets.find(safeName); if(it != RingModulatorPresets.end()) { return it->second; @@ -293,8 +293,8 @@ sRingModulatorParameters cAudioEffects::getRingModulatorEffectPreset(const char* sAutowahParameters cAudioEffects::getAutowahEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = AutowahPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = AutowahPresets.find(safeName); if(it != AutowahPresets.end()) { return it->second; @@ -305,8 +305,8 @@ sAutowahParameters cAudioEffects::getAutowahEffectPreset(const char* name) sCompressorParameters cAudioEffects::getCompressorEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = CompressorPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = CompressorPresets.find(safeName); if(it != CompressorPresets.end()) { return it->second; @@ -317,8 +317,8 @@ sCompressorParameters cAudioEffects::getCompressorEffectPreset(const char* name) sEqualizerParameters cAudioEffects::getEqualizerEffectPreset(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); - std::map, cSTLAllocator> >::iterator it = EqualizerPresets.find(safeName); + cAudioString safeName = safeCStr(name); + cAudioMap::Type::iterator it = EqualizerPresets.find(safeName); if(it != EqualizerPresets.end()) { return it->second; @@ -329,7 +329,7 @@ sEqualizerParameters cAudioEffects::getEqualizerEffectPreset(const char* name) void cAudioEffects::removeEffectPreset(const EffectTypes& type, const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); switch(type) { case EET_EAX_REVERB: @@ -379,7 +379,7 @@ void cAudioEffects::removeEffectPreset(const EffectTypes& type, const char* name bool cAudioEffects::isEffectPresetRegistered(const EffectTypes& type, const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); switch(type) { case EET_EAX_REVERB: diff --git a/Source/cAudioManager.cpp b/Source/cAudioManager.cpp index 27d8855..888582c 100644 --- a/Source/cAudioManager.cpp +++ b/Source/cAudioManager.cpp @@ -16,7 +16,6 @@ #include "../include/cAudioPlatform.h" #include "../Headers/cFileSourceFactory.h" -#include #include #include @@ -54,14 +53,14 @@ namespace cAudio //Note: OpenAL is threadsafe, so a mutex only needs to protect the class state #ifdef CAUDIO_USE_INTERNAL_THREAD static cAudioMutex AudioManagerObjectsMutex; - static std::set, cSTLAllocator > AudioManagerObjects; + static cAudioSet::Type AudioManagerObjects; CAUDIO_DECLARE_THREAD_FUNCTION(AudioManagerUpdateThread) { while(RunAudioManagerThread) { AudioManagerObjectsMutex.lock(); - std::set, cSTLAllocator >::iterator it; + cAudioSet::Type::iterator it; for ( it=AudioManagerObjects.begin() ; it != AudioManagerObjects.end(); it++ ) { (*it)->update(); @@ -163,10 +162,10 @@ namespace cAudio { cAudioMutexBasicLock lock(Mutex); - std::string audioName = safeCStr(name); - std::string path = safeCStr(filename); + cAudioString audioName = safeCStr(name); + cAudioString path = safeCStr(filename); - std::string ext = getExt(path); + cAudioString ext = getExt(path); IAudioDecoderFactory* factory = getAudioDecoderFactory(ext.c_str()); if(factory) @@ -224,8 +223,8 @@ namespace cAudio { cAudioMutexBasicLock lock(Mutex); - std::string audioName = safeCStr(name); - std::string ext = safeCStr(extension); + cAudioString audioName = safeCStr(name); + cAudioString ext = safeCStr(extension); IAudioDecoderFactory* factory = getAudioDecoderFactory(ext.c_str()); if(factory) { @@ -289,7 +288,7 @@ namespace cAudio { cAudioMutexBasicLock lock(Mutex); - std::string audioName = safeCStr(name); + cAudioString audioName = safeCStr(name); IAudioDecoderFactory* factory = getAudioDecoderFactory("raw"); if(factory) { @@ -352,7 +351,7 @@ namespace cAudio bool cAudioManager::registerAudioDecoder(IAudioDecoderFactory* factory, const char* extension) { cAudioMutexBasicLock lock(Mutex); - std::string ext = safeCStr(extension); + cAudioString ext = safeCStr(extension); decodermap[ext] = factory; getLogger()->logInfo("AudioManager", "Audio Decoder for extension .%s registered.", ext.c_str()); return true; @@ -361,7 +360,7 @@ namespace cAudio void cAudioManager::unRegisterAudioDecoder(const char* extension) { cAudioMutexBasicLock lock(Mutex); - std::string ext = safeCStr(extension); + cAudioString ext = safeCStr(extension); decodermapIterator it = decodermap.find(ext); if(it != decodermap.end()) { @@ -373,7 +372,7 @@ namespace cAudio bool cAudioManager::isAudioDecoderRegistered(const char* extension) { cAudioMutexBasicLock lock(Mutex); - std::string ext = safeCStr(extension); + cAudioString ext = safeCStr(extension); decodermapIterator it = decodermap.find(ext); return (it != decodermap.end()); } @@ -381,7 +380,7 @@ namespace cAudio IAudioDecoderFactory* cAudioManager::getAudioDecoderFactory(const char* extension) { cAudioMutexBasicLock lock(Mutex); - std::string ext = safeCStr(extension); + cAudioString ext = safeCStr(extension); decodermapIterator it = decodermap.find(ext); if(it != decodermap.end()) { @@ -396,7 +395,7 @@ namespace cAudio decodermap.clear(); } - bool compareDataSourcePriorities(std::pair left, std::pair right) + bool compareDataSourcePriorities(std::pair left, std::pair right) { return (left.first > right.first); } @@ -404,9 +403,9 @@ namespace cAudio bool cAudioManager::registerDataSource(IDataSourceFactory* factory, const char* name, int priority) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); datasourcemap[safeName] = factory; - dataSourcePriorityList.push_back(std::pair(priority, safeName)); + dataSourcePriorityList.push_back(std::pair(priority, safeName)); std::sort(dataSourcePriorityList.begin(), dataSourcePriorityList.end(), compareDataSourcePriorities); getLogger()->logInfo("AudioManager", "Data Source named %s registered (Priority %i).", safeName.c_str(), priority); @@ -416,7 +415,7 @@ namespace cAudio void cAudioManager::unRegisterDataSource(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); datasourcemapIterator it = datasourcemap.find(safeName); if(it != datasourcemap.end()) { @@ -439,7 +438,7 @@ namespace cAudio bool cAudioManager::isDataSourceRegistered(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); datasourcemapIterator it = datasourcemap.find(safeName); return (it != datasourcemap.end()); } @@ -447,7 +446,7 @@ namespace cAudio IDataSourceFactory* cAudioManager::getDataSourceFactory(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string safeName = safeCStr(name); + cAudioString safeName = safeCStr(name); datasourcemapIterator it = datasourcemap.find(safeName); if(it != datasourcemap.end()) { @@ -487,7 +486,7 @@ namespace cAudio void cAudioManager::signalEvent(Events sevent) { cAudioMutexBasicLock lock(Mutex); - std::list >::iterator it = eventHandlerList.begin(); + cAudioList::Type::iterator it = eventHandlerList.begin(); if(it != eventHandlerList.end()) { @@ -553,7 +552,7 @@ namespace cAudio IAudioSource* cAudioManager::getSoundByName(const char* name) { cAudioMutexBasicLock lock(Mutex); - std::string audioName = safeCStr(name); + cAudioString audioName = safeCStr(name); audioIndexIterator i = audioIndex.find(audioName); if (i == audioIndex.end()) { @@ -672,7 +671,7 @@ namespace cAudio { while(*deviceList) { - std::string device(deviceList); + cAudioString device(deviceList); AvailableDevices.push_back(device); deviceList += strlen(deviceList) + 1; } @@ -688,7 +687,7 @@ namespace cAudio { while(*deviceList) { - std::string device(deviceList); + cAudioString device(deviceList); AvailableDevices.push_back(device); deviceList += strlen(deviceList) + 1; } @@ -748,7 +747,7 @@ namespace cAudio #endif #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT - std::vector plugins = cPluginManager::Instance()->getPluginList(); + cAudioVector::Type plugins = cPluginManager::Instance()->getPluginList(); for(unsigned int i = 0; i < plugins.size(); ++i) { plugins[i]->onCreateAudioManager(manager); @@ -783,7 +782,7 @@ namespace cAudio #endif #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT - std::vector plugins = cPluginManager::Instance()->getPluginList(); + cAudioVector::Type plugins = cPluginManager::Instance()->getPluginList(); for(unsigned int i = 0; i < plugins.size(); ++i) { plugins[i]->onDestroyAudioManager(manager); diff --git a/Source/cAudioSource.cpp b/Source/cAudioSource.cpp index 8cc2aac..21517e3 100644 --- a/Source/cAudioSource.cpp +++ b/Source/cAudioSource.cpp @@ -792,7 +792,7 @@ namespace cAudio void cAudioSource::signalEvent(Events sevent) { cAudioMutexBasicLock lock(Mutex); - std::list >::iterator it = eventHandlerList.begin(); + cAudioList::Type::iterator it = eventHandlerList.begin(); if(it != eventHandlerList.end()){ diff --git a/Source/cFileSource.cpp b/Source/cFileSource.cpp index 5e34b78..be68566 100644 --- a/Source/cFileSource.cpp +++ b/Source/cFileSource.cpp @@ -14,7 +14,7 @@ namespace cAudio cFileSource::cFileSource(const char* filename) : pFile(NULL), Valid(false), Filesize(0) { - std::string safeFilename = safeCStr(filename); + cAudioString safeFilename = safeCStr(filename); if(safeFilename.length() != 0) { pFile = fopen(safeFilename.c_str(),"rb"); diff --git a/Source/cLogger.cpp b/Source/cLogger.cpp index f403d9a..42c63d8 100644 --- a/Source/cLogger.cpp +++ b/Source/cLogger.cpp @@ -106,7 +106,7 @@ namespace cAudio bool cLogger::registerLogReceiver(ILogReceiver* receiver, const char* name) { Mutex.lock(); - std::string logName = safeCStr(name); + cAudioString logName = safeCStr(name); Receivers[logName] = receiver; Mutex.unlock(); return true; @@ -115,7 +115,7 @@ namespace cAudio void cLogger::unRegisterLogReceiver(const char* name) { Mutex.lock(); - std::string logName = safeCStr(name); + cAudioString logName = safeCStr(name); ReceiversIterator it = Receivers.find(logName); if(it != Receivers.end()) { @@ -127,7 +127,7 @@ namespace cAudio bool cLogger::isLogReceiverRegistered(const char* name) { Mutex.lock(); - std::string logName = safeCStr(name); + cAudioString logName = safeCStr(name); ReceiversIterator it = Receivers.find(logName); bool result = (it != Receivers.end()); Mutex.unlock(); @@ -137,7 +137,7 @@ namespace cAudio ILogReceiver* cLogger::getLogReceiver(const char* name) { Mutex.lock(); - std::string logName = safeCStr(name); + cAudioString logName = safeCStr(name); ReceiversIterator it = Receivers.find(logName); if(it != Receivers.end()) { diff --git a/Source/cPluginManager.cpp b/Source/cPluginManager.cpp index becf64a..2ed5e9e 100644 --- a/Source/cPluginManager.cpp +++ b/Source/cPluginManager.cpp @@ -40,7 +40,7 @@ bool cPluginManager::installPlugin(IAudioPlugin* plugin, const char* name) { if(plugin) { - std::string theName = safeCStr(name); + cAudioString theName = safeCStr(name); if(theName.empty()) theName = plugin->getPluginName(); @@ -96,9 +96,9 @@ unsigned int cPluginManager::getPluginCount() return RegisteredPlugins.size(); } -std::vector cPluginManager::getPluginList() +cAudioVector::Type cPluginManager::getPluginList() { - std::vector list; + cAudioVector::Type list; RegisteredPluginsIterator it; for(it = RegisteredPlugins.begin(); it != RegisteredPlugins.end(); it++) { @@ -148,7 +148,7 @@ void cPluginManager::uninstallPlugin(const char* name) #ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT void cPluginManager::autoLoadPlugins() { - std::vector fileList = getFilesInDirectory("."); + cAudioVector::Type fileList = getFilesInDirectory("."); for(int i=0; iAllocate(size, __FILE__, __LINE__, __FUNCTION__) + #define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer) +#else + #define CAUDIO_NEW new + #define CAUDIO_DELETE delete + #define CAUDIO_MALLOC(size) cAudio::getMemoryProvider()->Allocate(size, NULL, -1, NULL) + #define CAUDIO_FREE(pointer) cAudio::getMemoryProvider()->Free((void*)pointer) +#endif + namespace cAudio { CAUDIO_API IMemoryProvider* getMemoryProvider(); diff --git a/include/cAudioPlatform.h b/include/cAudioPlatform.h index 0656659..2875454 100644 --- a/include/cAudioPlatform.h +++ b/include/cAudioPlatform.h @@ -23,4 +23,20 @@ # endif #endif +#ifndef CAUDIO_COMPILIER_GCC +# if defined(__GNUC__) || defined(__GCCXML__) +# define CAUDIO_COMPILIER_GCC +# endif +#endif + +#ifndef CAUDIO_COMPILIER_MSVC +# if defined(_MSC_VER) +# if _MSC_VER >= 1400 +# define CAUDIO_COMPILIER_MSVC +# else +# error This version of the MSVC compilier is not supported +# endif +# endif +#endif + #endif //! CAUDIOPLATFORM_H_INCLUDED \ No newline at end of file