diff --git a/ChangeLog b/ChangeLog index 12c84481..00905c1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,10 @@ Fernando Lopez-Lezcano Jackdmp changes log --------------------------- +2008-05-24 Stephane Letz + + * Tim Blechmann RAII idiom patch for JackServer ressource initialization. + 2008-05-23 Stephane Letz * Use StartSync to start the client notification thread, otherwise initial notifications from the server may be lost. diff --git a/common/JackGlobals.h b/common/JackGlobals.h index ba26bc6b..6e83590e 100644 --- a/common/JackGlobals.h +++ b/common/JackGlobals.h @@ -280,13 +280,29 @@ class JackGlobals }; +namespace detail +{ +struct JackGlobalsServerInitializer +{ + JackGlobalsServerInitializer(void) + { + JackGlobals::InitServer(); + } + + ~JackGlobalsServerInitializer(void) + { + JackGlobals::Destroy(); + } +}; +} + } // end of namespace #ifdef __cplusplus extern "C" { #endif - + extern jack_tls_key gRealTime; #ifdef WIN32 @@ -295,7 +311,7 @@ EXPORT void jack_init(); EXPORT void jack_uninit(); #else - + void __attribute__ ((constructor)) jack_init(); void __attribute__ ((destructor)) jack_uninit(); diff --git a/common/JackServer.cpp b/common/JackServer.cpp index 072d5494..f9766a15 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -44,7 +44,6 @@ JackServer* JackServer::fInstance = NULL; JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long priority, long loopback, bool verbose, const char* server_name) { - JackGlobals::InitServer(); for (int i = 0; i < CLIENT_NUM; i++) fSynchroTable[i] = JackGlobals::MakeSynchro(); fGraphManager = new JackGraphManager(); @@ -76,7 +75,6 @@ JackServer::~JackServer() UnloadDriverModule(fDriverInfo->handle); free(fDriverInfo); } - JackGlobals::Destroy(); } // TODO : better handling of intermediate failing cases... diff --git a/common/JackServer.h b/common/JackServer.h index eac66acb..f6817f9f 100644 --- a/common/JackServer.h +++ b/common/JackServer.h @@ -27,6 +27,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackConnectionManager.h" #include "jslist.h" +#include "JackGlobals.h" + namespace Jack { @@ -41,7 +43,7 @@ class JackEngineInterface; \brief The Jack server. */ -class EXPORT JackServer +class EXPORT JackServer : private detail::JackGlobalsServerInitializer { private: