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"
30 #include "JackMetadata.h"
40 jack_client_t * jack_client_new_aux (
const char *client_name,
41 jack_options_t options,
42 jack_status_t *status);
45 jack_options_t options,
46 jack_status_t *status, ...);
50 LIB_EXPORT
int jack_set_property(jack_client_t*, jack_uuid_t subject,
const char* key,
const char* value,
const char* type);
51 LIB_EXPORT
int jack_get_property(jack_uuid_t subject,
const char* key,
char** value,
char** type);
55 LIB_EXPORT
int jack_remove_property(jack_client_t* client, jack_uuid_t subject,
const char* key);
64 static jack_client_t * jack_client_open_aux (
const char *client_name,
65 jack_options_t options,
66 jack_status_t *status, va_list ap);
69 int JackLibGlobals::fClientCount = 0;
71 jack_client_t* jack_client_new_aux(
const char* client_name, jack_options_t options, jack_status_t* status)
74 jack_status_t my_status;
77 if (client_name == NULL) {
78 jack_error(
"jack_client_new called with a NULL client_name");
82 jack_log(
"jack_client_new %s", client_name);
86 *status = (jack_status_t)0;
89 if ((options & ~JackOpenOptions)) {
90 int my_status1 = *status | (JackFailure | JackInvalidOption);
91 *status = (jack_status_t)my_status1;
96 jack_varargs_init(&va);
98 JackLibGlobals::Init();
100 if (try_start_server(&va, options, status)) {
101 jack_error(
"jack server is not running or cannot be started");
102 JackLibGlobals::Destroy();
112 int res = client->Open(va.server_name, client_name, va.session_id, options, status);
115 JackLibGlobals::Destroy();
116 int my_status1 = (JackFailure | JackServerError);
117 *status = (jack_status_t)my_status1;
120 return (jack_client_t*)client;
124 static jack_client_t* jack_client_open_aux(
const char* client_name, jack_options_t options, jack_status_t* status, va_list ap)
127 jack_status_t my_status;
130 if (client_name == NULL) {
131 jack_error(
"jack_client_open called with a NULL client_name");
135 jack_log(
"jack_client_open %s", client_name);
139 *status = (jack_status_t)0;
142 if ((options & ~JackOpenOptions)) {
143 int my_status1 = *status | (JackFailure | JackInvalidOption);
144 *status = (jack_status_t)my_status1;
149 jack_varargs_parse(options, ap, &va);
151 JackLibGlobals::Init();
153 if (try_start_server(&va, options, status)) {
154 jack_error(
"jack server is not running or cannot be started");
155 JackLibGlobals::Destroy();
165 int res = client->Open(va.server_name, client_name, va.session_id, options, status);
168 JackLibGlobals::Destroy();
169 int my_status1 = (JackFailure | JackServerError);
170 *status = (jack_status_t)my_status1;
173 return (jack_client_t*)client;
177 LIB_EXPORT jack_client_t*
jack_client_open(
const char* ext_client_name, jack_options_t options, jack_status_t* status, ...)
179 JackGlobals::CheckContext(
"jack_client_open");
182 assert(JackGlobals::fOpenMutex);
183 JackGlobals::fOpenMutex->Lock();
185 va_start(ap, status);
186 jack_client_t* res = jack_client_open_aux(ext_client_name, options, status, ap);
188 JackGlobals::fOpenMutex->Unlock();
190 }
catch (std::bad_alloc& e) {
201 JackGlobals::CheckContext(
"jack_client_close");
203 assert(JackGlobals::fOpenMutex);
204 JackGlobals::fOpenMutex->Lock();
208 if (client == NULL) {
209 jack_error(
"jack_client_close called with a NULL client");
211 res = client->Close();
213 JackLibGlobals::Destroy();
214 jack_log(
"jack_client_close res = %d", res);
216 JackGlobals::fOpenMutex->Unlock();
222 jack_error(
"jack_get_client_pid : not implemented on library side");
228 LIB_EXPORT
int jack_set_property(jack_client_t* ext_client, jack_uuid_t subject,
const char* key,
const char* value,
const char* type)
230 JackGlobals::CheckContext(
"jack_set_property");
233 jack_log(
"jack_set_property ext_client %x client %x ", ext_client, client);
234 if (client == NULL) {
235 jack_error(
"jack_set_property called with a NULL client");
239 return (metadata ? metadata->SetProperty(client, subject, key, value, type) : -1);
243 LIB_EXPORT
int jack_get_property(jack_uuid_t subject,
const char* key,
char** value,
char** type)
245 JackGlobals::CheckContext(
"jack_get_property");
248 return (metadata ? metadata->GetProperty(subject, key, value, type) : -1);
253 JackGlobals::CheckContext(
"jack_free_description");
257 metadata->FreeDescription(desc, free_actual_description_too);
262 JackGlobals::CheckContext(
"jack_get_properties");
265 return (metadata ? metadata->GetProperties(subject, desc) : -1);
270 JackGlobals::CheckContext(
"jack_get_all_properties");
273 return (metadata ? metadata->GetAllProperties(descriptions) : -1);
278 JackGlobals::CheckContext(
"jack_remove_property");
281 jack_log(
"jack_remove_property ext_client %x client %x ", ext_client, client);
282 if (client == NULL) {
283 jack_error(
"jack_remove_property called with a NULL client");
287 return (metadata ? metadata->RemoveProperty(client, subject, key) : -1);
293 JackGlobals::CheckContext(
"jack_remove_properties");
296 jack_log(
"jack_remove_properties ext_client %x client %x ", ext_client, client);
297 if (client == NULL) {
298 jack_error(
"jack_remove_properties called with a NULL client");
302 return (metadata ? metadata->RemoveProperties(client, subject) : -1);
308 JackGlobals::CheckContext(
"jack_remove_all_properties");
311 jack_log(
"jack_remove_all_properties ext_client %x client %x ", ext_client, client);
312 if (client == NULL) {
313 jack_error(
"jack_remove_all_properties called with a NULL client");
317 return (metadata ? metadata->RemoveAllProperties(client) : -1);
323 JackGlobals::CheckContext(
"jack_set_property_change_callback");
326 jack_log(
"jack_set_property_change_callback ext_client %x client %x ", ext_client, client);
327 if (client == NULL) {
328 jack_error(
"jack_set_property_change_callback called with a NULL client");
331 return client->SetPropertyChangeCallback(callback, arg);
SERVER_EXPORT void jack_error(const char *fmt,...)
LIB_EXPORT jack_client_t * jack_client_open(const char *client_name, jack_options_t options, jack_status_t *status,...)
Global library static structure: singleton kind of pattern.
LIB_EXPORT int jack_get_client_pid(const char *name)
A "decorator" debug client to validate API use.
SERVER_EXPORT void jack_log(const char *fmt,...)
The base class for clients: share part of the implementation for JackInternalClient and JackLibClient...
Client on the library side.
LIB_EXPORT int jack_client_close(jack_client_t *client)