Browse Source

Correct ShutDown in JackInternalClient and JackLibClient.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4731 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.9.5
sletz 13 years ago
parent
commit
5e8a775049
10 changed files with 71 additions and 48 deletions
  1. +5
    -0
      ChangeLog
  2. +13
    -21
      common/JackClient.cpp
  3. +6
    -2
      common/JackEngine.cpp
  4. +10
    -3
      common/JackInternalClient.cpp
  5. +1
    -0
      common/JackInternalClient.h
  6. +14
    -0
      common/JackLibClient.cpp
  7. +1
    -0
      common/JackLibClient.h
  8. +18
    -17
      common/JackNetManager.cpp
  9. +2
    -1
      common/JackNetManager.h
  10. +1
    -4
      windows/JackRouter/JackRouter.cpp

+ 5
- 0
ChangeLog View File

@@ -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.


+ 13
- 21
common/JackClient.cpp View File

@@ -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
//----------------------


+ 6
- 2
common/JackEngine.cpp View File

@@ -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);
}



+ 10
- 3
common/JackInternalClient.cpp View File

@@ -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)


+ 1
- 0
common/JackInternalClient.h View File

@@ -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;


+ 14
- 0
common/JackLibClient.cpp View File

@@ -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);


+ 1
- 0
common/JackLibClient.h View File

@@ -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);



+ 18
- 17
common/JackNetManager.cpp View File

@@ -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)


+ 2
- 1
common/JackNetManager.h View File

@@ -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:



+ 1
- 4
windows/JackRouter/JackRouter.cpp View File

@@ -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);


Loading…
Cancel
Save