diff --git a/common/JackClient.cpp b/common/JackClient.cpp index 834d541f..ea58d85b 100644 --- a/common/JackClient.cpp +++ b/common/JackClient.cpp @@ -88,13 +88,15 @@ JackClient::JackClient(JackSynchro* table):fThread(this) JackClient::~JackClient() {} -void JackClient::ShutDown() +void JackClient::ShutDown(const char* message) { jack_log("JackClient::ShutDown"); + // If "fInfoShutdown" callback, then call it if (fInfoShutdown) { - fInfoShutdown(JackFailure, "JACK server has been closed", fInfoShutdownArg); + fInfoShutdown(JackFailure, message, fInfoShutdownArg); fInfoShutdown = NULL; + // Otherwise possibly call the normal "fShutdown" } else if (fShutdown) { fShutdown(fShutdownArg); fShutdown = NULL; @@ -296,10 +298,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, case kShutDownCallback: jack_log("JackClient::kShutDownCallback"); - if (fInfoShutdown) { - fInfoShutdown((jack_status_t)value1, message, fInfoShutdownArg); - fInfoShutdown = NULL; - } + ShutDown(message); break; case kSessionCallback: @@ -660,7 +659,7 @@ inline void JackClient::Error() fThread.DropSelfRealTime(); GetClientControl()->fActive = false; fChannel->ClientDeactivate(GetClientControl()->fRefNum, &result); - ShutDown(); + ShutDown(JACK_SERVER_FAILURE); fThread.Terminate(); } diff --git a/common/JackClient.h b/common/JackClient.h index 0c977d06..af187362 100644 --- a/common/JackClient.h +++ b/common/JackClient.h @@ -143,7 +143,7 @@ class SERVER_EXPORT JackClient : public JackClientInterface, public JackRunnable virtual int SetBufferSize(jack_nframes_t buffer_size); virtual int SetFreeWheel(int onoff); virtual int ComputeTotalLatencies(); - virtual void ShutDown(); + virtual void ShutDown(const char* message); virtual jack_native_thread_t GetThreadID(); // Port management diff --git a/common/JackConstants.h b/common/JackConstants.h index 51c1ab3f..8ec8a8f7 100644 --- a/common/JackConstants.h +++ b/common/JackConstants.h @@ -75,6 +75,8 @@ #define FREEWHEEL_DRIVER_TIMEOUT 10 // in sec #define DRIVER_TIMEOUT_FACTOR 10 +#define JACK_SERVER_FAILURE "JACK server has been closed" + #define NO_PORT 0xFFFE diff --git a/common/JackDebugClient.cpp b/common/JackDebugClient.cpp index 27e07dc5..d9bc63cc 100644 --- a/common/JackDebugClient.cpp +++ b/common/JackDebugClient.cpp @@ -363,10 +363,10 @@ ShutDown is called: (Not needed since the synch object used (Sema of Fifo will fails when server quits... see ShutDown)) */ -void JackDebugClient::ShutDown() +void JackDebugClient::ShutDown(const char* message) { CheckClient("ShutDown"); - fClient->ShutDown(); + fClient->ShutDown(message); } //--------------------- diff --git a/common/JackDebugClient.h b/common/JackDebugClient.h index fa50fc31..62790994 100644 --- a/common/JackDebugClient.h +++ b/common/JackDebugClient.h @@ -84,7 +84,7 @@ class JackDebugClient : public JackClient int SetBufferSize(jack_nframes_t buffer_size); int SetFreeWheel(int onoff); int ComputeTotalLatencies(); - void ShutDown(); + void ShutDown(const char* message); jack_native_thread_t GetThreadID(); // Port management diff --git a/common/JackInternalClient.cpp b/common/JackInternalClient.cpp index 5982ed36..16a87fda 100644 --- a/common/JackInternalClient.cpp +++ b/common/JackInternalClient.cpp @@ -110,10 +110,10 @@ error: return -1; } -void JackInternalClient::ShutDown() +void JackInternalClient::ShutDown(const char* message) { jack_log("JackInternalClient::ShutDown"); - JackClient::ShutDown(); + JackClient::ShutDown(message); } JackGraphManager* JackInternalClient::GetGraphManager() const diff --git a/common/JackInternalClient.h b/common/JackInternalClient.h index e47066cf..2c2b6aad 100644 --- a/common/JackInternalClient.h +++ b/common/JackInternalClient.h @@ -47,7 +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(); + void ShutDown(const char* message); JackGraphManager* GetGraphManager() const; JackEngineControl* GetEngineControl() const; diff --git a/common/JackLibClient.cpp b/common/JackLibClient.cpp index be2e5be0..a02175dd 100644 --- a/common/JackLibClient.cpp +++ b/common/JackLibClient.cpp @@ -62,11 +62,11 @@ ShutDown is called: (Not needed since the synch object used (Sema of Fifo will fails when server quits... see ShutDown)) */ -void JackLibClient::ShutDown() +void JackLibClient::ShutDown(const char* message) { jack_log("JackLibClient::ShutDown"); JackGlobals::fServerRunning = false; - JackClient::ShutDown(); + JackClient::ShutDown(message); } JackLibClient::JackLibClient(JackSynchro* table): JackClient(table) diff --git a/common/JackLibClient.h b/common/JackLibClient.h index 5e78b6f8..0486fc8e 100644 --- a/common/JackLibClient.h +++ b/common/JackLibClient.h @@ -45,7 +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(); + void ShutDown(const char* message); int ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); diff --git a/common/JackServer.cpp b/common/JackServer.cpp index ab15a603..d1f57507 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -160,17 +160,13 @@ int JackServer::Start() int JackServer::Stop() { jack_log("JackServer::Stop"); + int res = (fFreewheel) ? fThreadedFreewheelDriver->Stop() : fAudioDriver->Stop(); fEngine->NotifyQuit(); fRequestChannel.Stop(); + fEngine->NotifyFailure(JackFailure, JACK_SERVER_FAILURE); - fEngine->NotifyFailure(JackFailure, "JACK server has been closed"); - - if (fFreewheel) { - return fThreadedFreewheelDriver->Stop(); - } else { - return fAudioDriver->Stop(); - } + return res; } bool JackServer::IsRunning() diff --git a/posix/JackSocketClientChannel.cpp b/posix/JackSocketClientChannel.cpp index 08dbaa76..bb3f9c69 100644 --- a/posix/JackSocketClientChannel.cpp +++ b/posix/JackSocketClientChannel.cpp @@ -146,7 +146,7 @@ bool JackSocketClientChannel::Execute() error: fNotificationSocket->Close(); - fClient->ShutDown(); + fClient->ShutDown(JACK_SERVER_FAILURE); return false; } diff --git a/windows/JackWinNamedPipeClientChannel.cpp b/windows/JackWinNamedPipeClientChannel.cpp index 74b64339..ec327976 100644 --- a/windows/JackWinNamedPipeClientChannel.cpp +++ b/windows/JackWinNamedPipeClientChannel.cpp @@ -150,7 +150,7 @@ error: // Close the pipes, server wont be able to create them otherwise. fNotificationListenPipe.Close(); fRequest->Close(); - fClient->ShutDown(); + fClient->ShutDown(JACK_SERVER_FAILURE); return false; }