git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3666 0c269be4-1314-0410-8aa9-9f06e86f4224tags/v1.9.4
| @@ -30,6 +30,7 @@ Paul Davis | |||||
| * Correct JackProcessSync::LockedTimedWait. | * Correct JackProcessSync::LockedTimedWait. | ||||
| * Correct JACK_MESSAGE_SIZE value, particularly in OSX RPC code. | * 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. | * 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 <letz@grame.fr> | 2009-10-22 Stephane Letz <letz@grame.fr> | ||||
| @@ -25,8 +25,6 @@ | |||||
| #include "JackGlobals.h" | #include "JackGlobals.h" | ||||
| #include "JackMessageBuffer.h" | #include "JackMessageBuffer.h" | ||||
| int jack_verbose = 0; | |||||
| using namespace Jack; | using namespace Jack; | ||||
| void change_thread_log_function(jack_log_function_t log_function) | 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,...) | SERVER_EXPORT void jack_log(const char *fmt,...) | ||||
| { | { | ||||
| if (jack_verbose) { | |||||
| if (JackGlobals::fVerbose) { | |||||
| va_list ap; | va_list ap; | ||||
| va_start(ap, fmt); | va_start(ap, fmt); | ||||
| jack_format_and_log(LOG_LEVEL_INFO, "Jack: ", fmt, ap); | jack_format_and_log(LOG_LEVEL_INFO, "Jack: ", fmt, ap); | ||||
| @@ -58,8 +58,6 @@ extern "C" | |||||
| void jack_log_function(int level, const char *message); | void jack_log_function(int level, const char *message); | ||||
| SERVER_EXPORT void set_threaded_log_function(); | SERVER_EXPORT void set_threaded_log_function(); | ||||
| extern int jack_verbose; | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| @@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| bool JackGlobals::fVerbose = 0; | |||||
| jack_tls_key JackGlobals::fRealTime; | jack_tls_key JackGlobals::fRealTime; | ||||
| static bool gKeyRealtimeInitialized = jack_tls_allocate_key(&JackGlobals::fRealTime); | static bool gKeyRealtimeInitialized = jack_tls_allocate_key(&JackGlobals::fRealTime); | ||||
| @@ -34,10 +34,10 @@ struct JackGlobals { | |||||
| static JackMutex* fOpenMutex; | static JackMutex* fOpenMutex; | ||||
| static bool fServerRunning; | static bool fServerRunning; | ||||
| static JackClient* fClientTable[]; | static JackClient* fClientTable[]; | ||||
| static bool fVerbose; | |||||
| #ifndef WIN32 | #ifndef WIN32 | ||||
| static jack_thread_creator_t fJackThreadCreator; | static jack_thread_creator_t fJackThreadCreator; | ||||
| #endif | #endif | ||||
| }; | }; | ||||
| // Each "side" server and client will implement this to get the shared graph manager, engine control and inter-process synchro table. | // Each "side" server and client will implement this to get the shared graph manager, engine control and inter-process synchro table. | ||||
| @@ -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->fEngineControl.SetShmIndex(shared_engine, fServerName); | ||||
| JackLibGlobals::fGlobals->fGraphManager.SetShmIndex(shared_graph, fServerName); | JackLibGlobals::fGlobals->fGraphManager.SetShmIndex(shared_graph, fServerName); | ||||
| fClientControl.SetShmIndex(shared_client, fServerName); | fClientControl.SetShmIndex(shared_client, fServerName); | ||||
| jack_verbose = GetEngineControl()->fVerbose; | |||||
| JackGlobals::fVerbose = GetEngineControl()->fVerbose; | |||||
| } catch (int n) { | } catch (int n) { | ||||
| jack_error("Map shared memory segments exception %d", n); | jack_error("Map shared memory segments exception %d", n); | ||||
| goto error; | goto error; | ||||
| @@ -29,13 +29,19 @@ namespace Jack | |||||
| JackMessageBuffer* JackMessageBuffer::fInstance = NULL; | JackMessageBuffer* JackMessageBuffer::fInstance = NULL; | ||||
| JackMessageBuffer::JackMessageBuffer() | 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; | fRunning = true; | ||||
| fThread.StartSync(); | fThread.StartSync(); | ||||
| } | } | ||||
| JackMessageBuffer::~JackMessageBuffer() | |||||
| void JackMessageBuffer::Stop() | |||||
| { | { | ||||
| if (fOverruns > 0) { | if (fOverruns > 0) { | ||||
| jack_error("WARNING: %d message buffer overruns!", fOverruns); | jack_error("WARNING: %d message buffer overruns!", fOverruns); | ||||
| @@ -49,7 +55,7 @@ JackMessageBuffer::~JackMessageBuffer() | |||||
| fThread.Stop(); | fThread.Stop(); | ||||
| Flush(); | Flush(); | ||||
| } | } | ||||
| void JackMessageBuffer::Flush() | void JackMessageBuffer::Flush() | ||||
| { | { | ||||
| while (fOutBuffer != fInBuffer) { | while (fOutBuffer != fInBuffer) { | ||||
| @@ -86,12 +92,14 @@ void JackMessageBuffer::Create() | |||||
| { | { | ||||
| if (fInstance == NULL) { | if (fInstance == NULL) { | ||||
| fInstance = new JackMessageBuffer(); | fInstance = new JackMessageBuffer(); | ||||
| fInstance->Start(); | |||||
| } | } | ||||
| } | } | ||||
| void JackMessageBuffer::Destroy() | void JackMessageBuffer::Destroy() | ||||
| { | { | ||||
| if (fInstance != NULL) { | if (fInstance != NULL) { | ||||
| fInstance->Stop(); | |||||
| delete fInstance; | delete fInstance; | ||||
| fInstance = NULL; | fInstance = NULL; | ||||
| } | } | ||||
| @@ -100,8 +108,7 @@ void JackMessageBuffer::Destroy() | |||||
| void JackMessageBufferAdd(int level, const char *message) | void JackMessageBufferAdd(int level, const char *message) | ||||
| { | { | ||||
| if (Jack::JackMessageBuffer::fInstance == NULL) { | 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"); | jack_log_function(LOG_LEVEL_ERROR, "messagebuffer not initialized, skip message"); | ||||
| } else { | } else { | ||||
| Jack::JackMessageBuffer::fInstance->AddMessage(level, message); | Jack::JackMessageBuffer::fInstance->AddMessage(level, message); | ||||
| @@ -66,10 +66,13 @@ class JackMessageBuffer : public JackRunnableInterface | |||||
| bool fRunning; | bool fRunning; | ||||
| void Flush(); | void Flush(); | ||||
| void Start(); | |||||
| void Stop(); | |||||
| public: | public: | ||||
| JackMessageBuffer(); | |||||
| JackMessageBuffer(); | |||||
| ~JackMessageBuffer(); | ~JackMessageBuffer(); | ||||
| // JackRunnableInterface interface | // JackRunnableInterface interface | ||||
| @@ -55,7 +55,7 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr | |||||
| fFreewheel = false; | fFreewheel = false; | ||||
| JackServerGlobals::fInstance = this; // Unique instance | JackServerGlobals::fInstance = this; // Unique instance | ||||
| JackServerGlobals::fUserCount = 1; // One user | JackServerGlobals::fUserCount = 1; // One user | ||||
| jack_verbose = verbose; | |||||
| JackGlobals::fVerbose = verbose; | |||||
| } | } | ||||
| JackServer::~JackServer() | JackServer::~JackServer() | ||||