From 9b6b2f4853b7cde63e9322b410a7d8cc5ffc543a Mon Sep 17 00:00:00 2001 From: "Brigham Keys, Esq" Date: Mon, 1 Aug 2016 14:08:19 -0500 Subject: [PATCH 1/6] Made the .so generated be versioned so that packagers can package it easier for the purpose of putting cAudio into repositories --- cAudio/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cAudio/CMakeLists.txt b/cAudio/CMakeLists.txt index 0bb36ba..1e68759 100644 --- a/cAudio/CMakeLists.txt +++ b/cAudio/CMakeLists.txt @@ -26,6 +26,9 @@ else() target_link_libraries(cAudio ${OPENAL_LIBRARIES}) endif() +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY VERSION "2.3.0") +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY SOVERSION 2 ) + if (APPLE AND CAUDIO_IOS_BUILD) set_target_properties(cAudio PROPERTIES XCODE_ATTRIBUTE_GCC_THUMB_SUPPORT "NO") set_target_properties(cAudio PROPERTIES XCODE_ATTRIBUTE_GCC_UNROLL_LOOPS "YES") From 87f3aff4234c06fa624d184efe602ce7eea223dd Mon Sep 17 00:00:00 2001 From: "Brigham Keys, Esq" Date: Mon, 1 Aug 2016 17:03:52 -0500 Subject: [PATCH 2/6] Modified the audiomanager so that it can configure where it is going to place the log files --- cAudio/Headers/cFileLogReceiver.h | 6 +-- cAudio/include/cAudio.h | 3 +- cAudio/src/cAudio.cpp | 67 +++++++++++++++++-------------- cAudio/src/cFileLogReceiver.cpp | 7 ++-- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/cAudio/Headers/cFileLogReceiver.h b/cAudio/Headers/cFileLogReceiver.h index f40002a..54947d5 100644 --- a/cAudio/Headers/cFileLogReceiver.h +++ b/cAudio/Headers/cFileLogReceiver.h @@ -14,7 +14,7 @@ namespace cAudio class cFileLogReceiver : public ILogReceiver { public: - cFileLogReceiver(); + cFileLogReceiver(const char *lFilePath); ~cFileLogReceiver(); bool OnLogMessage(const char* sender, const char* message, LogLevel level, float time); @@ -22,7 +22,7 @@ namespace cAudio private: bool firsttime; - + const char *logFilePath; }; }; -#endif \ No newline at end of file +#endif diff --git a/cAudio/include/cAudio.h b/cAudio/include/cAudio.h index 485728a..ea25fb8 100644 --- a/cAudio/include/cAudio.h +++ b/cAudio/include/cAudio.h @@ -108,9 +108,10 @@ namespace cAudio { /** Note: This is the only way to get access to the audio playback capabilities of cAudio. You must delete this interface using destroyAudioManager() once you are done with it. \param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before you can create audio sources. + \param lFilePath Where the log file is going to be placed \return A pointer to the created object, NULL if the object could not be allocated. */ - CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true); + CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true, const char *lFilePath = "cAudioEngineLog.html"); //! Destroys an interface to a previously created Audio Manager and frees the memory allocated for it. /** diff --git a/cAudio/src/cAudio.cpp b/cAudio/src/cAudio.cpp index f7d4d62..02233fb 100644 --- a/cAudio/src/cAudio.cpp +++ b/cAudio/src/cAudio.cpp @@ -30,6 +30,19 @@ namespace cAudio { + //--------------------------------------------------------------------------------------- + // Logger section + //--------------------------------------------------------------------------------------- + +#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1 + static cConsoleLogReceiver ConsoleLog; +#endif + +#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 + // static cFileLogReceiver *FileLog = new cFileLogReceiver(); + static cFileLogReceiver *FileLog; +#endif + //--------------------------------------------------------------------------------------- // Audio manager section //--------------------------------------------------------------------------------------- @@ -46,10 +59,11 @@ namespace cAudio #if CAUDIO_COMPILE_WITH_FILE_SOURCE == 1 static cFileSourceFactory FileSourceFactory; #endif - - CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault) + CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault, const char *lFilePath) { cAudioManager* manager = CAUDIO_NEW cAudioManager; + if(FileLog == nullptr) + FileLog = new cFileLogReceiver(lFilePath); if(manager) { if(initializeDefault) @@ -98,6 +112,26 @@ namespace cAudio } } + ////////////////////////////////////////// + + CAUDIO_API ILogger* getLogger() + { + static cLogger* Logger = NULL; + if(!Logger) + { + Logger = new cLogger; +#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1 + Logger->registerLogReceiver(&ConsoleLog, "Console"); +#endif +#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 + Logger->registerLogReceiver(FileLog,"File"); +#endif + } + return Logger; + } + + + //--------------------------------------------------------------------------------------- // Audio capture section //--------------------------------------------------------------------------------------- @@ -137,35 +171,6 @@ namespace cAudio } } - //--------------------------------------------------------------------------------------- - // Logger section - //--------------------------------------------------------------------------------------- - -#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1 - static cConsoleLogReceiver ConsoleLog; -#endif - -#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 - static cFileLogReceiver FileLog; -#endif - - CAUDIO_API ILogger* getLogger() - { - static cLogger* Logger = NULL; - - if(!Logger) - { - Logger = new cLogger; -#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1 - Logger->registerLogReceiver(&ConsoleLog, "Console"); -#endif -#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 - Logger->registerLogReceiver(&FileLog,"File"); -#endif - } - return Logger; - } - //--------------------------------------------------------------------------------------- // IAudioDeviceList section //--------------------------------------------------------------------------------------- diff --git a/cAudio/src/cFileLogReceiver.cpp b/cAudio/src/cFileLogReceiver.cpp index 2c367d1..4db6b7f 100644 --- a/cAudio/src/cFileLogReceiver.cpp +++ b/cAudio/src/cFileLogReceiver.cpp @@ -10,7 +10,8 @@ namespace cAudio { - cFileLogReceiver::cFileLogReceiver() + cFileLogReceiver::cFileLogReceiver(const char *lFilePath) : + logFilePath(lFilePath) { firsttime = false; } @@ -31,7 +32,7 @@ namespace cAudio // Reset log file outf.setf( std::ios::fixed ); outf.precision( 3 ); - outf.open( "cAudioEngineLog.html", std::ios::out ); + outf.open( logFilePath, std::ios::out ); if( !outf ){ return false; @@ -108,7 +109,7 @@ namespace cAudio } else { - outf.open( "cAudioEngineLog.html", std::ios::out | std::ios::app ); + outf.open( logFilePath, std::ios::out | std::ios::app ); if( !outf ){ return false; From 22be57285522b008f64cbcd89184f8b4e3efa47c Mon Sep 17 00:00:00 2001 From: "Brigham Keys, Esq" Date: Mon, 1 Aug 2016 17:06:40 -0500 Subject: [PATCH 3/6] Made the code a bit less ugly --- cAudio/src/cAudio.cpp | 51 +++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/cAudio/src/cAudio.cpp b/cAudio/src/cAudio.cpp index 02233fb..711d3d5 100644 --- a/cAudio/src/cAudio.cpp +++ b/cAudio/src/cAudio.cpp @@ -30,22 +30,37 @@ namespace cAudio { - //--------------------------------------------------------------------------------------- - // Logger section - //--------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------- +// Logger section +//--------------------------------------------------------------------------------------- #if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1 static cConsoleLogReceiver ConsoleLog; #endif #if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 - // static cFileLogReceiver *FileLog = new cFileLogReceiver(); - static cFileLogReceiver *FileLog; + static cFileLogReceiver *FileLog; #endif - //--------------------------------------------------------------------------------------- - // Audio manager section - //--------------------------------------------------------------------------------------- + CAUDIO_API ILogger* getLogger() + { + static cLogger* Logger = NULL; + if(!Logger) + { + Logger = new cLogger; +#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1 + Logger->registerLogReceiver(&ConsoleLog, "Console"); +#endif +#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 + Logger->registerLogReceiver(FileLog,"File"); +#endif + } + return Logger; + } + +//--------------------------------------------------------------------------------------- +// Audio manager section +//--------------------------------------------------------------------------------------- #if CAUDIO_COMPILE_WITH_OGG_DECODER == 1 static cOggAudioDecoderFactory OggDecoderFactory; @@ -112,26 +127,6 @@ namespace cAudio } } - ////////////////////////////////////////// - - CAUDIO_API ILogger* getLogger() - { - static cLogger* Logger = NULL; - if(!Logger) - { - Logger = new cLogger; -#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1 - Logger->registerLogReceiver(&ConsoleLog, "Console"); -#endif -#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 - Logger->registerLogReceiver(FileLog,"File"); -#endif - } - return Logger; - } - - - //--------------------------------------------------------------------------------------- // Audio capture section //--------------------------------------------------------------------------------------- From d9f45c16d69a74bdfce466b184dbf02a78686491 Mon Sep 17 00:00:00 2001 From: "Brigham Keys, Esq" Date: Mon, 1 Aug 2016 17:09:32 -0500 Subject: [PATCH 4/6] Removed memory leak --- cAudio/src/cAudio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cAudio/src/cAudio.cpp b/cAudio/src/cAudio.cpp index 711d3d5..85e8dcb 100644 --- a/cAudio/src/cAudio.cpp +++ b/cAudio/src/cAudio.cpp @@ -110,6 +110,8 @@ namespace cAudio CAUDIO_API void destroyAudioManager(IAudioManager* manager) { + if(FileLog not_eq nullptr) + delete FileLog; if(manager) { #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT From 2e0bba404823e90125e12149f104013f4f25208d Mon Sep 17 00:00:00 2001 From: "Brigham Keys, Esq" Date: Mon, 1 Aug 2016 19:07:27 -0500 Subject: [PATCH 5/6] Fixed the compiler macro --- cAudio/src/cAudio.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cAudio/src/cAudio.cpp b/cAudio/src/cAudio.cpp index 85e8dcb..177d26c 100644 --- a/cAudio/src/cAudio.cpp +++ b/cAudio/src/cAudio.cpp @@ -77,8 +77,11 @@ namespace cAudio CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault, const char *lFilePath) { cAudioManager* manager = CAUDIO_NEW cAudioManager; +#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 if(FileLog == nullptr) + FileLog = new cFileLogReceiver(lFilePath); +#endif if(manager) { if(initializeDefault) From 2a790c34da5c1a52cc9f4c8943cbbebf1105985c Mon Sep 17 00:00:00 2001 From: "Brigham Keys, Esq" Date: Tue, 2 Aug 2016 12:24:38 -0500 Subject: [PATCH 6/6] Forgot to apply the macro on the delete, everything should be fine now --- cAudio/src/cAudio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cAudio/src/cAudio.cpp b/cAudio/src/cAudio.cpp index 177d26c..5461dba 100644 --- a/cAudio/src/cAudio.cpp +++ b/cAudio/src/cAudio.cpp @@ -113,8 +113,10 @@ namespace cAudio CAUDIO_API void destroyAudioManager(IAudioManager* manager) { +#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1 if(FileLog not_eq nullptr) delete FileLog; +#endif if(manager) { #ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT