From d8a6bc4de63615cf9e9ec74b52cb8def124d8915 Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Fri, 25 Jan 2013 09:12:05 +0100 Subject: [PATCH] Cleanup. --- common/JackEngine.cpp | 2 +- common/JackServer.cpp | 81 +++++++++++++++++++++++++------------------ common/JackServer.h | 6 +++- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index aee66070..560fe98c 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -279,7 +279,7 @@ int JackEngine::ClientNotify(JackClientInterface* client, int refnum, const char } if (ret < 0) { - jack_error("NotifyClient fails name = %s notification = %ld val1 = %ld val2 = %ld", name, notify, value1, value2); + jack_error("ClientNotify fails name = %s notification = %ld val1 = %ld val2 = %ld", name, notify, value1, value2); } return ret; } diff --git a/common/JackServer.cpp b/common/JackServer.cpp index 7f7a5daf..ab15a603 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -37,6 +37,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. namespace Jack { +//---------------- +// Server control +//---------------- + JackServer::JackServer(bool sync, bool temporary, int timeout, bool rt, int priority, int port_max, bool verbose, jack_timer_type_t clock, const char* server_name) { if (rt) { @@ -144,6 +148,42 @@ int JackServer::Close() return 0; } +int JackServer::Start() +{ + jack_log("JackServer::Start"); + if (fAudioDriver->Start() < 0) { + return -1; + } + return fRequestChannel.Start(); +} + +int JackServer::Stop() +{ + jack_log("JackServer::Stop"); + + fEngine->NotifyQuit(); + fRequestChannel.Stop(); + + fEngine->NotifyFailure(JackFailure, "JACK server has been closed"); + + if (fFreewheel) { + return fThreadedFreewheelDriver->Stop(); + } else { + return fAudioDriver->Stop(); + } +} + +bool JackServer::IsRunning() +{ + jack_log("JackServer::IsRunning"); + assert(fAudioDriver); + return fAudioDriver->IsRunning(); +} + +//------------------ +// Internal clients +//------------------ + int JackServer::InternalClientLoad1(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int uuid, int* status) { JackLoadableInternalClient* client = new JackLoadableInternalClient1(JackServerGlobals::fInstance, GetSynchroTable(), objet_data); @@ -176,37 +216,9 @@ int JackServer::InternalClientLoadAux(JackLoadableInternalClient* client, const } } -int JackServer::Start() -{ - jack_log("JackServer::Start"); - if (fAudioDriver->Start() < 0) { - return -1; - } - return fRequestChannel.Start(); -} - -int JackServer::Stop() -{ - jack_log("JackServer::Stop"); - - fEngine->NotifyQuit(); - fRequestChannel.Stop(); - - fEngine->NotifyFailure(JackFailure, "JACK server has been closed"); - - if (fFreewheel) { - return fThreadedFreewheelDriver->Stop(); - } else { - return fAudioDriver->Stop(); - } -} - -bool JackServer::IsRunning() -{ - jack_log("JackServer::IsRunning"); - assert(fAudioDriver); - return fAudioDriver->IsRunning(); -} +//--------------------------- +// From request thread : API +//--------------------------- int JackServer::SetBufferSize(jack_nframes_t buffer_size) { @@ -284,7 +296,10 @@ int JackServer::SetFreewheel(bool onoff) } } +//--------------------------- // Coming from the RT thread +//--------------------------- + void JackServer::Notify(int refnum, int notify, int value) { switch (notify) { @@ -299,9 +314,9 @@ void JackServer::Notify(int refnum, int notify, int value) } } -//---------------------- +//-------------------- // Backend management -//---------------------- +//-------------------- JackDriverInfo* JackServer::AddSlave(jack_driver_desc_t* driver_desc, JSList* driver_params) { diff --git a/common/JackServer.h b/common/JackServer.h index 0dde5cfa..245b2d9f 100644 --- a/common/JackServer.h +++ b/common/JackServer.h @@ -67,19 +67,23 @@ class SERVER_EXPORT JackServer JackServer(bool sync, bool temporary, int timeout, bool rt, int priority, int port_max, bool verbose, jack_timer_type_t clock, const char* server_name); ~JackServer(); + // Server control int Open(jack_driver_desc_t* driver_desc, JSList* driver_params); int Close(); int Start(); int Stop(); + bool IsRunning(); // RT thread void Notify(int refnum, int notify, int value); - // Command thread : API + // From request thread : API int SetBufferSize(jack_nframes_t buffer_size); int SetFreewheel(bool onoff); + + // Internals clients 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);