Jack2  1.9.10
JackAPI.cpp
1 /*
2 Copyright (C) 2001-2003 Paul Davis
3 Copyright (C) 2004-2008 Grame
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 */
20 
21 #include "JackClient.h"
22 #include "JackError.h"
23 #include "JackGraphManager.h"
24 #include "JackEngineControl.h"
25 #include "JackClientControl.h"
26 #include "JackGlobals.h"
27 #include "JackTime.h"
28 #include "JackPortType.h"
29 #include "JackMetadata.h"
30 #include <math.h>
31 
32 using namespace Jack;
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
39  typedef void (*print_function)(const char*);
40  typedef void *(*thread_routine)(void*);
41 
42  LIB_EXPORT const char* JACK_METADATA_PRETTY_NAME = "http://jackaudio.org/metadata/pretty-name";
43  LIB_EXPORT const char* JACK_METADATA_HARDWARE = "http://jackaudio.org/metadata/hardware";
44  LIB_EXPORT const char* JACK_METADATA_CONNECTED = "http://jackaudio.org/metadata/connected";
45  LIB_EXPORT const char* JACK_METADATA_PORT_GROUP = "http://jackaudio.org/metadata/port-group";
46  LIB_EXPORT const char* JACK_METADATA_ICON_SMALL = "http://jackaudio.org/metadata/icon-small";
47  LIB_EXPORT const char* JACK_METADATA_ICON_LARGE = "http://jackaudio.org/metadata/icon-large";
48 
49  LIB_EXPORT
50  void
51  jack_get_version(
52  int *major_ptr,
53  int *minor_ptr,
54  int *micro_ptr,
55  int *proto_ptr);
56 
57  LIB_EXPORT
58  const char*
59  jack_get_version_string();
60 
61  jack_client_t * jack_client_new_aux(const char* client_name,
62  jack_options_t options,
63  jack_status_t *status);
64 
65  LIB_EXPORT jack_client_t * jack_client_open(const char* client_name,
66  jack_options_t options,
67  jack_status_t *status, ...);
68  LIB_EXPORT jack_client_t * jack_client_new(const char* client_name);
69  LIB_EXPORT int jack_client_name_size(void);
70  LIB_EXPORT char* jack_get_client_name(jack_client_t *client);
71  LIB_EXPORT int jack_internal_client_new(const char* client_name,
72  const char* load_name,
73  const char* load_init);
74  LIB_EXPORT void jack_internal_client_close(const char* client_name);
75  LIB_EXPORT int jack_is_realtime(jack_client_t *client);
76  LIB_EXPORT void jack_on_shutdown(jack_client_t *client,
77  JackShutdownCallback shutdown_callback, void *arg);
78  LIB_EXPORT void jack_on_info_shutdown(jack_client_t *client,
79  JackInfoShutdownCallback shutdown_callback, void *arg);
80  LIB_EXPORT int jack_set_process_callback(jack_client_t *client,
81  JackProcessCallback process_callback,
82  void *arg);
83  LIB_EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status);
84 
85  // new
86  LIB_EXPORT jack_nframes_t jack_cycle_wait(jack_client_t*);
87  LIB_EXPORT void jack_cycle_signal(jack_client_t*, int status);
88  LIB_EXPORT int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg);
89 
90  LIB_EXPORT int jack_set_thread_init_callback(jack_client_t *client,
91  JackThreadInitCallback thread_init_callback,
92  void *arg);
93  LIB_EXPORT int jack_set_freewheel_callback(jack_client_t *client,
94  JackFreewheelCallback freewheel_callback,
95  void *arg);
96  LIB_EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
97  LIB_EXPORT int jack_set_buffer_size(jack_client_t *client, jack_nframes_t nframes);
98  LIB_EXPORT int jack_set_buffer_size_callback(jack_client_t *client,
99  JackBufferSizeCallback bufsize_callback,
100  void *arg);
101  LIB_EXPORT int jack_set_sample_rate_callback(jack_client_t *client,
102  JackSampleRateCallback srate_callback,
103  void *arg);
104  LIB_EXPORT int jack_set_client_registration_callback(jack_client_t *,
105  JackClientRegistrationCallback
106  registration_callback, void *arg);
107  LIB_EXPORT int jack_set_port_registration_callback(jack_client_t *,
108  JackPortRegistrationCallback
109  registration_callback, void *arg);
110  LIB_EXPORT int jack_set_port_connect_callback(jack_client_t *,
111  JackPortConnectCallback
112  connect_callback, void *arg);
113  LIB_EXPORT int jack_set_port_rename_callback(jack_client_t *,
114  JackPortRenameCallback
115  rename_callback, void *arg);
116  LIB_EXPORT int jack_set_graph_order_callback(jack_client_t *,
117  JackGraphOrderCallback graph_callback,
118  void *);
119  LIB_EXPORT int jack_set_xrun_callback(jack_client_t *,
120  JackXRunCallback xrun_callback, void *arg);
121  LIB_EXPORT int jack_set_latency_callback(jack_client_t *client,
122  JackLatencyCallback latency_callback, void *arg);
123 
124  LIB_EXPORT int jack_activate(jack_client_t *client);
125  LIB_EXPORT int jack_deactivate(jack_client_t *client);
126  LIB_EXPORT jack_port_t * jack_port_register(jack_client_t *client,
127  const char* port_name,
128  const char* port_type,
129  unsigned long flags,
130  unsigned long buffer_size);
131  LIB_EXPORT int jack_port_unregister(jack_client_t *, jack_port_t *);
132  LIB_EXPORT void * jack_port_get_buffer(jack_port_t *, jack_nframes_t);
133  LIB_EXPORT jack_uuid_t jack_port_uuid(const jack_port_t*);
134  LIB_EXPORT const char* jack_port_name(const jack_port_t *port);
135  LIB_EXPORT const char* jack_port_short_name(const jack_port_t *port);
136  LIB_EXPORT int jack_port_flags(const jack_port_t *port);
137  LIB_EXPORT const char* jack_port_type(const jack_port_t *port);
138  LIB_EXPORT jack_port_type_id_t jack_port_type_id(const jack_port_t *port);
139  LIB_EXPORT int jack_port_is_mine(const jack_client_t *, const jack_port_t *port);
140  LIB_EXPORT int jack_port_connected(const jack_port_t *port);
141  LIB_EXPORT int jack_port_connected_to(const jack_port_t *port,
142  const char* port_name);
143  LIB_EXPORT const char* * jack_port_get_connections(const jack_port_t *port);
144  LIB_EXPORT const char* * jack_port_get_all_connections(const jack_client_t *client,
145  const jack_port_t *port);
146  LIB_EXPORT int jack_port_tie(jack_port_t *src, jack_port_t *dst);
147  LIB_EXPORT int jack_port_untie(jack_port_t *port);
148 
149  // Old latency API
150  LIB_EXPORT jack_nframes_t jack_port_get_latency(jack_port_t *port);
151  LIB_EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t *,
152  jack_port_t *port);
153  LIB_EXPORT void jack_port_set_latency(jack_port_t *, jack_nframes_t);
154  LIB_EXPORT int jack_recompute_total_latency(jack_client_t*, jack_port_t* port);
155 
156  // New latency API
157  LIB_EXPORT void jack_port_get_latency_range(jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range);
158  LIB_EXPORT void jack_port_set_latency_range(jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range);
159  LIB_EXPORT int jack_recompute_total_latencies(jack_client_t*);
160 
161  LIB_EXPORT int jack_port_set_name(jack_port_t *port, const char* port_name);
162  LIB_EXPORT int jack_port_set_alias(jack_port_t *port, const char* alias);
163  LIB_EXPORT int jack_port_unset_alias(jack_port_t *port, const char* alias);
164  LIB_EXPORT int jack_port_get_aliases(const jack_port_t *port, char* const aliases[2]);
165  LIB_EXPORT int jack_port_request_monitor(jack_port_t *port, int onoff);
166  LIB_EXPORT int jack_port_request_monitor_by_name(jack_client_t *client,
167  const char* port_name, int onoff);
168  LIB_EXPORT int jack_port_ensure_monitor(jack_port_t *port, int onoff);
169  LIB_EXPORT int jack_port_monitoring_input(jack_port_t *port);
170  LIB_EXPORT int jack_connect(jack_client_t *,
171  const char* source_port,
172  const char* destination_port);
173  LIB_EXPORT int jack_disconnect(jack_client_t *,
174  const char* source_port,
175  const char* destination_port);
176  LIB_EXPORT int jack_port_disconnect(jack_client_t *, jack_port_t *);
177  LIB_EXPORT int jack_port_name_size(void);
178  LIB_EXPORT int jack_port_type_size(void);
179  LIB_EXPORT size_t jack_port_type_get_buffer_size(jack_client_t *client, const char* port_type);
180  LIB_EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t *);
181  LIB_EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t *);
182  LIB_EXPORT const char* * jack_get_ports(jack_client_t *,
183  const char* port_name_pattern,
184  const char* type_name_pattern,
185  unsigned long flags);
186  LIB_EXPORT jack_port_t * jack_port_by_name(jack_client_t *, const char* port_name);
187  LIB_EXPORT jack_port_t * jack_port_by_id(jack_client_t *client,
188  jack_port_id_t port_id);
189  LIB_EXPORT int jack_engine_takeover_timebase(jack_client_t *);
190  LIB_EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t *);
191  LIB_EXPORT jack_time_t jack_get_time();
192  LIB_EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t usecs);
193  LIB_EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames);
194  LIB_EXPORT jack_nframes_t jack_frame_time(const jack_client_t *);
195  LIB_EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t *client);
196  LIB_EXPORT int jack_get_cycle_times(const jack_client_t *client,
197  jack_nframes_t *current_frames,
198  jack_time_t *current_usecs,
199  jack_time_t *next_usecs,
200  float *period_usecs);
201  LIB_EXPORT float jack_cpu_load(jack_client_t *client);
202  LIB_EXPORT jack_native_thread_t jack_client_thread_id(jack_client_t *);
203  LIB_EXPORT void jack_set_error_function(print_function);
204  LIB_EXPORT void jack_set_info_function(print_function);
205 
206  LIB_EXPORT float jack_get_max_delayed_usecs(jack_client_t *client);
207  LIB_EXPORT float jack_get_xrun_delayed_usecs(jack_client_t *client);
208  LIB_EXPORT void jack_reset_max_delayed_usecs(jack_client_t *client);
209 
210  LIB_EXPORT int jack_release_timebase(jack_client_t *client);
211  LIB_EXPORT int jack_set_sync_callback(jack_client_t *client,
212  JackSyncCallback sync_callback,
213  void *arg);
214  LIB_EXPORT int jack_set_sync_timeout(jack_client_t *client,
215  jack_time_t timeout);
216  LIB_EXPORT int jack_set_timebase_callback(jack_client_t *client,
217  int conditional,
218  JackTimebaseCallback timebase_callback,
219  void *arg);
220  LIB_EXPORT int jack_transport_locate(jack_client_t *client,
221  jack_nframes_t frame);
222  LIB_EXPORT jack_transport_state_t jack_transport_query(const jack_client_t *client,
223  jack_position_t *pos);
224  LIB_EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t *client);
225  LIB_EXPORT int jack_transport_reposition(jack_client_t *client,
226  const jack_position_t *pos);
227  LIB_EXPORT void jack_transport_start(jack_client_t *client);
228  LIB_EXPORT void jack_transport_stop(jack_client_t *client);
229  LIB_EXPORT void jack_get_transport_info(jack_client_t *client,
230  jack_transport_info_t *tinfo);
231  LIB_EXPORT void jack_set_transport_info(jack_client_t *client,
232  jack_transport_info_t *tinfo);
233 
234  LIB_EXPORT int jack_client_real_time_priority(jack_client_t*);
235  LIB_EXPORT int jack_client_max_real_time_priority(jack_client_t*);
236  LIB_EXPORT int jack_acquire_real_time_scheduling(jack_native_thread_t thread, int priority);
237  LIB_EXPORT int jack_client_create_thread(jack_client_t* client,
238  jack_native_thread_t *thread,
239  int priority,
240  int realtime, // boolean
241  thread_routine routine,
242  void *arg);
243  LIB_EXPORT int jack_drop_real_time_scheduling(jack_native_thread_t thread);
244 
245  LIB_EXPORT int jack_client_stop_thread(jack_client_t* client, jack_native_thread_t thread);
246  LIB_EXPORT int jack_client_kill_thread(jack_client_t* client, jack_native_thread_t thread);
247 #ifndef WIN32
248  LIB_EXPORT void jack_set_thread_creator(jack_thread_creator_t jtc);
249 #endif
250  LIB_EXPORT char * jack_get_internal_client_name(jack_client_t *client,
251  jack_intclient_t intclient);
252  LIB_EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t *client,
253  const char* client_name,
254  jack_status_t *status);
255  LIB_EXPORT jack_intclient_t jack_internal_client_load(jack_client_t *client,
256  const char* client_name,
257  jack_options_t options,
258  jack_status_t *status, ...);
259 
260  LIB_EXPORT jack_status_t jack_internal_client_unload(jack_client_t *client,
261  jack_intclient_t intclient);
262  LIB_EXPORT void jack_free(void* ptr);
263 
264  LIB_EXPORT int jack_set_session_callback(jack_client_t* ext_client, JackSessionCallback session_callback, void* arg);
265  LIB_EXPORT jack_session_command_t *jack_session_notify(jack_client_t* ext_client, const char* target, jack_session_event_type_t ev_type, const char* path);
266  LIB_EXPORT int jack_session_reply(jack_client_t* ext_client, jack_session_event_t *event);
267  LIB_EXPORT void jack_session_event_free(jack_session_event_t* ev);
268  LIB_EXPORT char* jack_client_get_uuid (jack_client_t *client);
269  LIB_EXPORT char* jack_get_uuid_for_client_name(jack_client_t* ext_client, const char* client_name);
270  LIB_EXPORT char* jack_get_client_name_by_uuid(jack_client_t* ext_client, const char* client_uuid);
271  LIB_EXPORT int jack_reserve_client_name(jack_client_t* ext_client, const char* name, const char* uuid);
272  LIB_EXPORT void jack_session_commands_free(jack_session_command_t *cmds);
273  LIB_EXPORT int jack_client_has_session_callback(jack_client_t *client, const char* client_name);
274 
275  LIB_EXPORT int jack_set_property(jack_client_t*, jack_uuid_t subject, const char* key, const char* value, const char* type);
276  LIB_EXPORT int jack_get_property(jack_uuid_t subject, const char* key, char** value, char** type);
277  LIB_EXPORT void jack_free_description(jack_description_t* desc, int free_description_itself);
278  LIB_EXPORT int jack_get_properties(jack_uuid_t subject, jack_description_t* desc);
279  LIB_EXPORT int jack_get_all_properties(jack_description_t** descs);
280  LIB_EXPORT int jack_remove_property(jack_client_t* client, jack_uuid_t subject, const char* key);
281  LIB_EXPORT int jack_remove_properties(jack_client_t* client, jack_uuid_t subject);
282  LIB_EXPORT int jack_remove_all_properties(jack_client_t* client);
283  LIB_EXPORT int jack_set_property_change_callback(jack_client_t* client, JackPropertyChangeCallback callback, void* arg);
284 
285  LIB_EXPORT jack_uuid_t jack_client_uuid_generate();
286  LIB_EXPORT jack_uuid_t jack_port_uuid_generate(uint32_t port_id);
287  LIB_EXPORT uint32_t jack_uuid_to_index(jack_uuid_t);
288  LIB_EXPORT int jack_uuid_compare(jack_uuid_t, jack_uuid_t);
289  LIB_EXPORT void jack_uuid_copy(jack_uuid_t* dst, jack_uuid_t src);
290  LIB_EXPORT void jack_uuid_clear(jack_uuid_t*);
291  LIB_EXPORT int jack_uuid_parse(const char* buf, jack_uuid_t*);
292  LIB_EXPORT void jack_uuid_unparse(jack_uuid_t, char buf[JACK_UUID_STRING_SIZE]);
293  LIB_EXPORT int jack_uuid_empty(jack_uuid_t);
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 static inline bool CheckPort(jack_port_id_t port_index)
300 {
301  return (port_index > 0 && port_index < PORT_NUM_MAX);
302 }
303 
304 static inline bool CheckBufferSize(jack_nframes_t buffer_size)
305 {
306  return (buffer_size >= 1 && buffer_size <= BUFFER_SIZE_MAX);
307 }
308 
309 static inline void WaitGraphChange()
310 {
311  /*
312  TLS key that is set only in RT thread, so never waits for pending
313  graph change in RT context (just read the current graph state).
314  */
315 
316  if (jack_tls_get(JackGlobals::fRealTimeThread) == NULL) {
317  JackGraphManager* manager = GetGraphManager();
318  JackEngineControl* control = GetEngineControl();
319  assert(manager);
320  assert(control);
321  if (manager->IsPendingChange()) {
322  jack_log("WaitGraphChange...");
323  JackSleep(int(control->fPeriodUsecs * 1.1f));
324  }
325  }
326 }
327 
328 LIB_EXPORT void jack_set_error_function(print_function func)
329 {
330  jack_error_callback = (func == NULL) ? &default_jack_error_callback : func;
331 }
332 
333 LIB_EXPORT void jack_set_info_function(print_function func)
334 {
335  jack_info_callback = (func == NULL) ? &default_jack_info_callback : func;
336 }
337 
338 LIB_EXPORT jack_client_t* jack_client_new(const char* client_name)
339 {
340  JackGlobals::CheckContext("jack_client_new");
341 
342  try {
343  assert(JackGlobals::fOpenMutex);
344  JackGlobals::fOpenMutex->Lock();
345  jack_error("jack_client_new: deprecated");
346  int options = JackUseExactName;
347  if (getenv("JACK_START_SERVER") == NULL) {
348  options |= JackNoStartServer;
349  }
350  jack_client_t* res = jack_client_new_aux(client_name, (jack_options_t)options, NULL);
351  JackGlobals::fOpenMutex->Unlock();
352  return res;
353  } catch (std::bad_alloc& e) {
354  jack_error("Memory allocation error...");
355  return NULL;
356  } catch (...) {
357  jack_error("Unknown error...");
358  return NULL;
359  }
360 }
361 
362 LIB_EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
363 {
364  JackGlobals::CheckContext("jack_port_get_buffer");
365 
366  uintptr_t port_aux = (uintptr_t)port;
367  jack_port_id_t myport = (jack_port_id_t)port_aux;
368  if (!CheckPort(myport)) {
369  jack_error("jack_port_get_buffer called with an incorrect port %ld", myport);
370  return NULL;
371  } else {
372  JackGraphManager* manager = GetGraphManager();
373  return (manager ? manager->GetBuffer(myport, frames) : NULL);
374  }
375 }
376 
377 LIB_EXPORT jack_uuid_t jack_port_uuid(const jack_port_t*)
378 {
379  return 0;
380 }
381 
382 LIB_EXPORT const char* jack_port_name(const jack_port_t* port)
383 {
384  JackGlobals::CheckContext("jack_port_name");
385 
386  uintptr_t port_aux = (uintptr_t)port;
387  jack_port_id_t myport = (jack_port_id_t)port_aux;
388  if (!CheckPort(myport)) {
389  jack_error("jack_port_name called with an incorrect port %ld", myport);
390  return NULL;
391  } else {
392  JackGraphManager* manager = GetGraphManager();
393  return (manager ? manager->GetPort(myport)->GetName() : NULL);
394  }
395 }
396 
397 LIB_EXPORT const char* jack_port_short_name(const jack_port_t* port)
398 {
399  JackGlobals::CheckContext("jack_port_short_name");
400 
401  uintptr_t port_aux = (uintptr_t)port;
402  jack_port_id_t myport = (jack_port_id_t)port_aux;
403  if (!CheckPort(myport)) {
404  jack_error("jack_port_short_name called with an incorrect port %ld", myport);
405  return NULL;
406  } else {
407  JackGraphManager* manager = GetGraphManager();
408  return (manager ? manager->GetPort(myport)->GetShortName() : NULL);
409  }
410 }
411 
412 LIB_EXPORT int jack_port_flags(const jack_port_t* port)
413 {
414  JackGlobals::CheckContext("jack_port_flags");
415 
416  uintptr_t port_aux = (uintptr_t)port;
417  jack_port_id_t myport = (jack_port_id_t)port_aux;
418  if (!CheckPort(myport)) {
419  jack_error("jack_port_flags called with an incorrect port %ld", myport);
420  return -1;
421  } else {
422  JackGraphManager* manager = GetGraphManager();
423  return (manager ? manager->GetPort(myport)->GetFlags() : -1);
424  }
425 }
426 
427 LIB_EXPORT const char* jack_port_type(const jack_port_t* port)
428 {
429  JackGlobals::CheckContext("jack_port_type");
430 
431  uintptr_t port_aux = (uintptr_t)port;
432  jack_port_id_t myport = (jack_port_id_t)port_aux;
433  if (!CheckPort(myport)) {
434  jack_error("jack_port_flags called an incorrect port %ld", myport);
435  return NULL;
436  } else {
437  JackGraphManager* manager = GetGraphManager();
438  return (manager ? manager->GetPort(myport)->GetType() : NULL);
439  }
440 }
441 
442 LIB_EXPORT jack_port_type_id_t jack_port_type_id(const jack_port_t *port)
443 {
444  JackGlobals::CheckContext("jack_port_type_id");
445 
446  uintptr_t port_aux = (uintptr_t)port;
447  jack_port_id_t myport = (jack_port_id_t)port_aux;
448  if (!CheckPort(myport)) {
449  jack_error("jack_port_type_id called an incorrect port %ld", myport);
450  return 0;
451  } else {
452  JackGraphManager* manager = GetGraphManager();
453  return (manager ? GetPortTypeId(manager->GetPort(myport)->GetType()) : 0);
454  }
455 }
456 
457 LIB_EXPORT int jack_port_connected(const jack_port_t* port)
458 {
459  JackGlobals::CheckContext("jack_port_connected");
460 
461  uintptr_t port_aux = (uintptr_t)port;
462  jack_port_id_t myport = (jack_port_id_t)port_aux;
463  if (!CheckPort(myport)) {
464  jack_error("jack_port_connected called with an incorrect port %ld", myport);
465  return -1;
466  } else {
467  WaitGraphChange();
468  JackGraphManager* manager = GetGraphManager();
469  return (manager ? manager->GetConnectionsNum(myport) : -1);
470  }
471 }
472 
473 LIB_EXPORT int jack_port_connected_to(const jack_port_t* port, const char* port_name)
474 {
475  JackGlobals::CheckContext("jack_port_connected_to");
476 
477  uintptr_t port_aux = (uintptr_t)port;
478  jack_port_id_t src = (jack_port_id_t)port_aux;
479  if (!CheckPort(src)) {
480  jack_error("jack_port_connected_to called with an incorrect port %ld", src);
481  return -1;
482  } else if (port_name == NULL) {
483  jack_error("jack_port_connected_to called with a NULL port name");
484  return -1;
485  } else {
486  WaitGraphChange();
487  JackGraphManager* manager = GetGraphManager();
488  jack_port_id_t dst = (manager ? manager->GetPort(port_name) : NO_PORT);
489  if (dst == NO_PORT) {
490  jack_error("Unknown destination port port_name = %s", port_name);
491  return 0;
492  } else {
493  return manager->IsConnected(src, dst);
494  }
495  }
496 }
497 
498 LIB_EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
499 {
500  JackGlobals::CheckContext("jack_port_tie");
501 
502  uintptr_t src_aux = (uintptr_t)src;
503  jack_port_id_t mysrc = (jack_port_id_t)src_aux;
504  if (!CheckPort(mysrc)) {
505  jack_error("jack_port_tie called with a NULL src port");
506  return -1;
507  }
508  uintptr_t dst_aux = (uintptr_t)dst;
509  jack_port_id_t mydst = (jack_port_id_t)dst_aux;
510  if (!CheckPort(mydst)) {
511  jack_error("jack_port_tie called with a NULL dst port");
512  return -1;
513  }
514  JackGraphManager* manager = GetGraphManager();
515  if (manager && manager->GetPort(mysrc)->GetRefNum() != manager->GetPort(mydst)->GetRefNum()) {
516  jack_error("jack_port_tie called with ports not belonging to the same client");
517  return -1;
518  } else {
519  return manager->GetPort(mydst)->Tie(mysrc);
520  }
521 }
522 
523 LIB_EXPORT int jack_port_untie(jack_port_t* port)
524 {
525  JackGlobals::CheckContext("jack_port_untie");
526 
527  uintptr_t port_aux = (uintptr_t)port;
528  jack_port_id_t myport = (jack_port_id_t)port_aux;
529  if (!CheckPort(myport)) {
530  jack_error("jack_port_untie called with an incorrect port %ld", myport);
531  return -1;
532  } else {
533  JackGraphManager* manager = GetGraphManager();
534  return (manager ? manager->GetPort(myport)->UnTie() : -1);
535  }
536 }
537 
538 LIB_EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
539 {
540  JackGlobals::CheckContext("jack_port_get_latency");
541 
542  uintptr_t port_aux = (uintptr_t)port;
543  jack_port_id_t myport = (jack_port_id_t)port_aux;
544  if (!CheckPort(myport)) {
545  jack_error("jack_port_get_latency called with an incorrect port %ld", myport);
546  return 0;
547  } else {
548  WaitGraphChange();
549  JackGraphManager* manager = GetGraphManager();
550  return (manager ? manager->GetPort(myport)->GetLatency() : 0);
551  }
552 }
553 
554 LIB_EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
555 {
556  JackGlobals::CheckContext("jack_port_set_latency");
557 
558  uintptr_t port_aux = (uintptr_t)port;
559  jack_port_id_t myport = (jack_port_id_t)port_aux;
560  if (!CheckPort(myport)) {
561  jack_error("jack_port_set_latency called with an incorrect port %ld", myport);
562  } else {
563  JackGraphManager* manager = GetGraphManager();
564  if (manager)
565  manager->GetPort(myport)->SetLatency(frames);
566  }
567 }
568 
569 LIB_EXPORT void jack_port_get_latency_range(jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range)
570 {
571  JackGlobals::CheckContext("jack_port_get_latency_range");
572 
573  uintptr_t port_aux = (uintptr_t)port;
574  jack_port_id_t myport = (jack_port_id_t)port_aux;
575  if (!CheckPort(myport)) {
576  jack_error("jack_port_get_latency_range called with an incorrect port %ld", myport);
577  } else {
578  WaitGraphChange();
579  JackGraphManager* manager = GetGraphManager();
580  if (manager)
581  manager->GetPort(myport)->GetLatencyRange(mode, range);
582  }
583 }
584 
585 LIB_EXPORT void jack_port_set_latency_range(jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range)
586 {
587  JackGlobals::CheckContext("jack_port_set_latency_range");
588 
589  uintptr_t port_aux = (uintptr_t)port;
590  jack_port_id_t myport = (jack_port_id_t)port_aux;
591  if (!CheckPort(myport)) {
592  jack_error("jack_port_set_latency_range called with an incorrect port %ld", myport);
593  } else {
594  WaitGraphChange();
595  JackGraphManager* manager = GetGraphManager();
596  if (manager)
597  manager->GetPort(myport)->SetLatencyRange(mode, range);
598  }
599 }
600 
601 LIB_EXPORT int jack_recompute_total_latency(jack_client_t* ext_client, jack_port_t* port)
602 {
603  JackGlobals::CheckContext("jack_recompute_total_latency");
604 
605 
606  JackClient* client = (JackClient*)ext_client;
607  uintptr_t port_aux = (uintptr_t)port;
608  jack_port_id_t myport = (jack_port_id_t)port_aux;
609  if (client == NULL) {
610  jack_error("jack_recompute_total_latency called with a NULL client");
611  return -1;
612  } else if (!CheckPort(myport)) {
613  jack_error("jack_recompute_total_latency called with a NULL port");
614  return -1;
615  } else {
616  WaitGraphChange();
617  JackGraphManager* manager = GetGraphManager();
618  return (manager ? manager->ComputeTotalLatency(myport) : -1);
619  }
620 }
621 
622 LIB_EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
623 {
624  JackGlobals::CheckContext("jack_recompute_total_latencies");
625 
626  JackClient* client = (JackClient*)ext_client;
627  if (client == NULL) {
628  jack_error("jack_recompute_total_latencies called with a NULL client");
629  return -1;
630  } else {
631  return client->ComputeTotalLatencies();
632  }
633 }
634 
635 LIB_EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
636 {
637  JackGlobals::CheckContext("jack_port_set_name");
638 
639  uintptr_t port_aux = (uintptr_t)port;
640  jack_port_id_t myport = (jack_port_id_t)port_aux;
641  if (!CheckPort(myport)) {
642  jack_error("jack_port_set_name called with an incorrect port %ld", myport);
643  return -1;
644  } else if (name == NULL) {
645  jack_error("jack_port_set_name called with a NULL port name");
646  return -1;
647  } else {
648  JackClient* client = NULL;
649  for (int i = 0; i < CLIENT_NUM; i++) {
650  // Find a valid client
651  if ((client = JackGlobals::fClientTable[i])) {
652  break;
653  }
654  }
655  return (client) ? client->PortRename(myport, name) : -1;
656  }
657 }
658 
659 LIB_EXPORT int jack_port_set_alias(jack_port_t* port, const char* name)
660 {
661  JackGlobals::CheckContext("jack_port_set_alias");
662 
663  uintptr_t port_aux = (uintptr_t)port;
664  jack_port_id_t myport = (jack_port_id_t)port_aux;
665  if (!CheckPort(myport)) {
666  jack_error("jack_port_set_alias called with an incorrect port %ld", myport);
667  return -1;
668  } else if (name == NULL) {
669  jack_error("jack_port_set_alias called with a NULL port name");
670  return -1;
671  } else {
672  JackGraphManager* manager = GetGraphManager();
673  return (manager ? manager->GetPort(myport)->SetAlias(name) : -1);
674  }
675 }
676 
677 LIB_EXPORT int jack_port_unset_alias(jack_port_t* port, const char* name)
678 {
679  JackGlobals::CheckContext("jack_port_unset_alias");
680 
681  uintptr_t port_aux = (uintptr_t)port;
682  jack_port_id_t myport = (jack_port_id_t)port_aux;
683  if (!CheckPort(myport)) {
684  jack_error("jack_port_unset_alias called with an incorrect port %ld", myport);
685  return -1;
686  } else if (name == NULL) {
687  jack_error("jack_port_unset_alias called with a NULL port name");
688  return -1;
689  } else {
690  JackGraphManager* manager = GetGraphManager();
691  return (manager ? manager->GetPort(myport)->UnsetAlias(name) : -1);
692  }
693 }
694 
695 LIB_EXPORT int jack_port_get_aliases(const jack_port_t* port, char* const aliases[2])
696 {
697  JackGlobals::CheckContext("jack_port_get_aliases");
698 
699  uintptr_t port_aux = (uintptr_t)port;
700  jack_port_id_t myport = (jack_port_id_t)port_aux;
701  if (!CheckPort(myport)) {
702  jack_error("jack_port_get_aliases called with an incorrect port %ld", myport);
703  return -1;
704  } else {
705  JackGraphManager* manager = GetGraphManager();
706  return (manager ? manager->GetPort(myport)->GetAliases(aliases) : -1);
707  }
708 }
709 
710 LIB_EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
711 {
712  JackGlobals::CheckContext("jack_port_request_monitor");
713 
714  uintptr_t port_aux = (uintptr_t)port;
715  jack_port_id_t myport = (jack_port_id_t)port_aux;
716  if (!CheckPort(myport)) {
717  jack_error("jack_port_request_monitor called with an incorrect port %ld", myport);
718  return -1;
719  } else {
720  JackGraphManager* manager = GetGraphManager();
721  return (manager ? manager->RequestMonitor(myport, onoff) : -1);
722  }
723 }
724 
725 LIB_EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
726 {
727  JackGlobals::CheckContext("jack_port_request_monitor_by_name");
728 
729  JackClient* client = (JackClient*)ext_client;
730  if (client == NULL) {
731  jack_error("jack_port_request_monitor_by_name called with a NULL client");
732  return -1;
733  } else {
734  JackGraphManager* manager = GetGraphManager();
735  if (!manager)
736  return -1;
737  jack_port_id_t myport = manager->GetPort(port_name);
738  if (!CheckPort(myport)) {
739  jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
740  return -1;
741  } else {
742  return manager->RequestMonitor(myport, onoff);
743  }
744  }
745 }
746 
747 LIB_EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
748 {
749  JackGlobals::CheckContext("jack_port_ensure_monitor");
750 
751  uintptr_t port_aux = (uintptr_t)port;
752  jack_port_id_t myport = (jack_port_id_t)port_aux;
753  if (!CheckPort(myport)) {
754  jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport);
755  return -1;
756  } else {
757  JackGraphManager* manager = GetGraphManager();
758  return (manager ? manager->GetPort(myport)->EnsureMonitor(onoff) : -1);
759  }
760 }
761 
762 LIB_EXPORT int jack_port_monitoring_input(jack_port_t* port)
763 {
764  JackGlobals::CheckContext("jack_port_monitoring_input");
765 
766  uintptr_t port_aux = (uintptr_t)port;
767  jack_port_id_t myport = (jack_port_id_t)port_aux;
768  if (!CheckPort(myport)) {
769  jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport);
770  return -1;
771  } else {
772  JackGraphManager* manager = GetGraphManager();
773  return (manager ? manager->GetPort(myport)->MonitoringInput() : -1);
774  }
775 }
776 
777 LIB_EXPORT int jack_is_realtime(jack_client_t* ext_client)
778 {
779  JackGlobals::CheckContext("jack_is_realtime");
780 
781  JackClient* client = (JackClient*)ext_client;
782  if (client == NULL) {
783  jack_error("jack_is_realtime called with a NULL client");
784  return -1;
785  } else {
786  JackEngineControl* control = GetEngineControl();
787  return (control ? control->fRealTime : -1);
788  }
789 }
790 
791 LIB_EXPORT void jack_on_shutdown(jack_client_t* ext_client, JackShutdownCallback callback, void* arg)
792 {
793  JackGlobals::CheckContext("jack_on_shutdown");
794 
795  JackClient* client = (JackClient*)ext_client;
796  if (client == NULL) {
797  jack_error("jack_on_shutdown called with a NULL client");
798  } else {
799  client->OnShutdown(callback, arg);
800  }
801 }
802 
803 LIB_EXPORT void jack_on_info_shutdown(jack_client_t* ext_client, JackInfoShutdownCallback callback, void* arg)
804 {
805  JackGlobals::CheckContext("jack_on_info_shutdown");
806 
807  JackClient* client = (JackClient*)ext_client;
808  if (client == NULL) {
809  jack_error("jack_on_info_shutdown called with a NULL client");
810  } else {
811  client->OnInfoShutdown(callback, arg);
812  }
813 }
814 
815 LIB_EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
816 {
817  JackGlobals::CheckContext("jack_set_process_callback");
818 
819  JackClient* client = (JackClient*)ext_client;
820  if (client == NULL) {
821  jack_error("jack_set_process_callback called with a NULL client");
822  return -1;
823  } else {
824  return client->SetProcessCallback(callback, arg);
825  }
826 }
827 
828 LIB_EXPORT jack_nframes_t jack_thread_wait(jack_client_t* ext_client, int status)
829 {
830  JackGlobals::CheckContext("jack_thread_wait");
831 
832  JackClient* client = (JackClient*)ext_client;
833  if (client == NULL) {
834  jack_error("jack_thread_wait called with a NULL client");
835  return 0;
836  } else {
837  jack_error("jack_thread_wait: deprecated, use jack_cycle_wait/jack_cycle_signal");
838  return 0;
839  }
840 }
841 
842 LIB_EXPORT jack_nframes_t jack_cycle_wait(jack_client_t* ext_client)
843 {
844  JackGlobals::CheckContext("jack_cycle_wait");
845 
846  JackClient* client = (JackClient*)ext_client;
847  if (client == NULL) {
848  jack_error("jack_cycle_wait called with a NULL client");
849  return 0;
850  } else {
851  return client->CycleWait();
852  }
853 }
854 
855 LIB_EXPORT void jack_cycle_signal(jack_client_t* ext_client, int status)
856 {
857  JackGlobals::CheckContext("jack_cycle_signal");
858 
859  JackClient* client = (JackClient*)ext_client;
860  if (client == NULL) {
861  jack_error("jack_cycle_signal called with a NULL client");
862  } else {
863  client->CycleSignal(status);
864  }
865 }
866 
867 LIB_EXPORT int jack_set_process_thread(jack_client_t* ext_client, JackThreadCallback fun, void *arg)
868 {
869  JackGlobals::CheckContext("jack_set_process_thread");
870 
871  JackClient* client = (JackClient*)ext_client;
872  if (client == NULL) {
873  jack_error("jack_set_process_thread called with a NULL client");
874  return -1;
875  } else {
876  return client->SetProcessThread(fun, arg);
877  }
878 }
879 
880 LIB_EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
881 {
882  JackGlobals::CheckContext("jack_set_freewheel_callback");
883 
884  JackClient* client = (JackClient*)ext_client;
885  if (client == NULL) {
886  jack_error("jack_set_freewheel_callback called with a NULL client");
887  return -1;
888  } else {
889  return client->SetFreewheelCallback(freewheel_callback, arg);
890  }
891 }
892 
893 LIB_EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
894 {
895  JackGlobals::CheckContext("jack_set_freewheel");
896 
897  JackClient* client = (JackClient*)ext_client;
898  if (client == NULL) {
899  jack_error("jack_set_freewheel called with a NULL client");
900  return -1;
901  } else {
902  return client->SetFreeWheel(onoff);
903  }
904 }
905 
906 LIB_EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
907 {
908  JackGlobals::CheckContext("jack_set_buffer_size");
909 
910  JackClient* client = (JackClient*)ext_client;
911  if (client == NULL) {
912  jack_error("jack_set_buffer_size called with a NULL client");
913  return -1;
914  } else if (!CheckBufferSize(buffer_size)) {
915  return -1;
916  } else {
917  return client->SetBufferSize(buffer_size);
918  }
919 }
920 
921 LIB_EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
922 {
923  JackGlobals::CheckContext("jack_set_buffer_size_callback");
924 
925  JackClient* client = (JackClient*)ext_client;
926  if (client == NULL) {
927  jack_error("jack_set_buffer_size_callback called with a NULL client");
928  return -1;
929  } else {
930  return client->SetBufferSizeCallback(bufsize_callback, arg);
931  }
932 }
933 
934 LIB_EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
935 {
936  JackGlobals::CheckContext("jack_set_sample_rate_callback");
937 
938  JackClient* client = (JackClient*)ext_client;
939  if (client == NULL) {
940  jack_error("jack_set_sample_rate_callback called with a NULL client");
941  return -1;
942  } else {
943  return client->SetSampleRateCallback(srate_callback, arg);
944  }
945 }
946 
947 LIB_EXPORT int jack_set_client_registration_callback(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg)
948 {
949  JackGlobals::CheckContext("jack_set_client_registration_callback");
950 
951  JackClient* client = (JackClient*)ext_client;
952  if (client == NULL) {
953  jack_error("jack_set_client_registration_callback called with a NULL client");
954  return -1;
955  } else {
956  return client->SetClientRegistrationCallback(registration_callback, arg);
957  }
958 }
959 
960 LIB_EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
961 {
962  JackGlobals::CheckContext("jack_set_port_registration_callback");
963 
964  JackClient* client = (JackClient*)ext_client;
965  if (client == NULL) {
966  jack_error("jack_set_port_registration_callback called with a NULL client");
967  return -1;
968  } else {
969  return client->SetPortRegistrationCallback(registration_callback, arg);
970  }
971 }
972 
973 LIB_EXPORT int jack_set_port_connect_callback(jack_client_t* ext_client, JackPortConnectCallback portconnect_callback, void* arg)
974 {
975  JackGlobals::CheckContext("jack_set_port_connect_callback");
976 
977  JackClient* client = (JackClient*)ext_client;
978  if (client == NULL) {
979  jack_error("jack_set_port_connect_callback called with a NULL client");
980  return -1;
981  } else {
982  return client->SetPortConnectCallback(portconnect_callback, arg);
983  }
984 }
985 
986 LIB_EXPORT int jack_set_port_rename_callback(jack_client_t* ext_client, JackPortRenameCallback rename_callback, void* arg)
987 {
988  JackGlobals::CheckContext("jack_set_port_rename_callback");
989 
990  JackClient* client = (JackClient*)ext_client;
991  if (client == NULL) {
992  jack_error("jack_set_port_rename_callback called with a NULL client");
993  return -1;
994  } else {
995  return client->SetPortRenameCallback(rename_callback, arg);
996  }
997 }
998 
999 LIB_EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
1000 {
1001  JackGlobals::CheckContext("jack_set_graph_order_callback");
1002 
1003  JackClient* client = (JackClient*)ext_client;
1004  jack_log("jack_set_graph_order_callback ext_client %x client %x ", ext_client, client);
1005  if (client == NULL) {
1006  jack_error("jack_set_graph_order_callback called with a NULL client");
1007  return -1;
1008  } else {
1009  return client->SetGraphOrderCallback(graph_callback, arg);
1010  }
1011 }
1012 
1013 LIB_EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
1014 {
1015  JackGlobals::CheckContext("jack_set_xrun_callback");
1016 
1017  JackClient* client = (JackClient*)ext_client;
1018  if (client == NULL) {
1019  jack_error("jack_set_xrun_callback called with a NULL client");
1020  return -1;
1021  } else {
1022  return client->SetXRunCallback(xrun_callback, arg);
1023  }
1024 }
1025 
1026 LIB_EXPORT int jack_set_latency_callback(jack_client_t* ext_client, JackLatencyCallback latency_callback, void *arg)
1027 {
1028  JackGlobals::CheckContext("jack_set_latency_callback");
1029 
1030  JackClient* client = (JackClient*)ext_client;
1031  if (client == NULL) {
1032  jack_error("jack_set_latency_callback called with a NULL client");
1033  return -1;
1034  } else {
1035  return client->SetLatencyCallback(latency_callback, arg);
1036  }
1037 }
1038 
1039 LIB_EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
1040 {
1041  JackGlobals::CheckContext("jack_set_thread_init_callback");
1042 
1043  JackClient* client = (JackClient*)ext_client;
1044  jack_log("jack_set_thread_init_callback ext_client %x client %x ", ext_client, client);
1045  if (client == NULL) {
1046  jack_error("jack_set_thread_init_callback called with a NULL client");
1047  return -1;
1048  } else {
1049  return client->SetInitCallback(init_callback, arg);
1050  }
1051 }
1052 
1053 LIB_EXPORT int jack_activate(jack_client_t* ext_client)
1054 {
1055  JackGlobals::CheckContext("jack_activate");
1056 
1057  JackClient* client = (JackClient*)ext_client;
1058  if (client == NULL) {
1059  jack_error("jack_activate called with a NULL client");
1060  return -1;
1061  } else {
1062  return client->Activate();
1063  }
1064 }
1065 
1066 LIB_EXPORT int jack_deactivate(jack_client_t* ext_client)
1067 {
1068  JackGlobals::CheckContext("jack_deactivate");
1069 
1070  JackClient* client = (JackClient*)ext_client;
1071  if (client == NULL) {
1072  jack_error("jack_deactivate called with a NULL client");
1073  return -1;
1074  } else {
1075  return client->Deactivate();
1076  }
1077 }
1078 
1079 LIB_EXPORT jack_port_t* jack_port_register(jack_client_t* ext_client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size)
1080 {
1081  JackGlobals::CheckContext("jack_port_register");
1082 
1083  JackClient* client = (JackClient*)ext_client;
1084  if (client == NULL) {
1085  jack_error("jack_port_register called with a NULL client");
1086  return NULL;
1087  } else if ((port_name == NULL) || (port_type == NULL)) {
1088  jack_error("jack_port_register called with a NULL port name or a NULL port_type");
1089  return NULL;
1090  } else {
1091  return (jack_port_t *)((uintptr_t)client->PortRegister(port_name, port_type, flags, buffer_size));
1092  }
1093 }
1094 
1095 LIB_EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port)
1096 {
1097  JackGlobals::CheckContext("jack_port_unregister");
1098 
1099  JackClient* client = (JackClient*)ext_client;
1100  if (client == NULL) {
1101  jack_error("jack_port_unregister called with a NULL client");
1102  return -1;
1103  }
1104  uintptr_t port_aux = (uintptr_t)port;
1105  jack_port_id_t myport = (jack_port_id_t)port_aux;
1106  if (!CheckPort(myport)) {
1107  jack_error("jack_port_unregister called with an incorrect port %ld", myport);
1108  return -1;
1109  }
1110  return client->PortUnRegister(myport);
1111 }
1112 
1113 LIB_EXPORT int jack_port_is_mine(const jack_client_t* ext_client, const jack_port_t* port)
1114 {
1115  JackGlobals::CheckContext("jack_port_is_mine");
1116 
1117  JackClient* client = (JackClient*)ext_client;
1118  if (client == NULL) {
1119  jack_error("jack_port_is_mine called with a NULL client");
1120  return -1;
1121  }
1122  uintptr_t port_aux = (uintptr_t)port;
1123  jack_port_id_t myport = (jack_port_id_t)port_aux;
1124  if (!CheckPort(myport)) {
1125  jack_error("jack_port_is_mine called with an incorrect port %ld", myport);
1126  return -1;
1127  }
1128  return client->PortIsMine(myport);
1129 }
1130 
1131 LIB_EXPORT const char** jack_port_get_connections(const jack_port_t* port)
1132 {
1133  JackGlobals::CheckContext("jack_port_get_connections");
1134 
1135  uintptr_t port_aux = (uintptr_t)port;
1136  jack_port_id_t myport = (jack_port_id_t)port_aux;
1137  if (!CheckPort(myport)) {
1138  jack_error("jack_port_get_connections called with an incorrect port %ld", myport);
1139  return NULL;
1140  } else {
1141  WaitGraphChange();
1142  JackGraphManager* manager = GetGraphManager();
1143  return (manager ? manager->GetConnections(myport) : NULL);
1144  }
1145 }
1146 
1147 // Calling client does not need to "own" the port
1148 LIB_EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_client, const jack_port_t* port)
1149 {
1150  JackGlobals::CheckContext("jack_port_get_all_connections");
1151 
1152  JackClient* client = (JackClient*)ext_client;
1153  if (client == NULL) {
1154  jack_error("jack_port_get_all_connections called with a NULL client");
1155  return NULL;
1156  }
1157 
1158  uintptr_t port_aux = (uintptr_t)port;
1159  jack_port_id_t myport = (jack_port_id_t)port_aux;
1160  if (!CheckPort(myport)) {
1161  jack_error("jack_port_get_all_connections called with an incorrect port %ld", myport);
1162  return NULL;
1163  } else {
1164  WaitGraphChange();
1165  JackGraphManager* manager = GetGraphManager();
1166  return (manager ? manager->GetConnections(myport) : NULL);
1167  }
1168 }
1169 
1170 LIB_EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port)
1171 {
1172  JackGlobals::CheckContext("jack_port_get_total_latency");
1173 
1174  JackClient* client = (JackClient*)ext_client;
1175  if (client == NULL) {
1176  jack_error("jack_port_get_total_latency called with a NULL client");
1177  return 0;
1178  }
1179 
1180  uintptr_t port_aux = (uintptr_t)port;
1181  jack_port_id_t myport = (jack_port_id_t)port_aux;
1182  if (!CheckPort(myport)) {
1183  jack_error("jack_port_get_total_latency called with an incorrect port %ld", myport);
1184  return 0;
1185  } else {
1186  WaitGraphChange();
1187  JackGraphManager* manager = GetGraphManager();
1188  if (manager) {
1189  manager->ComputeTotalLatency(myport);
1190  return manager->GetPort(myport)->GetTotalLatency();
1191  } else {
1192  return 0;
1193  }
1194  }
1195 }
1196 
1197 LIB_EXPORT int jack_connect(jack_client_t* ext_client, const char* src, const char* dst)
1198 {
1199  JackGlobals::CheckContext("jack_connect");
1200 
1201  JackClient* client = (JackClient*)ext_client;
1202  if (client == NULL) {
1203  jack_error("jack_connect called with a NULL client");
1204  return -1;
1205  } else if ((src == NULL) || (dst == NULL)) {
1206  jack_error("jack_connect called with a NULL port name");
1207  return -1;
1208  } else {
1209  return client->PortConnect(src, dst);
1210  }
1211 }
1212 
1213 LIB_EXPORT int jack_disconnect(jack_client_t* ext_client, const char* src, const char* dst)
1214 {
1215  JackGlobals::CheckContext("jack_disconnect");
1216 
1217  JackClient* client = (JackClient*)ext_client;
1218  if (client == NULL) {
1219  jack_error("jack_disconnect called with a NULL client");
1220  return -1;
1221  } else if ((src == NULL) || (dst == NULL)) {
1222  jack_error("jack_disconnect called with a NULL port name");
1223  return -1;
1224  } else {
1225  return client->PortDisconnect(src, dst);
1226  }
1227 }
1228 
1229 LIB_EXPORT int jack_port_disconnect(jack_client_t* ext_client, jack_port_t* src)
1230 {
1231  JackGlobals::CheckContext("jack_port_disconnect");
1232 
1233  JackClient* client = (JackClient*)ext_client;
1234  if (client == NULL) {
1235  jack_error("jack_port_disconnect called with a NULL client");
1236  return -1;
1237  }
1238  uintptr_t port_aux = (uintptr_t)src;
1239  jack_port_id_t myport = (jack_port_id_t)port_aux;
1240  if (!CheckPort(myport)) {
1241  jack_error("jack_port_disconnect called with an incorrect port %ld", myport);
1242  return -1;
1243  }
1244  return client->PortDisconnect(myport);
1245 }
1246 
1247 LIB_EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t* ext_client)
1248 {
1249  JackGlobals::CheckContext("jack_get_sample_rate");
1250 
1251  JackClient* client = (JackClient*)ext_client;
1252  if (client == NULL) {
1253  jack_error("jack_get_sample_rate called with a NULL client");
1254  return 0;
1255  } else {
1256  JackEngineControl* control = GetEngineControl();
1257  return (control ? control->fSampleRate : 0);
1258  }
1259 }
1260 
1261 LIB_EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client)
1262 {
1263  JackGlobals::CheckContext("jack_get_buffer_size");
1264 
1265  JackClient* client = (JackClient*)ext_client;
1266  if (client == NULL) {
1267  jack_error("jack_get_buffer_size called with a NULL client");
1268  return 0;
1269  } else {
1270  JackEngineControl* control = GetEngineControl();
1271  return (control ? control->fBufferSize : 0);
1272  }
1273 }
1274 
1275 LIB_EXPORT const char** jack_get_ports(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
1276 {
1277  JackGlobals::CheckContext("jack_get_ports");
1278 
1279  JackClient* client = (JackClient*)ext_client;
1280  if (client == NULL) {
1281  jack_error("jack_get_ports called with a NULL client");
1282  return NULL;
1283  }
1284  JackGraphManager* manager = GetGraphManager();
1285  return (manager ? manager->GetPorts(port_name_pattern, type_name_pattern, flags) : NULL);
1286 }
1287 
1288 LIB_EXPORT jack_port_t* jack_port_by_name(jack_client_t* ext_client, const char* portname)
1289 {
1290  JackGlobals::CheckContext("jack_port_by_name");
1291 
1292  JackClient* client = (JackClient*)ext_client;
1293  if (client == NULL) {
1294  jack_error("jack_port_by_name called with a NULL client");
1295  return NULL;
1296  }
1297 
1298  if (portname == NULL) {
1299  jack_error("jack_port_by_name called with a NULL port name");
1300  return NULL;
1301  }
1302 
1303  JackGraphManager* manager = GetGraphManager();
1304  if (manager) {
1305  int res = manager->GetPort(portname); // returns a port index at least > 1
1306  return (res == NO_PORT) ? NULL : (jack_port_t*)((uintptr_t)res);
1307  } else {
1308  return NULL;
1309  }
1310 }
1311 
1312 LIB_EXPORT jack_port_t* jack_port_by_id(jack_client_t* ext_client, jack_port_id_t id)
1313 {
1314  JackGlobals::CheckContext("jack_port_by_id");
1315 
1316  /* jack_port_t* type is actually the port index */
1317  return (jack_port_t*)((uintptr_t)id);
1318 }
1319 
1320 LIB_EXPORT int jack_engine_takeover_timebase(jack_client_t* ext_client)
1321 {
1322  JackGlobals::CheckContext("jack_engine_takeover_timebase");
1323 
1324  JackClient* client = (JackClient*)ext_client;
1325  if (client == NULL) {
1326  jack_error("jack_engine_takeover_timebase called with a NULL client");
1327  return -1;
1328  } else {
1329  jack_error("jack_engine_takeover_timebase: deprecated\n");
1330  return 0;
1331  }
1332 }
1333 
1334 LIB_EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t* ext_client)
1335 {
1336  JackGlobals::CheckContext("jack_frames_since_cycle_start");
1337 
1338  JackTimer timer;
1339  JackEngineControl* control = GetEngineControl();
1340  if (control) {
1341  control->ReadFrameTime(&timer);
1342  return timer.FramesSinceCycleStart(GetMicroSeconds(), control->fSampleRate);
1343  } else {
1344  return 0;
1345  }
1346 }
1347 
1348 LIB_EXPORT jack_time_t jack_get_time()
1349 {
1350  JackGlobals::CheckContext("jack_get_time");
1351 
1352  return GetMicroSeconds();
1353 }
1354 
1355 LIB_EXPORT jack_time_t jack_frames_to_time(const jack_client_t* ext_client, jack_nframes_t frames)
1356 {
1357  JackGlobals::CheckContext("jack_frames_to_time");
1358 
1359  JackClient* client = (JackClient*)ext_client;
1360  if (client == NULL) {
1361  jack_error("jack_frames_to_time called with a NULL client");
1362  return 0;
1363  } else {
1364  JackTimer timer;
1365  JackEngineControl* control = GetEngineControl();
1366  if (control) {
1367  control->ReadFrameTime(&timer);
1368  return timer.Frames2Time(frames, control->fBufferSize);
1369  } else {
1370  return 0;
1371  }
1372  }
1373 }
1374 
1375 LIB_EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t* ext_client, jack_time_t usecs)
1376 {
1377  JackGlobals::CheckContext("jack_time_to_frames");
1378 
1379  JackClient* client = (JackClient*)ext_client;
1380  if (client == NULL) {
1381  jack_error("jack_time_to_frames called with a NULL client");
1382  return 0;
1383  } else {
1384  JackTimer timer;
1385  JackEngineControl* control = GetEngineControl();
1386  if (control) {
1387  control->ReadFrameTime(&timer);
1388  return timer.Time2Frames(usecs, control->fBufferSize);
1389  } else {
1390  return 0;
1391  }
1392  }
1393 }
1394 
1395 LIB_EXPORT jack_nframes_t jack_frame_time(const jack_client_t* ext_client)
1396 {
1397  JackGlobals::CheckContext("jack_frame_time");
1398 
1399  return jack_time_to_frames(ext_client, GetMicroSeconds());
1400 }
1401 
1402 LIB_EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
1403 {
1404  JackGlobals::CheckContext("jack_last_frame_time");
1405 
1406  JackEngineControl* control = GetEngineControl();
1407  return (control) ? control->fFrameTimer.ReadCurrentState()->CurFrame() : 0;
1408 }
1409 
1410 LIB_EXPORT int jack_get_cycle_times(const jack_client_t *client,
1411  jack_nframes_t *current_frames,
1412  jack_time_t *current_usecs,
1413  jack_time_t *next_usecs,
1414  float *period_usecs)
1415 {
1416  JackGlobals::CheckContext("jack_get_cycle_times");
1417 
1418  JackEngineControl* control = GetEngineControl();
1419  if (control) {
1420  JackTimer timer;
1421  control->ReadFrameTime(&timer);
1422  return timer.GetCycleTimes(current_frames, current_usecs, next_usecs, period_usecs);
1423  } else {
1424  return -1;
1425  }
1426 }
1427 
1428 LIB_EXPORT float jack_cpu_load(jack_client_t* ext_client)
1429 {
1430  JackGlobals::CheckContext("jack_cpu_load");
1431 
1432  JackClient* client = (JackClient*)ext_client;
1433  if (client == NULL) {
1434  jack_error("jack_cpu_load called with a NULL client");
1435  return 0.0f;
1436  } else {
1437  JackEngineControl* control = GetEngineControl();
1438  return (control ? control->fCPULoad : 0.0f);
1439  }
1440 }
1441 
1442 LIB_EXPORT jack_native_thread_t jack_client_thread_id(jack_client_t* ext_client)
1443 {
1444  JackGlobals::CheckContext("jack_client_thread_id");
1445 
1446  JackClient* client = (JackClient*)ext_client;
1447  if (client == NULL) {
1448  jack_error("jack_client_thread_id called with a NULL client");
1449  return (jack_native_thread_t)NULL;
1450  } else {
1451  return client->GetThreadID();
1452  }
1453 }
1454 
1455 LIB_EXPORT char* jack_get_client_name(jack_client_t* ext_client)
1456 {
1457  JackGlobals::CheckContext("jack_get_client_name");
1458 
1459  JackClient* client = (JackClient*)ext_client;
1460  if (client == NULL) {
1461  jack_error("jack_get_client_name called with a NULL client");
1462  return NULL;
1463  } else {
1464  return client->GetClientControl()->fName;
1465  }
1466 }
1467 
1468 LIB_EXPORT int jack_client_name_size(void)
1469 {
1470  return JACK_CLIENT_NAME_SIZE;
1471 }
1472 
1473 LIB_EXPORT int jack_port_name_size(void)
1474 {
1475  return REAL_JACK_PORT_NAME_SIZE;
1476 }
1477 
1478 LIB_EXPORT int jack_port_type_size(void)
1479 {
1480  return JACK_PORT_TYPE_SIZE;
1481 }
1482 
1483 LIB_EXPORT size_t jack_port_type_get_buffer_size(jack_client_t* ext_client, const char* port_type)
1484 {
1485  JackGlobals::CheckContext("jack_port_type_get_buffer_size");
1486 
1487  JackClient* client = (JackClient*)ext_client;
1488  if (client == NULL) {
1489  jack_error("jack_port_type_get_buffer_size called with a NULL client");
1490  return 0;
1491  } else {
1492  jack_port_type_id_t port_id = GetPortTypeId(port_type);
1493  if (port_id == PORT_TYPES_MAX) {
1494  jack_error("jack_port_type_get_buffer_size called with an unknown port type = %s", port_type);
1495  return 0;
1496  } else {
1497  return GetPortType(port_id)->size();
1498  }
1499  }
1500 }
1501 
1502 // transport.h
1503 LIB_EXPORT int jack_release_timebase(jack_client_t* ext_client)
1504 {
1505  JackGlobals::CheckContext("jack_release_timebase");
1506 
1507  JackClient* client = (JackClient*)ext_client;
1508  if (client == NULL) {
1509  jack_error("jack_release_timebase called with a NULL client");
1510  return -1;
1511  } else {
1512  return client->ReleaseTimebase();
1513  }
1514 }
1515 
1516 LIB_EXPORT int jack_set_sync_callback(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg)
1517 {
1518  JackGlobals::CheckContext("jack_set_sync_callback");
1519 
1520  JackClient* client = (JackClient*)ext_client;
1521  if (client == NULL) {
1522  jack_error("jack_set_sync_callback called with a NULL client");
1523  return -1;
1524  } else {
1525  return client->SetSyncCallback(sync_callback, arg);
1526  }
1527 }
1528 
1529 LIB_EXPORT int jack_set_sync_timeout(jack_client_t* ext_client, jack_time_t timeout)
1530 {
1531  JackGlobals::CheckContext("jack_set_sync_timeout");
1532 
1533  JackClient* client = (JackClient*)ext_client;
1534  if (client == NULL) {
1535  jack_error("jack_set_sync_timeout called with a NULL client");
1536  return -1;
1537  } else {
1538  return client->SetSyncTimeout(timeout);
1539  }
1540 }
1541 
1542 LIB_EXPORT int jack_set_timebase_callback(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg)
1543 {
1544  JackGlobals::CheckContext("jack_set_timebase_callback");
1545 
1546  JackClient* client = (JackClient*)ext_client;
1547  if (client == NULL) {
1548  jack_error("jack_set_timebase_callback called with a NULL client");
1549  return -1;
1550  } else {
1551  return client->SetTimebaseCallback(conditional, timebase_callback, arg);
1552  }
1553 }
1554 
1555 LIB_EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame)
1556 {
1557  JackGlobals::CheckContext("jack_transport_locate");
1558 
1559  JackClient* client = (JackClient*)ext_client;
1560  if (client == NULL) {
1561  jack_error("jack_transport_locate called with a NULL client");
1562  return -1;
1563  } else {
1564  client->TransportLocate(frame);
1565  return 0;
1566  }
1567 }
1568 
1569 LIB_EXPORT jack_transport_state_t jack_transport_query(const jack_client_t* ext_client, jack_position_t* pos)
1570 {
1571  JackGlobals::CheckContext("jack_transport_query");
1572 
1573  JackClient* client = (JackClient*)ext_client;
1574  if (client == NULL) {
1575  jack_error("jack_transport_query called with a NULL client");
1576  return JackTransportStopped;
1577  } else {
1578  return client->TransportQuery(pos);
1579  }
1580 }
1581 
1582 LIB_EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t* ext_client)
1583 {
1584  JackGlobals::CheckContext("jack_get_current_transport_frame");
1585 
1586  JackClient* client = (JackClient*)ext_client;
1587  if (client == NULL) {
1588  jack_error("jack_get_current_transport_frame called with a NULL client");
1589  return 0;
1590  } else {
1591  return client->GetCurrentTransportFrame();
1592  }
1593 }
1594 
1595 LIB_EXPORT int jack_transport_reposition(jack_client_t* ext_client, const jack_position_t* pos)
1596 {
1597  JackGlobals::CheckContext("jack_transport_reposition");
1598 
1599  JackClient* client = (JackClient*)ext_client;
1600  if (client == NULL) {
1601  jack_error("jack_transport_reposition called with a NULL client");
1602  return -1;
1603  } else {
1604  client->TransportReposition(pos);
1605  return 0;
1606  }
1607 }
1608 
1609 LIB_EXPORT void jack_transport_start(jack_client_t* ext_client)
1610 {
1611  JackGlobals::CheckContext("jack_transport_start");
1612 
1613  JackClient* client = (JackClient*)ext_client;
1614  if (client == NULL) {
1615  jack_error("jack_transport_start called with a NULL client");
1616  } else {
1617  client->TransportStart();
1618  }
1619 }
1620 
1621 LIB_EXPORT void jack_transport_stop(jack_client_t* ext_client)
1622 {
1623  JackGlobals::CheckContext("jack_transport_stop");
1624 
1625  JackClient* client = (JackClient*)ext_client;
1626  if (client == NULL) {
1627  jack_error("jack_transport_stop called with a NULL client");
1628  } else {
1629  client->TransportStop();
1630  }
1631 }
1632 
1633 // deprecated
1634 LIB_EXPORT void jack_get_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
1635 {
1636  JackGlobals::CheckContext("jack_get_transport_info");
1637 
1638  jack_error("jack_get_transport_info: deprecated");
1639  if (tinfo)
1640  memset(tinfo, 0, sizeof(jack_transport_info_t));
1641 }
1642 
1643 LIB_EXPORT void jack_set_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
1644 {
1645  JackGlobals::CheckContext("jack_set_transport_info");
1646 
1647  jack_error("jack_set_transport_info: deprecated");
1648  if (tinfo)
1649  memset(tinfo, 0, sizeof(jack_transport_info_t));
1650 }
1651 
1652 // statistics.h
1653 LIB_EXPORT float jack_get_max_delayed_usecs(jack_client_t* ext_client)
1654 {
1655  JackGlobals::CheckContext("jack_get_max_delayed_usecs");
1656 
1657  JackClient* client = (JackClient*)ext_client;
1658  if (client == NULL) {
1659  jack_error("jack_get_max_delayed_usecs called with a NULL client");
1660  return 0.f;
1661  } else {
1662  JackEngineControl* control = GetEngineControl();
1663  return (control ? control->fMaxDelayedUsecs : 0.f);
1664  }
1665  }
1666 
1667 LIB_EXPORT float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
1668 {
1669  JackGlobals::CheckContext("jack_get_xrun_delayed_usecs");
1670 
1671  JackClient* client = (JackClient*)ext_client;
1672  if (client == NULL) {
1673  jack_error("jack_get_xrun_delayed_usecs called with a NULL client");
1674  return 0.f;
1675  } else {
1676  JackEngineControl* control = GetEngineControl();
1677  return (control ? control->fXrunDelayedUsecs : 0.f);
1678  }
1679 }
1680 
1681 LIB_EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
1682 {
1683  JackGlobals::CheckContext("jack_reset_max_delayed_usecs");
1684 
1685  JackClient* client = (JackClient*)ext_client;
1686  if (client == NULL) {
1687  jack_error("jack_reset_max_delayed_usecs called with a NULL client");
1688  } else {
1689  JackEngineControl* control = GetEngineControl();
1690  control->ResetXRun();
1691  }
1692 }
1693 
1694 // thread.h
1695 LIB_EXPORT int jack_client_real_time_priority(jack_client_t* ext_client)
1696 {
1697  JackGlobals::CheckContext("jack_client_real_time_priority");
1698 
1699  JackClient* client = (JackClient*)ext_client;
1700  if (client == NULL) {
1701  jack_error("jack_client_real_time_priority called with a NULL client");
1702  return -1;
1703  } else {
1704  JackEngineControl* control = GetEngineControl();
1705  return (control->fRealTime) ? control->fClientPriority : -1;
1706  }
1707 }
1708 
1709 LIB_EXPORT int jack_client_max_real_time_priority(jack_client_t* ext_client)
1710 {
1711  JackGlobals::CheckContext("jack_client_max_real_time_priority");
1712 
1713  JackClient* client = (JackClient*)ext_client;
1714  if (client == NULL) {
1715  jack_error("jack_client_max_real_time_priority called with a NULL client");
1716  return -1;
1717  } else {
1718  JackEngineControl* control = GetEngineControl();
1719  return (control->fRealTime) ? control->fMaxClientPriority : -1;
1720  }
1721 }
1722 
1723 LIB_EXPORT int jack_acquire_real_time_scheduling(jack_native_thread_t thread, int priority)
1724 {
1725  JackEngineControl* control = GetEngineControl();
1726  return (control
1727  ? JackThread::AcquireRealTimeImp(thread, priority, control->fPeriod, control->fComputation, control->fConstraint)
1728  : -1);
1729 }
1730 
1731 LIB_EXPORT int jack_client_create_thread(jack_client_t* client,
1732  jack_native_thread_t *thread,
1733  int priority,
1734  int realtime, /* boolean */
1735  thread_routine routine,
1736  void *arg)
1737 {
1738  JackGlobals::CheckContext("jack_client_create_thread");
1739 
1740  JackEngineControl* control = GetEngineControl();
1741  int res = JackThread::StartImp(thread, priority, realtime, routine, arg);
1742  return (res == 0)
1743  ? ((realtime ? JackThread::AcquireRealTimeImp(*thread, priority, control->fPeriod, control->fComputation, control->fConstraint) : res))
1744  : res;
1745 }
1746 
1747 LIB_EXPORT int jack_drop_real_time_scheduling(jack_native_thread_t thread)
1748 {
1749  return JackThread::DropRealTimeImp(thread);
1750 }
1751 
1752 LIB_EXPORT int jack_client_stop_thread(jack_client_t* client, jack_native_thread_t thread)
1753 {
1754  JackGlobals::CheckContext("jack_client_stop_thread");
1755  return JackThread::StopImp(thread);
1756 }
1757 
1758 LIB_EXPORT int jack_client_kill_thread(jack_client_t* client, jack_native_thread_t thread)
1759 {
1760  JackGlobals::CheckContext("jack_client_kill_thread");
1761  return JackThread::KillImp(thread);
1762 }
1763 
1764 #ifndef WIN32
1765 LIB_EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc)
1766 {
1767  if (jtc == NULL) {
1768  JackGlobals::fJackThreadCreator = pthread_create;
1769  } else {
1770  JackGlobals::fJackThreadCreator = jtc;
1771  }
1772 }
1773 #endif
1774 
1775 // intclient.h
1776 LIB_EXPORT int jack_internal_client_new (const char* client_name,
1777  const char* load_name,
1778  const char* load_init)
1779 {
1780  JackGlobals::CheckContext("jack_internal_client_new");
1781  jack_error("jack_internal_client_new: deprecated");
1782  return -1;
1783 }
1784 
1785 LIB_EXPORT void jack_internal_client_close (const char* client_name)
1786 {
1787  JackGlobals::CheckContext("jack_internal_client_close");
1788  jack_error("jack_internal_client_close: deprecated");
1789 }
1790 
1791 LIB_EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
1792 {
1793  JackGlobals::CheckContext("jack_get_internal_client_name");
1794 
1795  JackClient* client = (JackClient*)ext_client;
1796  if (client == NULL) {
1797  jack_error("jack_get_internal_client_name called with a NULL client");
1798  return NULL;
1799  } else if (intclient >= CLIENT_NUM) {
1800  jack_error("jack_get_internal_client_name: incorrect client");
1801  return NULL;
1802  } else {
1803  return client->GetInternalClientName(intclient);
1804  }
1805 }
1806 
1807 LIB_EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, const char* client_name, jack_status_t* status)
1808 {
1809  JackGlobals::CheckContext("jack_internal_client_handle");
1810 
1811  JackClient* client = (JackClient*)ext_client;
1812  if (client == NULL) {
1813  jack_error("jack_internal_client_handle called with a NULL client");
1814  return 0;
1815  } else {
1816  jack_status_t my_status;
1817  if (status == NULL) /* no status from caller? */
1818  status = &my_status; /* use local status word */
1819  *status = (jack_status_t)0;
1820  return client->InternalClientHandle(client_name, status);
1821  }
1822 }
1823 
1824 static jack_intclient_t jack_internal_client_load_aux(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, va_list ap)
1825 {
1826  JackGlobals::CheckContext("jack_internal_client_load_aux");
1827 
1828  JackClient* client = (JackClient*)ext_client;
1829  if (client == NULL) {
1830  jack_error("jack_internal_client_load called with a NULL client");
1831  return 0;
1832  } else {
1833  jack_varargs_t va;
1834  jack_status_t my_status;
1835 
1836  if (status == NULL) /* no status from caller? */
1837  status = &my_status; /* use local status word */
1838  *status = (jack_status_t)0;
1839 
1840  /* validate parameters */
1841  if ((options & ~JackLoadOptions)) {
1842  int my_status1 = *status | (JackFailure | JackInvalidOption);
1843  *status = (jack_status_t)my_status1;
1844  return 0;
1845  }
1846 
1847  /* parse variable arguments */
1848  jack_varargs_parse(options, ap, &va);
1849  return client->InternalClientLoad(client_name, options, status, &va);
1850  }
1851 }
1852 
1853 LIB_EXPORT jack_intclient_t jack_internal_client_load(jack_client_t *client, const char* client_name, jack_options_t options, jack_status_t *status, ...)
1854 {
1855  JackGlobals::CheckContext("jack_internal_client_load");
1856 
1857  va_list ap;
1858  va_start(ap, status);
1859  jack_intclient_t res = jack_internal_client_load_aux(client, client_name, options, status, ap);
1860  va_end(ap);
1861  return res;
1862 }
1863 
1864 LIB_EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
1865 {
1866  JackGlobals::CheckContext("jack_internal_client_load");
1867 
1868  JackClient* client = (JackClient*)ext_client;
1869  if (client == NULL) {
1870  jack_error("jack_internal_client_unload called with a NULL client");
1871  return (jack_status_t)(JackNoSuchClient | JackFailure);
1872  } else if (intclient >= CLIENT_NUM) {
1873  jack_error("jack_internal_client_unload: incorrect client");
1874  return (jack_status_t)(JackNoSuchClient | JackFailure);
1875  } else {
1876  jack_status_t my_status;
1877  client->InternalClientUnload(intclient, &my_status);
1878  return my_status;
1879  }
1880 }
1881 
1882 LIB_EXPORT void jack_get_version(int *major_ptr,
1883  int *minor_ptr,
1884  int *micro_ptr,
1885  int *proto_ptr)
1886 {
1887  JackGlobals::CheckContext("jack_get_version");
1888 
1889  // FIXME: We need these comming from build system
1890  *major_ptr = 0;
1891  *minor_ptr = 0;
1892  *micro_ptr = 0;
1893  *proto_ptr = 0;
1894 }
1895 
1896 LIB_EXPORT const char* jack_get_version_string()
1897 {
1898  JackGlobals::CheckContext("jack_get_version_string");
1899  return VERSION;
1900 }
1901 
1902 LIB_EXPORT void jack_free(void* ptr)
1903 {
1904  JackGlobals::CheckContext("jack_free");
1905 
1906  if (ptr) {
1907  free(ptr);
1908  }
1909 }
1910 
1911 // session.h
1912 LIB_EXPORT int jack_set_session_callback(jack_client_t* ext_client, JackSessionCallback session_callback, void* arg)
1913 {
1914  JackGlobals::CheckContext("jack_set_session_callback");
1915 
1916  JackClient* client = (JackClient*)ext_client;
1917  jack_log("jack_set_session_callback ext_client %x client %x ", ext_client, client);
1918  if (client == NULL) {
1919  jack_error("jack_set_session_callback called with a NULL client");
1920  return -1;
1921  } else {
1922  return client->SetSessionCallback(session_callback, arg);
1923  }
1924 }
1925 
1926 LIB_EXPORT jack_session_command_t* jack_session_notify(jack_client_t* ext_client, const char* target, jack_session_event_type_t ev_type, const char* path)
1927 {
1928  JackGlobals::CheckContext("jack_session_notify");
1929 
1930  JackClient* client = (JackClient*)ext_client;
1931  jack_log("jack_session_notify ext_client %x client %x ", ext_client, client);
1932  if (client == NULL) {
1933  jack_error("jack_session_notify called with a NULL client");
1934  return NULL;
1935  } else {
1936  return client->SessionNotify(target, ev_type, path);
1937  }
1938 }
1939 
1940 LIB_EXPORT int jack_session_reply(jack_client_t* ext_client, jack_session_event_t *event)
1941 {
1942  JackGlobals::CheckContext("jack_session_reply");
1943 
1944  JackClient* client = (JackClient*)ext_client;
1945  jack_log("jack_session_reply ext_client %x client %x ", ext_client, client);
1946  if (client == NULL) {
1947  jack_error("jack_session_reply called with a NULL client");
1948  return -1;
1949  } else {
1950  return client->SessionReply(event);
1951  }
1952 }
1953 
1955 {
1956  JackGlobals::CheckContext("jack_session_event_free");
1957 
1958  if (ev) {
1959  if (ev->session_dir)
1960  free((void *)ev->session_dir);
1961  if (ev->client_uuid)
1962  free((void *)ev->client_uuid);
1963  if (ev->command_line)
1964  free(ev->command_line);
1965  free(ev);
1966  }
1967 }
1968 
1969 LIB_EXPORT char *jack_client_get_uuid(jack_client_t* ext_client)
1970 {
1971  JackGlobals::CheckContext("jack_client_get_uuid");
1972 
1973  JackClient* client = (JackClient*)ext_client;
1974  if (client == NULL) {
1975  jack_error("jack_client_get_uuid called with a NULL client");
1976  return NULL;
1977  } else {
1978  char retval[16];
1979  snprintf(retval, sizeof(retval), "%d", client->GetClientControl()->fSessionID);
1980  return strdup(retval);
1981  }
1982 }
1983 
1984 LIB_EXPORT char* jack_get_uuid_for_client_name(jack_client_t* ext_client, const char* client_name)
1985 {
1986  JackGlobals::CheckContext("jack_get_uuid_for_client_name");
1987 
1988  JackClient* client = (JackClient*)ext_client;
1989  jack_log("jack_get_uuid_for_client_name ext_client %x client %x ", ext_client, client);
1990  if (client == NULL) {
1991  jack_error("jack_get_uuid_for_client_name called with a NULL client");
1992  return NULL;
1993  } else {
1994  return client->GetUUIDForClientName(client_name);
1995  }
1996 }
1997 
1998 LIB_EXPORT char* jack_get_client_name_by_uuid(jack_client_t* ext_client, const char* client_uuid)
1999 {
2000  JackGlobals::CheckContext("jack_get_client_name_by_uuid");
2001 
2002  JackClient* client = (JackClient*)ext_client;
2003  jack_log("jack_get_uuid_for_client_name ext_client %x client %x ", ext_client, client);
2004  if (client == NULL) {
2005  jack_error("jack_get_client_name_by_uuid called with a NULL client");
2006  return NULL;
2007  } else {
2008  return client->GetClientNameByUUID(client_uuid);
2009  }
2010 }
2011 
2012 LIB_EXPORT int jack_reserve_client_name(jack_client_t* ext_client, const char* client_name, const char* uuid)
2013 {
2014  JackGlobals::CheckContext("jack_reserve_client_name");
2015 
2016  JackClient* client = (JackClient*)ext_client;
2017  jack_log("jack_reserve_client_name ext_client %x client %x ", ext_client, client);
2018  if (client == NULL) {
2019  jack_error("jack_reserve_client_name called with a NULL client");
2020  return -1;
2021  } else {
2022  return client->ReserveClientName(client_name, uuid);
2023  }
2024 }
2025 
2027 {
2028  JackGlobals::CheckContext("jack_session_commands_free");
2029 
2030 
2031  if (!cmds) {
2032  return;
2033  }
2034 
2035  int i = 0;
2036  while (1) {
2037  if (cmds[i].client_name) {
2038  free ((char *)cmds[i].client_name);
2039  }
2040  if (cmds[i].command) {
2041  free ((char *)cmds[i].command);
2042  }
2043  if (cmds[i].uuid) {
2044  free ((char *)cmds[i].uuid);
2045  } else {
2046  break;
2047  }
2048 
2049  i += 1;
2050  }
2051 
2052  free(cmds);
2053 }
2054 
2055 LIB_EXPORT int jack_client_has_session_callback(jack_client_t* ext_client, const char* client_name)
2056 {
2057  JackGlobals::CheckContext("jack_client_has_session_callback");
2058 
2059  JackClient* client = (JackClient*)ext_client;
2060  jack_log("jack_client_has_session_callback ext_client %x client %x ", ext_client, client);
2061  if (client == NULL) {
2062  jack_error("jack_client_has_session_callback called with a NULL client");
2063  return -1;
2064  } else {
2065  return client->ClientHasSessionCallback(client_name);
2066  }
2067 }
2068 
2069 LIB_EXPORT int jack_set_property(jack_client_t*, jack_uuid_t, const char*, const char*, const char*)
2070 {
2071  return -1;
2072 }
2073 
2074 LIB_EXPORT int jack_get_property(jack_uuid_t, const char*, char**, char**)
2075 {
2076  return -1;
2077 }
2078 
2080 {
2081 }
2082 
2083 LIB_EXPORT int jack_get_properties(jack_uuid_t, jack_description_t*)
2084 {
2085  return -1;
2086 }
2087 
2089 {
2090  return -1;
2091 }
2092 
2093 LIB_EXPORT int jack_remove_property(jack_client_t*, jack_uuid_t, const char*)
2094 {
2095  return -1;
2096 }
2097 
2098 LIB_EXPORT int jack_remove_properties(jack_client_t*, jack_uuid_t)
2099 {
2100  return -1;
2101 }
2102 
2103 LIB_EXPORT int jack_remove_all_properties(jack_client_t*)
2104 {
2105  return -1;
2106 }
2107 
2108 LIB_EXPORT int jack_set_property_change_callback(jack_client_t*, JackPropertyChangeCallback, void*)
2109 {
2110  return -1;
2111 }
2112 
2113 LIB_EXPORT jack_uuid_t jack_client_uuid_generate()
2114 {
2115  return 0;
2116 }
2117 
2118 LIB_EXPORT jack_uuid_t jack_port_uuid_generate(uint32_t)
2119 {
2120  return 0;
2121 }
2122 
2123 LIB_EXPORT uint32_t jack_uuid_to_index(jack_uuid_t)
2124 {
2125  return 0;
2126 }
2127 
2128 LIB_EXPORT int jack_uuid_compare(jack_uuid_t, jack_uuid_t)
2129 {
2130  return 0;
2131 }
2132 
2133 LIB_EXPORT void jack_uuid_copy(jack_uuid_t*, jack_uuid_t)
2134 {
2135 }
2136 
2137 LIB_EXPORT void jack_uuid_clear(jack_uuid_t*)
2138 {
2139 }
2140 
2141 LIB_EXPORT int jack_uuid_parse(const char*, jack_uuid_t*)
2142 {
2143  return 0;
2144 }
2145 
2146 LIB_EXPORT void jack_uuid_unparse(jack_uuid_t, char buf[JACK_UUID_STRING_SIZE])
2147 {
2148 }
2149 
2150 LIB_EXPORT int jack_uuid_empty(jack_uuid_t)
2151 {
2152  return 0;
2153 }
LIB_EXPORT int jack_remove_properties(jack_client_t *client, jack_uuid_t subject)
Definition: JackAPI.cpp:2098
LIB_EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t *, jack_port_t *port)
Definition: JackAPI.cpp:1170
LIB_EXPORT int jack_set_client_registration_callback(jack_client_t *, JackClientRegistrationCallback registration_callback, void *arg)
Definition: JackAPI.cpp:947
LIB_EXPORT int jack_get_property(jack_uuid_t subject, const char *key, char **value, char **type)
Definition: JackAPI.cpp:2074
LIB_EXPORT int jack_port_request_monitor(jack_port_t *port, int onoff)
Definition: JackAPI.cpp:710
LIB_EXPORT int jack_set_freewheel_callback(jack_client_t *client, JackFreewheelCallback freewheel_callback, void *arg)
Definition: JackAPI.cpp:880
T * ReadCurrentState()
Returns the current state : only valid in the RT reader thread.
LIB_EXPORT int jack_set_graph_order_callback(jack_client_t *, JackGraphOrderCallback graph_callback, void *)
Definition: JackAPI.cpp:999
LIB_EXPORT int jack_set_buffer_size(jack_client_t *client, jack_nframes_t nframes)
Definition: JackAPI.cpp:906
A structure used for time management.
LIB_EXPORT int jack_port_unregister(jack_client_t *, jack_port_t *)
Definition: JackAPI.cpp:1095
LIB_EXPORT int jack_port_tie(jack_port_t *src, jack_port_t *dst)
Definition: JackAPI.cpp:498
LIB_EXPORT int jack_set_thread_init_callback(jack_client_t *client, JackThreadInitCallback thread_init_callback, void *arg)
Definition: JackAPI.cpp:1039
LIB_EXPORT int jack_set_session_callback(jack_client_t *ext_client, JackSessionCallback session_callback, void *arg)
Definition: JackAPI.cpp:1912
const char * client_uuid
Definition: JackSession.h:48
LIB_EXPORT jack_port_type_id_t jack_port_type_id(const jack_port_t *port)
Definition: JackAPI.cpp:442
LIB_EXPORT int jack_port_set_name(jack_port_t *port, const char *port_name)
Definition: JackAPI.cpp:635
LIB_EXPORT jack_port_t * jack_port_by_id(jack_client_t *client, jack_port_id_t port_id)
Definition: JackAPI.cpp:1312
LIB_EXPORT void jack_port_set_latency(jack_port_t *, jack_nframes_t)
Definition: JackAPI.cpp:554
LIB_EXPORT int jack_port_set_alias(jack_port_t *port, const char *alias)
Definition: JackAPI.cpp:659
LIB_EXPORT void jack_set_transport_info(jack_client_t *client, jack_transport_info_t *tinfo)
Definition: JackAPI.cpp:1643
LIB_EXPORT int jack_port_ensure_monitor(jack_port_t *port, int onoff)
Definition: JackAPI.cpp:747
LIB_EXPORT int jack_client_real_time_priority(jack_client_t *)
Definition: JackAPI.cpp:1695
LIB_EXPORT void jack_cycle_signal(jack_client_t *, int status)
Definition: JackAPI.cpp:855
LIB_EXPORT jack_transport_state_t jack_transport_query(const jack_client_t *client, jack_position_t *pos)
Definition: JackAPI.cpp:1569
LIB_EXPORT void jack_internal_client_close(const char *client_name)
Definition: JackAPI.cpp:1785
LIB_EXPORT jack_nframes_t jack_cycle_wait(jack_client_t *)
Definition: JackAPI.cpp:842
const char * session_dir
Definition: JackSession.h:47
LIB_EXPORT int jack_port_name_size(void)
Definition: JackAPI.cpp:1473
LIB_EXPORT int jack_set_process_callback(jack_client_t *client, JackProcessCallback process_callback, void *arg)
Definition: JackAPI.cpp:815
LIB_EXPORT int jack_recompute_total_latency(jack_client_t *, jack_port_t *port)
Definition: JackAPI.cpp:601
LIB_EXPORT int jack_activate(jack_client_t *client)
Definition: JackAPI.cpp:1053
LIB_EXPORT int jack_client_stop_thread(jack_client_t *client, jack_native_thread_t thread)
Definition: JackAPI.cpp:1752
LIB_EXPORT const char * jack_port_type(const jack_port_t *port)
Definition: JackAPI.cpp:427
LIB_EXPORT int jack_get_properties(jack_uuid_t subject, jack_description_t *desc)
Definition: JackAPI.cpp:2083
virtual int Deactivate()
Need to stop thread after deactivating in the server.
Definition: JackClient.cpp:464
SERVER_EXPORT void(* jack_info_callback)(const char *desc)
Definition: JackError.cpp:137
void jack_set_info_function(void(*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT
LIB_EXPORT int jack_set_property_change_callback(jack_client_t *client, JackPropertyChangeCallback callback, void *arg)
Definition: JackAPI.cpp:2108
LIB_EXPORT jack_native_thread_t jack_client_thread_id(jack_client_t *)
Definition: JackAPI.cpp:1442
LIB_EXPORT const char ** jack_port_get_connections(const jack_port_t *port)
Definition: JackAPI.cpp:1131
SERVER_EXPORT void jack_error(const char *fmt,...)
Definition: JackError.cpp:92
LIB_EXPORT int jack_port_disconnect(jack_client_t *, jack_port_t *)
Definition: JackAPI.cpp:1229
LIB_EXPORT void jack_port_set_latency_range(jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range)
Definition: JackAPI.cpp:585
LIB_EXPORT jack_time_t jack_get_time()
Definition: JackAPI.cpp:1348
LIB_EXPORT char * jack_get_client_name_by_uuid(jack_client_t *ext_client, const char *client_uuid)
Definition: JackAPI.cpp:1998
LIB_EXPORT char * jack_client_get_uuid(jack_client_t *client)
Definition: JackAPI.cpp:1969
LIB_EXPORT int jack_connect(jack_client_t *, const char *source_port, const char *destination_port)
Definition: JackAPI.cpp:1197
LIB_EXPORT jack_uuid_t jack_port_uuid(const jack_port_t *)
Definition: JackAPI.cpp:377
LIB_EXPORT int jack_disconnect(jack_client_t *, const char *source_port, const char *destination_port)
Definition: JackAPI.cpp:1213
LIB_EXPORT jack_port_t * jack_port_register(jack_client_t *client, const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size)
Definition: JackAPI.cpp:1079
LIB_EXPORT int jack_release_timebase(jack_client_t *client)
Definition: JackAPI.cpp:1503
LIB_EXPORT int jack_remove_property(jack_client_t *client, jack_uuid_t subject, const char *key)
Definition: JackAPI.cpp:2093
LIB_EXPORT const char ** jack_port_get_all_connections(const jack_client_t *client, const jack_port_t *port)
Definition: JackAPI.cpp:1148
LIB_EXPORT int jack_acquire_real_time_scheduling(jack_native_thread_t thread, int priority)
Definition: JackAPI.cpp:1723
LIB_EXPORT int jack_port_type_size(void)
Definition: JackAPI.cpp:1478
LIB_EXPORT void jack_on_shutdown(jack_client_t *client, JackShutdownCallback shutdown_callback, void *arg)
Definition: JackAPI.cpp:791
SERVER_EXPORT void(* jack_error_callback)(const char *desc)
Definition: JackError.cpp:136
LIB_EXPORT int jack_set_port_connect_callback(jack_client_t *, JackPortConnectCallback connect_callback, void *arg)
Definition: JackAPI.cpp:973
LIB_EXPORT int jack_remove_all_properties(jack_client_t *client)
Definition: JackAPI.cpp:2103
LIB_EXPORT jack_client_t * jack_client_open(const char *client_name, jack_options_t options, jack_status_t *status,...)
Definition: JackLibAPI.cpp:167
LIB_EXPORT jack_nframes_t jack_frame_time(const jack_client_t *)
Definition: JackAPI.cpp:1395
LIB_EXPORT char * jack_get_client_name(jack_client_t *client)
Definition: JackAPI.cpp:1455
LIB_EXPORT int jack_set_property(jack_client_t *, jack_uuid_t subject, const char *key, const char *value, const char *type)
Definition: JackAPI.cpp:2069
LIB_EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t *client)
Definition: JackAPI.cpp:1402
LIB_EXPORT int jack_port_monitoring_input(jack_port_t *port)
Definition: JackAPI.cpp:762
LIB_EXPORT int jack_client_has_session_callback(jack_client_t *client, const char *client_name)
Definition: JackAPI.cpp:2055
void jack_set_error_function(void(*func)(const char *)) JACK_OPTIONAL_WEAK_EXPORT
Graph manager: contains the connection manager and the port array.
LIB_EXPORT void jack_transport_start(jack_client_t *client)
Definition: JackAPI.cpp:1609
LIB_EXPORT void jack_session_commands_free(jack_session_command_t *cmds)
Definition: JackAPI.cpp:2026
LIB_EXPORT int jack_set_port_rename_callback(jack_client_t *, JackPortRenameCallback rename_callback, void *arg)
Definition: JackAPI.cpp:986
LIB_EXPORT int jack_set_xrun_callback(jack_client_t *, JackXRunCallback xrun_callback, void *arg)
Definition: JackAPI.cpp:1013
LIB_EXPORT int jack_set_sync_timeout(jack_client_t *client, jack_time_t timeout)
Definition: JackAPI.cpp:1529
LIB_EXPORT jack_session_command_t * jack_session_notify(jack_client_t *ext_client, const char *target, jack_session_event_type_t ev_type, const char *path)
Definition: JackAPI.cpp:1926
virtual int Activate()
We need to start thread before activating in the server, otherwise the FW driver connected to the cli...
Definition: JackClient.cpp:431
LIB_EXPORT int jack_reserve_client_name(jack_client_t *ext_client, const char *name, const char *uuid)
Definition: JackAPI.cpp:2012
LIB_EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t *)
Definition: JackAPI.cpp:1261
LIB_EXPORT jack_nframes_t jack_port_get_latency(jack_port_t *port)
Definition: JackAPI.cpp:538
LIB_EXPORT int jack_port_untie(jack_port_t *port)
Definition: JackAPI.cpp:523
LIB_EXPORT int jack_client_max_real_time_priority(jack_client_t *)
Definition: JackAPI.cpp:1709
LIB_EXPORT void jack_set_thread_creator(jack_thread_creator_t jtc)
Definition: JackAPI.cpp:1765
LIB_EXPORT int jack_set_sample_rate_callback(jack_client_t *client, JackSampleRateCallback srate_callback, void *arg)
Definition: JackAPI.cpp:934
LIB_EXPORT int jack_transport_locate(jack_client_t *client, jack_nframes_t frame)
Definition: JackAPI.cpp:1555
LIB_EXPORT void * jack_port_get_buffer(jack_port_t *, jack_nframes_t)
Definition: JackAPI.cpp:362
LIB_EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames)
Definition: JackAPI.cpp:1355
LIB_EXPORT int jack_port_get_aliases(const jack_port_t *port, char *const aliases[2])
Definition: JackAPI.cpp:695
LIB_EXPORT void jack_transport_stop(jack_client_t *client)
Definition: JackAPI.cpp:1621
LIB_EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t *)
Definition: JackAPI.cpp:1334
LIB_EXPORT int jack_recompute_total_latencies(jack_client_t *)
Definition: JackAPI.cpp:622
LIB_EXPORT int jack_get_all_properties(jack_description_t **descs)
Definition: JackAPI.cpp:2088
LIB_EXPORT int jack_port_connected_to(const jack_port_t *port, const char *port_name)
Definition: JackAPI.cpp:473
LIB_EXPORT int jack_port_is_mine(const jack_client_t *, const jack_port_t *port)
Definition: JackAPI.cpp:1113
LIB_EXPORT int jack_port_unset_alias(jack_port_t *port, const char *alias)
Definition: JackAPI.cpp:677
LIB_EXPORT int jack_client_create_thread(jack_client_t *client, jack_native_thread_t *thread, int priority, int realtime, thread_routine routine, void *arg)
Definition: JackAPI.cpp:1731
LIB_EXPORT void jack_free_description(jack_description_t *desc, int free_description_itself)
Definition: JackAPI.cpp:2079
LIB_EXPORT int jack_drop_real_time_scheduling(jack_native_thread_t thread)
Definition: JackAPI.cpp:1747
LIB_EXPORT int jack_transport_reposition(jack_client_t *client, const jack_position_t *pos)
Definition: JackAPI.cpp:1595
LIB_EXPORT jack_port_t * jack_port_by_name(jack_client_t *, const char *port_name)
Definition: JackAPI.cpp:1288
LIB_EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t *)
Definition: JackAPI.cpp:1247
LIB_EXPORT int jack_set_timebase_callback(jack_client_t *client, int conditional, JackTimebaseCallback timebase_callback, void *arg)
Definition: JackAPI.cpp:1542
LIB_EXPORT size_t jack_port_type_get_buffer_size(jack_client_t *client, const char *port_type)
Definition: JackAPI.cpp:1483
LIB_EXPORT int jack_set_buffer_size_callback(jack_client_t *client, JackBufferSizeCallback bufsize_callback, void *arg)
Definition: JackAPI.cpp:921
LIB_EXPORT float jack_cpu_load(jack_client_t *client)
Definition: JackAPI.cpp:1428
LIB_EXPORT int jack_set_sync_callback(jack_client_t *client, JackSyncCallback sync_callback, void *arg)
Definition: JackAPI.cpp:1516
LIB_EXPORT int jack_port_connected(const jack_port_t *port)
Definition: JackAPI.cpp:457
LIB_EXPORT void jack_on_info_shutdown(jack_client_t *client, JackInfoShutdownCallback shutdown_callback, void *arg)
Definition: JackAPI.cpp:803
LIB_EXPORT int jack_port_request_monitor_by_name(jack_client_t *client, const char *port_name, int onoff)
Definition: JackAPI.cpp:725
int RequestMonitor(jack_port_id_t port_index, bool onoff)
LIB_EXPORT int jack_internal_client_new(const char *client_name, const char *load_name, const char *load_init)
Definition: JackAPI.cpp:1776
LIB_EXPORT char * jack_get_uuid_for_client_name(jack_client_t *ext_client, const char *client_name)
Definition: JackAPI.cpp:1984
LIB_EXPORT int jack_session_reply(jack_client_t *ext_client, jack_session_event_t *event)
Definition: JackAPI.cpp:1940
LIB_EXPORT int jack_engine_takeover_timebase(jack_client_t *)
Definition: JackAPI.cpp:1320
LIB_EXPORT int jack_get_cycle_times(const jack_client_t *client, jack_nframes_t *current_frames, jack_time_t *current_usecs, jack_time_t *next_usecs, float *period_usecs)
Definition: JackAPI.cpp:1410
Engine control in shared memory.
LIB_EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status)
Definition: JackAPI.cpp:828
LIB_EXPORT const char * jack_port_name(const jack_port_t *port)
Definition: JackAPI.cpp:382
LIB_EXPORT int jack_client_name_size(void)
Definition: JackAPI.cpp:1468
LIB_EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t usecs)
Definition: JackAPI.cpp:1375
LIB_EXPORT const char ** jack_get_ports(jack_client_t *, const char *port_name_pattern, const char *type_name_pattern, unsigned long flags)
Definition: JackAPI.cpp:1275
LIB_EXPORT int jack_port_flags(const jack_port_t *port)
Definition: JackAPI.cpp:412
LIB_EXPORT int jack_set_port_registration_callback(jack_client_t *, JackPortRegistrationCallback registration_callback, void *arg)
Definition: JackAPI.cpp:960
LIB_EXPORT int jack_deactivate(jack_client_t *client)
Definition: JackAPI.cpp:1066
LIB_EXPORT jack_client_t * jack_client_new(const char *client_name)
Definition: JackAPI.cpp:338
LIB_EXPORT int jack_set_process_thread(jack_client_t *client, JackThreadCallback fun, void *arg)
Definition: JackAPI.cpp:867
LIB_EXPORT void jack_get_transport_info(jack_client_t *client, jack_transport_info_t *tinfo)
Definition: JackAPI.cpp:1634
SERVER_EXPORT void jack_log(const char *fmt,...)
Definition: JackError.cpp:108
LIB_EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t *client)
Definition: JackAPI.cpp:1582
void(* JackSessionCallback)(jack_session_event_t *event, void *arg)
Definition: session.h:162
LIB_EXPORT void jack_port_get_latency_range(jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range)
Definition: JackAPI.cpp:569
LIB_EXPORT const char * jack_port_short_name(const jack_port_t *port)
Definition: JackAPI.cpp:397
int EnsureMonitor(bool onoff)
Definition: JackPort.cpp:176
The base class for clients: share part of the implementation for JackInternalClient and JackLibClient...
Definition: JackClient.h:47
LIB_EXPORT int jack_client_kill_thread(jack_client_t *client, jack_native_thread_t thread)
Definition: JackAPI.cpp:1758
LIB_EXPORT void jack_session_event_free(jack_session_event_t *ev)
Definition: JackAPI.cpp:1954
LIB_EXPORT int jack_set_freewheel(jack_client_t *client, int onoff)
Definition: JackAPI.cpp:893