diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index 43b50b3e..9b9519ff 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -107,7 +107,6 @@ void JackEngine::ShutDown() } } - void JackEngine::NotifyQuit() { fChannel.NotifyQuit(); @@ -128,9 +127,9 @@ int JackEngine::AllocateRefnum() return -1; } -void JackEngine::ReleaseRefnum(int ref) +void JackEngine::ReleaseRefnum(int refnum) { - fClientTable[ref] = NULL; + fClientTable[refnum] = NULL; if (fEngineControl->fTemporary) { int i; @@ -140,7 +139,7 @@ void JackEngine::ReleaseRefnum(int ref) } } if (i == CLIENT_NUM) { - // last client and temporay case: quit the server + // Last client and temporay case: quit the server jack_log("JackEngine::ReleaseRefnum server quit"); fEngineControl->fTemporary = false; throw JackTemporaryException(); @@ -155,10 +154,10 @@ void JackEngine::ReleaseRefnum(int ref) void JackEngine::ProcessNext(jack_time_t cur_cycle_begin) { fLastSwitchUsecs = cur_cycle_begin; - if (fGraphManager->RunNextGraph()) { // True if the graph actually switched to a new state + if (fGraphManager->RunNextGraph()) { // True if the graph actually switched to a new state fChannel.Notify(ALL_CLIENTS, kGraphOrderCallback, 0); } - fSignal.Signal(); // Signal for threads waiting for next cycle + fSignal.Signal(); // Signal for threads waiting for next cycle } void JackEngine::ProcessCurrent(jack_time_t cur_cycle_begin) @@ -842,6 +841,17 @@ int JackEngine::ClientDeactivate(int refnum) } } +void JackEngine::ClientKill(int refnum) +{ + jack_log("JackEngine::ClientKill ref = %ld", refnum); + if (ClientDeactivate(refnum) < 0) { + jack_error("JackServer::ClientKill ref = %ld cannot be removed from the graph !!", refnum); + } + if (ClientExternalClose(refnum) < 0) { + jack_error("JackServer::ClientKill ref = %ld cannot be closed", refnum); + } +} + //----------------- // Port management //----------------- diff --git a/common/JackEngine.h b/common/JackEngine.h index ebd3eb1b..023063ca 100644 --- a/common/JackEngine.h +++ b/common/JackEngine.h @@ -74,7 +74,7 @@ class SERVER_EXPORT JackEngine : public JackLockAble bool GenerateUniqueName(char* name); int AllocateRefnum(); - void ReleaseRefnum(int ref); + void ReleaseRefnum(int refnum); int ClientNotify(JackClientInterface* client, int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); @@ -106,6 +106,7 @@ class SERVER_EXPORT JackEngine : public JackLockAble // Client management int ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status); + int ClientExternalOpen(const char* name, int pid, int uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager); int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait); @@ -114,6 +115,8 @@ class SERVER_EXPORT JackEngine : public JackLockAble int ClientActivate(int refnum, bool is_real_time); int ClientDeactivate(int refnum); + + void ClientKill(int refnum); int GetClientPID(const char* name); int GetClientRefNum(const char* name); diff --git a/common/JackLockedEngine.h b/common/JackLockedEngine.h index a1dc807e..bbdf2c29 100644 --- a/common/JackLockedEngine.h +++ b/common/JackLockedEngine.h @@ -164,6 +164,13 @@ class SERVER_EXPORT JackLockedEngine return (fEngine.CheckClient(refnum)) ? fEngine.ClientDeactivate(refnum) : -1; CATCH_EXCEPTION_RETURN } + void ClientKill(int refnum) + { + TRY_CALL + JackLock lock(&fEngine); + fEngine.ClientKill(refnum); + CATCH_EXCEPTION + } // Internal client management int GetInternalClientName(int int_ref, char* name_res) diff --git a/common/JackServer.cpp b/common/JackServer.cpp index 419ba3fe..8b1829ef 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -53,8 +53,7 @@ JackServer::JackServer(bool sync, bool temporary, int timeout, bool rt, int prio // regular freewheel driver because the freewheel driver needs to run in // threaded mode when freewheel mode is active and needs to run as a slave // when freewheel mode isn't active. - JackFreewheelDriver *freewheelDriver = - new JackFreewheelDriver(fEngine, GetSynchroTable()); + JackFreewheelDriver* freewheelDriver = new JackFreewheelDriver(fEngine, GetSynchroTable()); fThreadedFreewheelDriver = new JackThreadedDriver(freewheelDriver); fFreewheelDriver = freewheelDriver; @@ -299,17 +298,6 @@ void JackServer::Notify(int refnum, int notify, int value) } } -void JackServer::ClientKill(int refnum) -{ - jack_log("JackServer::ClientKill ref = %ld", refnum); - if (fEngine->ClientDeactivate(refnum) < 0) { - jack_error("JackServer::ClientKill ref = %ld cannot be removed from the graph !!", refnum); - } - if (fEngine->ClientExternalClose(refnum) < 0) { - jack_error("JackServer::ClientKill ref = %ld cannot be closed", refnum); - } -} - //---------------------- // Backend management //---------------------- diff --git a/common/JackServer.h b/common/JackServer.h index 04032721..91fcd85b 100644 --- a/common/JackServer.h +++ b/common/JackServer.h @@ -82,8 +82,7 @@ class SERVER_EXPORT JackServer int SetFreewheel(bool onoff); int InternalClientLoad1(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int uuid, int* status); int InternalClientLoad2(const char* client_name, const char* so_name, const JSList * parameters, int options, int* int_ref, int uuid, int* status); - void ClientKill(int refnum); - + // Transport management int ReleaseTimebase(int refnum); int SetTimebaseCallback(int refnum, int conditional); diff --git a/posix/JackSocketServerChannel.cpp b/posix/JackSocketServerChannel.cpp index dcc1aa5f..eccb5ff0 100644 --- a/posix/JackSocketServerChannel.cpp +++ b/posix/JackSocketServerChannel.cpp @@ -170,13 +170,13 @@ void JackSocketServerChannel::ClientKill(int fd) int refnum = elem.first; assert(socket); + jack_log("JackSocketServerChannel::ClientKill ref = %d fd = %d", refnum, fd); if (refnum == -1) { // Should never happen... correspond to a client that started the socket but never opened... jack_log("Client was not opened : probably correspond to server_check"); } else { - fServer->ClientKill(refnum); + fServer->GetEngine()->ClientKill(refnum); } - - jack_log("JackSocketServerChannel::ClientKill ref = %d fd = %d", refnum, fd); + fSocketTable.erase(fd); socket->Close(); delete socket; diff --git a/windows/JackWinNamedPipeServerChannel.cpp b/windows/JackWinNamedPipeServerChannel.cpp index af381c96..bdd8fcb4 100644 --- a/windows/JackWinNamedPipeServerChannel.cpp +++ b/windows/JackWinNamedPipeServerChannel.cpp @@ -136,7 +136,7 @@ void JackClientPipeThread::ClientKill() } else if (fRefNum == 0) { // Correspond to a still not opened client. jack_log("Kill a not opened client %x", this); } else { - fServer->ClientKill(fRefNum); + fServer->GetEngine()->ClientKill(fRefNum); } Close(); diff --git a/windows/portaudio/JackPortAudioDriver.cpp b/windows/portaudio/JackPortAudioDriver.cpp index f0f5b58a..fa83508f 100644 --- a/windows/portaudio/JackPortAudioDriver.cpp +++ b/windows/portaudio/JackPortAudioDriver.cpp @@ -324,7 +324,7 @@ int JackPortAudioDriver::SetBufferSize(jack_nframes_t buffer_size) goto error; } - // It seems that some ASIO drivers (like ASIO4All needs this to restart correctly); + // It seems that some ASIO drivers (like ASIO4All) needs this to restart correctly; delete fPaDevices; fPaDevices = new PortAudioDevices();