From 9f7cb9fd04531892308b53bf35beea64a2d9b02d Mon Sep 17 00:00:00 2001 From: Adam Miartus Date: Fri, 24 Jan 2020 09:56:54 +0100 Subject: [PATCH] JackGlobals: whitespace fix, no functional change fix to reflect programming style of other classes in Jack Audio Change-Id: I86f5d190d4a9df26a30c5de1b504421efe0202c1 Signed-off-by: Adam Miartus --- common/JackGlobals.h | 30 ++++--- common/JackLibGlobals.h | 157 +++++++++++++++++++------------------ common/JackServerGlobals.h | 61 +++++++------- 3 files changed, 129 insertions(+), 119 deletions(-) diff --git a/common/JackGlobals.h b/common/JackGlobals.h index 5d7c2421..812a2887 100644 --- a/common/JackGlobals.h +++ b/common/JackGlobals.h @@ -35,24 +35,28 @@ namespace Jack { // Globals used for client management on server or library side. -struct JackGlobals { - - static jack_tls_key fRealTimeThread; - static jack_tls_key fNotificationThread; - static jack_tls_key fKeyLogFunction; - static JackMutex* fOpenMutex; - static JackMutex* fSynchroMutex; - static volatile bool fServerRunning; - static JackClient* fClientTable[CLIENT_NUM]; - static bool fVerbose; +class JackGlobals +{ + + public: + + static jack_tls_key fRealTimeThread; + static jack_tls_key fNotificationThread; + static jack_tls_key fKeyLogFunction; + static JackMutex* fOpenMutex; + static JackMutex* fSynchroMutex; + static volatile bool fServerRunning; + static JackClient* fClientTable[CLIENT_NUM]; + static bool fVerbose; #ifndef WIN32 - static jack_thread_creator_t fJackThreadCreator; + static jack_thread_creator_t fJackThreadCreator; #endif #ifdef __CLIENTDEBUG__ - static std::ofstream* fStream; + static std::ofstream* fStream; #endif - static void CheckContext(const char* name); + static void CheckContext(const char* name); + }; // 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/JackLibGlobals.h b/common/JackLibGlobals.h index bca775a3..a25727a9 100644 --- a/common/JackLibGlobals.h +++ b/common/JackLibGlobals.h @@ -50,95 +50,98 @@ class JackClient; \brief Global library static structure: singleton kind of pattern. */ -struct JackLibGlobals +class JackLibGlobals { - JackShmReadWritePtr fGraphManager; /*! Shared memory Port manager */ - JackShmReadWritePtr fEngineControl; /*! Shared engine control */ // transport engine has to be writable - JackSynchro fSynchroTable[CLIENT_NUM]; /*! Shared synchro table */ - JackMetadata *fMetadata; /*! Shared metadata base */ - sigset_t fProcessSignals; - - static int fClientCount; - static JackLibGlobals* fGlobals; - - JackLibGlobals() - { - jack_log("JackLibGlobals"); - if (!JackMessageBuffer::Create()) { - jack_error("Cannot create message buffer"); - } - fGraphManager = -1; - fEngineControl = -1; - - fMetadata = new JackMetadata(false); - - // Filter SIGPIPE to avoid having client get a SIGPIPE when trying to access a died server. - #ifdef WIN32 - // TODO - #else - sigset_t signals; - sigemptyset(&signals); - sigaddset(&signals, SIGPIPE); - sigprocmask(SIG_BLOCK, &signals, &fProcessSignals); - #endif - } - - ~JackLibGlobals() - { - jack_log("~JackLibGlobals"); - for (int i = 0; i < CLIENT_NUM; i++) { - fSynchroTable[i].Disconnect(); - } - JackMessageBuffer::Destroy(); - delete fMetadata; - fMetadata = NULL; + public: + + JackShmReadWritePtr fGraphManager; /*! Shared memory Port manager */ + JackShmReadWritePtr fEngineControl; /*! Shared engine control */ // transport engine has to be writable + JackSynchro fSynchroTable[CLIENT_NUM]; /*! Shared synchro table */ + JackMetadata *fMetadata; /*! Shared metadata base */ + sigset_t fProcessSignals; - // Restore old signal mask - #ifdef WIN32 - // TODO - #else - sigprocmask(SIG_BLOCK, &fProcessSignals, 0); - #endif - } + static int fClientCount; + static JackLibGlobals* fGlobals; - static void Init() - { - if (!JackGlobals::fServerRunning && fClientCount > 0) { + JackLibGlobals() + { + jack_log("JackLibGlobals"); + if (!JackMessageBuffer::Create()) { + jack_error("Cannot create message buffer"); + } + fGraphManager = -1; + fEngineControl = -1; + + fMetadata = new JackMetadata(false); - // Cleanup remaining clients - jack_error("Jack server was closed but clients are still allocated, cleanup..."); + // Filter SIGPIPE to avoid having client get a SIGPIPE when trying to access a died server. +#ifdef WIN32 + // TODO +#else + sigset_t signals; + sigemptyset(&signals); + sigaddset(&signals, SIGPIPE); + sigprocmask(SIG_BLOCK, &signals, &fProcessSignals); +#endif + } + + ~JackLibGlobals() + { + jack_log("~JackLibGlobals"); for (int i = 0; i < CLIENT_NUM; i++) { - JackClient* client = JackGlobals::fClientTable[i]; - if (client) { - jack_error("Cleanup client ref = %d", i); - client->Close(); - delete client; - } + fSynchroTable[i].Disconnect(); } + JackMessageBuffer::Destroy(); - // Cleanup global context - fClientCount = 0; - delete fGlobals; - fGlobals = NULL; + delete fMetadata; + fMetadata = NULL; + + // Restore old signal mask +#ifdef WIN32 + // TODO +#else + sigprocmask(SIG_BLOCK, &fProcessSignals, 0); +#endif } - if (fClientCount++ == 0 && !fGlobals) { - jack_log("JackLibGlobals Init %x", fGlobals); - InitTime(); - fGlobals = new JackLibGlobals(); + static void Init() + { + if (!JackGlobals::fServerRunning && fClientCount > 0) { + + // Cleanup remaining clients + jack_error("Jack server was closed but clients are still allocated, cleanup..."); + for (int i = 0; i < CLIENT_NUM; i++) { + JackClient* client = JackGlobals::fClientTable[i]; + if (client) { + jack_error("Cleanup client ref = %d", i); + client->Close(); + delete client; + } + } + + // Cleanup global context + fClientCount = 0; + delete fGlobals; + fGlobals = NULL; + } + + if (fClientCount++ == 0 && !fGlobals) { + jack_log("JackLibGlobals Init %x", fGlobals); + InitTime(); + fGlobals = new JackLibGlobals(); + } } - } - - static void Destroy() - { - if (--fClientCount == 0 && fGlobals) { - jack_log("JackLibGlobals Destroy %x", fGlobals); - EndTime(); - delete fGlobals; - fGlobals = NULL; + + static void Destroy() + { + if (--fClientCount == 0 && fGlobals) { + jack_log("JackLibGlobals Destroy %x", fGlobals); + EndTime(); + delete fGlobals; + fGlobals = NULL; + } } - } }; diff --git a/common/JackServerGlobals.h b/common/JackServerGlobals.h index 15fdfd97..ad1db5f0 100644 --- a/common/JackServerGlobals.h +++ b/common/JackServerGlobals.h @@ -35,36 +35,39 @@ class JackClient; \brief Global server static structure: singleton kind of pattern. */ -struct SERVER_EXPORT JackServerGlobals +class SERVER_EXPORT JackServerGlobals { - static JackServer* fInstance; - static unsigned int fUserCount; - static std::map fSlavesList; - static std::map fInternalsList; - - static bool (* on_device_acquire)(const char* device_name); - static void (* on_device_release)(const char* device_name); - static void (* on_device_reservation_loop)(void); - - JackServerGlobals(); - ~JackServerGlobals(); - - static bool Init(); - static void Destroy(); - static int Start(const char* server_name, - jack_driver_desc_t* driver_desc, - JSList* driver_params, - int sync, - int temporary, - int time_out_ms, - int rt, - int priority, - int port_max, - int verbose, - jack_timer_type_t clock, - char self_connect_mode); - static void Stop(); - static void Delete(); + + public: + + static JackServer* fInstance; + static unsigned int fUserCount; + static std::map fSlavesList; + static std::map fInternalsList; + + static bool (* on_device_acquire)(const char* device_name); + static void (* on_device_release)(const char* device_name); + static void (* on_device_reservation_loop)(void); + + JackServerGlobals(); + ~JackServerGlobals(); + + static bool Init(); + static void Destroy(); + static int Start(const char* server_name, + jack_driver_desc_t* driver_desc, + JSList* driver_params, + int sync, + int temporary, + int time_out_ms, + int rt, + int priority, + int port_max, + int verbose, + jack_timer_type_t clock, + char self_connect_mode); + static void Stop(); + static void Delete(); }; } // end of namespace