diff options
author | sletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224> | 2012-01-24 16:33:31 +0000 |
---|---|---|
committer | sletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224> | 2012-01-24 16:33:31 +0000 |
commit | 5e8a775049148867db7469d091484513c2ec2d55 (patch) | |
tree | c32b6ff3543cca0030947f97452a92658a7d7323 | |
parent | b4dbbf3e73ccb99226a2f0adbc3ec9a8683ce1a3 (diff) | |
download | jack2-5e8a775049148867db7469d091484513c2ec2d55.tar.gz |
Correct ShutDown in JackInternalClient and JackLibClient.
git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4731 0c269be4-1314-0410-8aa9-9f06e86f4224
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | common/JackClient.cpp | 34 | ||||
-rw-r--r-- | common/JackEngine.cpp | 8 | ||||
-rw-r--r-- | common/JackInternalClient.cpp | 13 | ||||
-rw-r--r-- | common/JackInternalClient.h | 1 | ||||
-rw-r--r-- | common/JackLibClient.cpp | 14 | ||||
-rw-r--r-- | common/JackLibClient.h | 1 | ||||
-rw-r--r-- | common/JackNetManager.cpp | 35 | ||||
-rw-r--r-- | common/JackNetManager.h | 3 | ||||
-rw-r--r-- | windows/JackRouter/JackRouter.cpp | 5 |
10 files changed, 71 insertions, 48 deletions
@@ -36,6 +36,11 @@ John Emmas Jackdmp changes log --------------------------- +2012-01-24 Stephane Letz <letz@grame.fr> + + * Improve ShutDown in NetManager + * Correct ShutDown in JackInternalClient and JackLibClient. + 2012-01-20 Stephane Letz <letz@grame.fr> * Experimental system port alias use in WIndows JackRouter. diff --git a/common/JackClient.cpp b/common/JackClient.cpp index 9e1c952b..4070d0d0 100644 --- a/common/JackClient.cpp +++ b/common/JackClient.cpp @@ -88,6 +88,19 @@ JackClient::JackClient(JackSynchro* table):fThread(this) JackClient::~JackClient() {} +void JackClient::ShutDown() +{ + jack_log("JackClient::ShutDown"); + + if (fInfoShutdown) { + fInfoShutdown(JackFailure, "JACK server has been closed", fInfoShutdownArg); + fInfoShutdown = NULL; + } else if (fShutdown) { + fShutdown(fShutdownArg); + fShutdown = NULL; + } +} + int JackClient::Close() { jack_log("JackClient::Close ref = %ld", GetClientControl()->fRefNum); @@ -747,27 +760,6 @@ int JackClient::ComputeTotalLatencies() return result; } -/* -ShutDown is called: -- from the RT thread when Execute method fails -- possibly from a "closed" notification channel -(Not needed since the synch object used (Sema of Fifo will fails when server quits... see ShutDown)) -*/ - -void JackClient::ShutDown() -{ - jack_log("JackClient::ShutDown"); - JackGlobals::fServerRunning = false; - - if (fInfoShutdown) { - fInfoShutdown(JackFailure, "JACK server has been closed", fInfoShutdownArg); - fInfoShutdown = NULL; - } else if (fShutdown) { - fShutdown(fShutdownArg); - fShutdown = NULL; - } -} - //---------------------- // Transport management //---------------------- diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index fdc5f698..9d2c3447 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -78,14 +78,13 @@ int JackEngine::Close() if (JackLoadableInternalClient* loadable_client = dynamic_cast<JackLoadableInternalClient*>(fClientTable[i])) { jack_log("JackEngine::Close loadable client = %s", loadable_client->GetClientControl()->fName); loadable_client->Close(); - // Close does not delete the pointer for internal clients fClientTable[i] = NULL; delete loadable_client; } else if (JackExternalClient* external_client = dynamic_cast<JackExternalClient*>(fClientTable[i])) { jack_log("JackEngine::Close external client = %s", external_client->GetClientControl()->fName); external_client->Close(); - // Close deletes the pointer for external clients fClientTable[i] = NULL; + delete external_client; } } @@ -671,6 +670,8 @@ error: // Used for external clients int JackEngine::ClientExternalClose(int refnum) { + jack_log("JackEngine::ClientExternalClose ref = %ld", refnum); + JackClientInterface* client = fClientTable[refnum]; fEngineControl->fTransport.ResetTimebase(refnum); int res = ClientCloseAux(refnum, client, true); @@ -682,7 +683,10 @@ int JackEngine::ClientExternalClose(int refnum) // Used for server internal clients or drivers when the RT thread is stopped int JackEngine::ClientInternalClose(int refnum, bool wait) { + jack_log("JackEngine::ClientInternalClose ref = %ld", refnum); + JackClientInterface* client = fClientTable[refnum]; + fEngineControl->fTransport.ResetTimebase(refnum); return ClientCloseAux(refnum, client, wait); } diff --git a/common/JackInternalClient.cpp b/common/JackInternalClient.cpp index c843559f..5b7060c9 100644 --- a/common/JackInternalClient.cpp +++ b/common/JackInternalClient.cpp @@ -59,7 +59,6 @@ SERVER_EXPORT JackSynchro* GetSynchroTable() JackInternalClient::JackInternalClient(JackServer* server, JackSynchro* table): JackClient(table) { fChannel = new JackInternalClientChannel(server); - //fChannel = new JackGenericClientChannel(); } JackInternalClient::~JackInternalClient() @@ -106,6 +105,12 @@ error: return -1; } +void JackInternalClient::ShutDown() +{ + jack_log("JackInternalClient::ShutDown"); + JackClient::ShutDown(); +} + JackGraphManager* JackInternalClient::GetGraphManager() const { assert(fGraphManager); @@ -196,10 +201,12 @@ JackLoadableInternalClient2::JackLoadableInternalClient2(JackServer* server, Jac JackLoadableInternalClient::~JackLoadableInternalClient() { - if (fFinish != NULL) + if (fFinish != NULL) { fFinish(fProcessArg); - if (fHandle != NULL) + } + if (fHandle != NULL) { UnloadJackModule(fHandle); + } } int JackLoadableInternalClient1::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) diff --git a/common/JackInternalClient.h b/common/JackInternalClient.h index d8479271..e47066cf 100644 --- a/common/JackInternalClient.h +++ b/common/JackInternalClient.h @@ -47,6 +47,7 @@ class JackInternalClient : public JackClient virtual ~JackInternalClient(); int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status); + void ShutDown(); JackGraphManager* GetGraphManager() const; JackEngineControl* GetEngineControl() const; diff --git a/common/JackLibClient.cpp b/common/JackLibClient.cpp index 4ba58c9c..72b05642 100644 --- a/common/JackLibClient.cpp +++ b/common/JackLibClient.cpp @@ -55,6 +55,20 @@ JackSynchro* GetSynchroTable() // Client management //------------------- +/* +ShutDown is called: +- from the RT thread when Execute method fails +- possibly from a "closed" notification channel +(Not needed since the synch object used (Sema of Fifo will fails when server quits... see ShutDown)) +*/ + +void JackLibClient::ShutDown() +{ + jack_log("JackLibClient::ShutDown"); + JackGlobals::fServerRunning = false; + JackClient::ShutDown(); +} + JackLibClient::JackLibClient(JackSynchro* table): JackClient(table) { jack_log("JackLibClient::JackLibClient table = %x", table); diff --git a/common/JackLibClient.h b/common/JackLibClient.h index a294ab45..5e78b6f8 100644 --- a/common/JackLibClient.h +++ b/common/JackLibClient.h @@ -45,6 +45,7 @@ class JackLibClient : public JackClient virtual ~JackLibClient(); int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status); + void ShutDown(); int ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); diff --git a/common/JackNetManager.cpp b/common/JackNetManager.cpp index a3cb6e0a..3d39a102 100644 --- a/common/JackNetManager.cpp +++ b/common/JackNetManager.cpp @@ -560,7 +560,7 @@ namespace Jack const JSList* node; const jack_driver_param_t* param; - jack_on_shutdown(fClient, ShutDown, this); + jack_on_shutdown(fClient, SetShutDown, this); // Possibly use env variable const char* default_udp_port = getenv("JACK_NETJACK_PORT"); @@ -613,17 +613,7 @@ namespace Jack JackNetMasterManager::~JackNetMasterManager() { jack_log("JackNetMasterManager::~JackNetMasterManager"); - jack_info("Exiting NetManager..."); - if (fRunning) { - jack_client_kill_thread(fClient, fThread); - fRunning = false; - } - master_list_t::iterator it; - for (it = fMasterList.begin(); it != fMasterList.end(); it++) { - delete(*it); - } - fSocket.Close(); - SocketAPIEnd(); + ShutDown(); } int JackNetMasterManager::CountIO(int flags) @@ -644,14 +634,25 @@ namespace Jack return count; } - void JackNetMasterManager::ShutDown(void* arg) + void JackNetMasterManager::SetShutDown(void* arg) + { + static_cast<JackNetMasterManager*>(arg)->ShutDown(); + } + + void JackNetMasterManager::ShutDown() { jack_log("JackNetMasterManager::ShutDown"); - JackNetMasterManager* manager = (JackNetMasterManager*)arg; - if (manager->fRunning) { - jack_client_kill_thread(manager->fClient, manager->fThread); - manager->fRunning = false; + if (fRunning) { + jack_client_kill_thread(fClient, fThread); + fRunning = false; } + master_list_t::iterator it; + for (it = fMasterList.begin(); it != fMasterList.end(); it++) { + delete(*it); + } + fMasterList.clear(); + fSocket.Close(); + SocketAPIEnd(); } int JackNetMasterManager::SetSyncCallback(jack_transport_state_t state, jack_position_t* pos, void* arg) diff --git a/common/JackNetManager.h b/common/JackNetManager.h index 8bd4a2e4..7f7facff 100644 --- a/common/JackNetManager.h +++ b/common/JackNetManager.h @@ -96,7 +96,7 @@ namespace Jack private: - static void ShutDown(void* arg); + static void SetShutDown(void* arg); static int SetSyncCallback(jack_transport_state_t state, jack_position_t* pos, void* arg); static void* NetManagerThread(void* arg); @@ -116,6 +116,7 @@ namespace Jack int KillMaster(session_params_t* params); int SyncCallback(jack_transport_state_t state, jack_position_t* pos); int CountIO(int flags); + void ShutDown(); public: diff --git a/windows/JackRouter/JackRouter.cpp b/windows/JackRouter/JackRouter.cpp index 23e7a0c6..61d9e56c 100644 --- a/windows/JackRouter/JackRouter.cpp +++ b/windows/JackRouter/JackRouter.cpp @@ -69,7 +69,7 @@ static const double twoRaisedTo32Reciprocal = 1. / twoRaisedTo32; using namespace std;
-#define JACK_LOG 1
+//#define JACK_LOG 1
#ifdef JACK_LOG
#include <fstream>
@@ -146,10 +146,8 @@ HRESULT _stdcall DllUnregisterServer() }
// Globals
-
list<pair<string, string> > JackRouter::fConnections;
-
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
JackRouter::JackRouter (LPUNKNOWN pUnk, HRESULT *phr)
@@ -206,7 +204,6 @@ JackRouter::JackRouter() : AsioDriver() fAutoConnectOut = get_private_profile_int("AUTO_CONNECT", "output", 1, confPath.c_str());
fFloatSample = get_private_profile_int("IO", "float-sample", 0, confPath.c_str());
-
fAliasSystem = get_private_profile_int("AUTO_CONNECT", "alias", 0, confPath.c_str());
FreeLibrary(handle);
|