21 #include "JackDebugClient.h"
22 #include "JackLibClient.h"
23 #include "JackChannel.h"
24 #include "JackLibGlobals.h"
25 #include "JackGlobals.h"
26 #include "JackCompilerDeps.h"
27 #include "JackTools.h"
28 #include "JackSystemDeps.h"
29 #include "JackServerLaunch.h"
39 jack_client_t * jack_client_new_aux (
const char *client_name,
40 jack_options_t options,
41 jack_status_t *status);
43 LIB_EXPORT jack_client_t * jack_client_open (
const char *client_name,
44 jack_options_t options,
45 jack_status_t *status, ...);
46 LIB_EXPORT
int jack_client_close (jack_client_t *client);
47 LIB_EXPORT
int jack_get_client_pid (
const char *name);
54 static jack_client_t * jack_client_open_aux (
const char *client_name,
55 jack_options_t options,
56 jack_status_t *status, va_list ap);
59 int JackLibGlobals::fClientCount = 0;
61 jack_client_t* jack_client_new_aux(
const char* client_name, jack_options_t options, jack_status_t* status)
64 jack_status_t my_status;
67 if (client_name == NULL) {
68 jack_error(
"jack_client_new called with a NULL client_name");
72 jack_log(
"jack_client_new %s", client_name);
76 *status = (jack_status_t)0;
79 if ((options & ~JackOpenOptions)) {
80 int my_status1 = *status | (JackFailure | JackInvalidOption);
81 *status = (jack_status_t)my_status1;
86 jack_varargs_init(&va);
88 JackLibGlobals::Init();
90 if (try_start_server(&va, options, status)) {
91 jack_error(
"jack server is not running or cannot be started");
92 JackLibGlobals::Destroy();
102 int res = client->Open(va.server_name, client_name, va.session_id, options, status);
105 JackLibGlobals::Destroy();
106 int my_status1 = (JackFailure | JackServerError);
107 *status = (jack_status_t)my_status1;
110 return (jack_client_t*)client;
114 static jack_client_t* jack_client_open_aux(
const char* client_name, jack_options_t options, jack_status_t* status, va_list ap)
117 jack_status_t my_status;
120 if (client_name == NULL) {
121 jack_error(
"jack_client_open called with a NULL client_name");
125 jack_log(
"jack_client_open %s", client_name);
129 *status = (jack_status_t)0;
132 if ((options & ~JackOpenOptions)) {
133 int my_status1 = *status | (JackFailure | JackInvalidOption);
134 *status = (jack_status_t)my_status1;
139 jack_varargs_parse(options, ap, &va);
141 JackLibGlobals::Init();
143 if (try_start_server(&va, options, status)) {
144 jack_error(
"jack server is not running or cannot be started");
145 JackLibGlobals::Destroy();
155 int res = client->Open(va.server_name, client_name, va.session_id, options, status);
158 JackLibGlobals::Destroy();
159 int my_status1 = (JackFailure | JackServerError);
160 *status = (jack_status_t)my_status1;
163 return (jack_client_t*)client;
167 LIB_EXPORT jack_client_t* jack_client_open(
const char* ext_client_name, jack_options_t options, jack_status_t* status, ...)
169 #ifdef __CLIENTDEBUG__
170 JackGlobals::CheckContext(
"jack_client_open");
173 assert(JackGlobals::fOpenMutex);
174 JackGlobals::fOpenMutex->Lock();
176 va_start(ap, status);
177 jack_client_t* res = jack_client_open_aux(ext_client_name, options, status, ap);
179 JackGlobals::fOpenMutex->Unlock();
181 }
catch(std::bad_alloc& e) {
190 LIB_EXPORT
int jack_client_close(jack_client_t* ext_client)
192 #ifdef __CLIENTDEBUG__
193 JackGlobals::CheckContext(
"jack_client_close");
195 assert(JackGlobals::fOpenMutex);
196 JackGlobals::fOpenMutex->Lock();
200 if (client == NULL) {
201 jack_error(
"jack_client_close called with a NULL client");
203 res = client->Close();
205 JackLibGlobals::Destroy();
206 jack_log(
"jack_client_close res = %d", res);
208 JackGlobals::fOpenMutex->Unlock();
212 LIB_EXPORT
int jack_get_client_pid(
const char *name)
214 jack_error(
"jack_get_client_pid : not implemented on library side");