From cf33a4d05eaf69e05aeb8f8ba91baa094ece0799 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 23 Oct 2009 13:53:53 +0000 Subject: [PATCH] jack_verbose moved to JackGlobals class. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3666 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 1 + common/JackError.cpp | 4 +--- common/JackError.h | 2 -- common/JackGlobals.cpp | 2 ++ common/JackGlobals.h | 2 +- common/JackLibClient.cpp | 2 +- common/JackMessageBuffer.cpp | 17 ++++++++++++----- common/JackMessageBuffer.h | 5 ++++- common/JackServer.cpp | 2 +- 9 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a95f906..94ded717 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,7 @@ Paul Davis * Correct JackProcessSync::LockedTimedWait. * Correct JACK_MESSAGE_SIZE value, particularly in OSX RPC code. * Now start server channel thread only when backend has been started (so in JackServer::Start). Should solve race conditions at start time. + * jack_verbose moved to JackGlobals class. 2009-10-22 Stephane Letz diff --git a/common/JackError.cpp b/common/JackError.cpp index aad72327..3705c35c 100644 --- a/common/JackError.cpp +++ b/common/JackError.cpp @@ -25,8 +25,6 @@ #include "JackGlobals.h" #include "JackMessageBuffer.h" -int jack_verbose = 0; - using namespace Jack; void change_thread_log_function(jack_log_function_t log_function) @@ -110,7 +108,7 @@ SERVER_EXPORT void jack_info(const char *fmt, ...) SERVER_EXPORT void jack_log(const char *fmt,...) { - if (jack_verbose) { + if (JackGlobals::fVerbose) { va_list ap; va_start(ap, fmt); jack_format_and_log(LOG_LEVEL_INFO, "Jack: ", fmt, ap); diff --git a/common/JackError.h b/common/JackError.h index fca6ec30..403c55ae 100644 --- a/common/JackError.h +++ b/common/JackError.h @@ -58,8 +58,6 @@ extern "C" void jack_log_function(int level, const char *message); SERVER_EXPORT void set_threaded_log_function(); - - extern int jack_verbose; #ifdef __cplusplus } diff --git a/common/JackGlobals.cpp b/common/JackGlobals.cpp index 599523db..c8c40545 100644 --- a/common/JackGlobals.cpp +++ b/common/JackGlobals.cpp @@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace Jack { +bool JackGlobals::fVerbose = 0; + jack_tls_key JackGlobals::fRealTime; static bool gKeyRealtimeInitialized = jack_tls_allocate_key(&JackGlobals::fRealTime); diff --git a/common/JackGlobals.h b/common/JackGlobals.h index 8dfe7f92..7586708e 100644 --- a/common/JackGlobals.h +++ b/common/JackGlobals.h @@ -34,10 +34,10 @@ struct JackGlobals { static JackMutex* fOpenMutex; static bool fServerRunning; static JackClient* fClientTable[]; + static bool fVerbose; #ifndef WIN32 static jack_thread_creator_t fJackThreadCreator; #endif - }; // Each "side" server and client will implement this to get the shared graph manager, engine control and inter-process synchro table. diff --git a/common/JackLibClient.cpp b/common/JackLibClient.cpp index ca41d923..4c92e9e3 100644 --- a/common/JackLibClient.cpp +++ b/common/JackLibClient.cpp @@ -99,7 +99,7 @@ int JackLibClient::Open(const char* server_name, const char* name, jack_options_ JackLibGlobals::fGlobals->fEngineControl.SetShmIndex(shared_engine, fServerName); JackLibGlobals::fGlobals->fGraphManager.SetShmIndex(shared_graph, fServerName); fClientControl.SetShmIndex(shared_client, fServerName); - jack_verbose = GetEngineControl()->fVerbose; + JackGlobals::fVerbose = GetEngineControl()->fVerbose; } catch (int n) { jack_error("Map shared memory segments exception %d", n); goto error; diff --git a/common/JackMessageBuffer.cpp b/common/JackMessageBuffer.cpp index 18e4d52f..bc380a52 100644 --- a/common/JackMessageBuffer.cpp +++ b/common/JackMessageBuffer.cpp @@ -29,13 +29,19 @@ namespace Jack JackMessageBuffer* JackMessageBuffer::fInstance = NULL; JackMessageBuffer::JackMessageBuffer() - :fThread(this),fInBuffer(0),fOutBuffer(0),fOverruns(0) + :fThread(this),fInBuffer(0),fOutBuffer(0),fOverruns(0),fRunning(false) +{} + +JackMessageBuffer::~JackMessageBuffer() +{} + +void JackMessageBuffer::Start() { fRunning = true; fThread.StartSync(); } -JackMessageBuffer::~JackMessageBuffer() +void JackMessageBuffer::Stop() { if (fOverruns > 0) { jack_error("WARNING: %d message buffer overruns!", fOverruns); @@ -49,7 +55,7 @@ JackMessageBuffer::~JackMessageBuffer() fThread.Stop(); Flush(); } - + void JackMessageBuffer::Flush() { while (fOutBuffer != fInBuffer) { @@ -86,12 +92,14 @@ void JackMessageBuffer::Create() { if (fInstance == NULL) { fInstance = new JackMessageBuffer(); + fInstance->Start(); } } void JackMessageBuffer::Destroy() { if (fInstance != NULL) { + fInstance->Stop(); delete fInstance; fInstance = NULL; } @@ -100,8 +108,7 @@ void JackMessageBuffer::Destroy() void JackMessageBufferAdd(int level, const char *message) { if (Jack::JackMessageBuffer::fInstance == NULL) { - /* Unable to print message with realtime safety. - * Complain and print it anyway. */ + /* Unable to print message with realtime safety. Complain and print it anyway. */ jack_log_function(LOG_LEVEL_ERROR, "messagebuffer not initialized, skip message"); } else { Jack::JackMessageBuffer::fInstance->AddMessage(level, message); diff --git a/common/JackMessageBuffer.h b/common/JackMessageBuffer.h index 23bb12a6..5e3472a5 100644 --- a/common/JackMessageBuffer.h +++ b/common/JackMessageBuffer.h @@ -66,10 +66,13 @@ class JackMessageBuffer : public JackRunnableInterface bool fRunning; void Flush(); + + void Start(); + void Stop(); public: - JackMessageBuffer(); + JackMessageBuffer(); ~JackMessageBuffer(); // JackRunnableInterface interface diff --git a/common/JackServer.cpp b/common/JackServer.cpp index b51ca2ce..a260b47a 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -55,7 +55,7 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr fFreewheel = false; JackServerGlobals::fInstance = this; // Unique instance JackServerGlobals::fUserCount = 1; // One user - jack_verbose = verbose; + JackGlobals::fVerbose = verbose; } JackServer::~JackServer()