jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1455 lines
63KB

  1. /*
  2. Copyright (C) 2008 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include "types.h"
  16. #include "jack.h"
  17. #include "JackExports.h"
  18. #include "varargs.h"
  19. #include "JackConstants.h"
  20. #include <dlfcn.h>
  21. #include <stdarg.h>
  22. #include <stdio.h>
  23. #include <dirent.h>
  24. #include <unistd.h>
  25. #include <errno.h>
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. EXPORT int jack_client_name_size (void);
  31. EXPORT char* jack_get_client_name (jack_client_t *client);
  32. EXPORT int jack_internal_client_new (const char *client_name, // deprecated
  33. const char *load_name,
  34. const char *load_init);
  35. EXPORT void jack_internal_client_close (const char *client_name); // deprecated
  36. EXPORT int jack_is_realtime (jack_client_t *client);
  37. EXPORT void jack_on_shutdown (jack_client_t *client,
  38. void (*function)(void *arg), void *arg);
  39. EXPORT int jack_set_process_callback (jack_client_t *client,
  40. JackProcessCallback process_callback,
  41. void *arg);
  42. EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status);
  43. EXPORT jack_nframes_t jack_cycle_wait (jack_client_t*);
  44. EXPORT void jack_cycle_signal (jack_client_t*, int status);
  45. EXPORT int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg);
  46. EXPORT int jack_set_thread_init_callback (jack_client_t *client,
  47. JackThreadInitCallback thread_init_callback,
  48. void *arg);
  49. EXPORT int jack_set_freewheel_callback (jack_client_t *client,
  50. JackFreewheelCallback freewheel_callback,
  51. void *arg);
  52. EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
  53. EXPORT int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
  54. EXPORT int jack_set_buffer_size_callback (jack_client_t *client,
  55. JackBufferSizeCallback bufsize_callback,
  56. void *arg);
  57. EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
  58. JackSampleRateCallback srate_callback,
  59. void *arg);
  60. EXPORT int jack_set_client_registration_callback (jack_client_t *,
  61. JackClientRegistrationCallback
  62. registration_callback, void *arg);
  63. EXPORT int jack_set_port_registration_callback (jack_client_t *,
  64. JackPortRegistrationCallback
  65. registration_callback, void *arg);
  66. EXPORT int jack_set_port_connect_callback (jack_client_t *,
  67. JackPortConnectCallback
  68. connect_callback, void *arg);
  69. EXPORT int jack_set_graph_order_callback (jack_client_t *,
  70. JackGraphOrderCallback graph_callback,
  71. void *);
  72. EXPORT int jack_set_xrun_callback (jack_client_t *,
  73. JackXRunCallback xrun_callback, void *arg);
  74. EXPORT int jack_activate (jack_client_t *client);
  75. EXPORT int jack_deactivate (jack_client_t *client);
  76. EXPORT jack_port_t * jack_port_register (jack_client_t *client,
  77. const char *port_name,
  78. const char *port_type,
  79. unsigned long flags,
  80. unsigned long buffer_size);
  81. EXPORT int jack_port_unregister (jack_client_t *, jack_port_t *);
  82. EXPORT void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
  83. EXPORT const char * jack_port_name (const jack_port_t *port);
  84. EXPORT const char * jack_port_short_name (const jack_port_t *port);
  85. EXPORT int jack_port_flags (const jack_port_t *port);
  86. EXPORT const char * jack_port_type (const jack_port_t *port);
  87. EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
  88. EXPORT int jack_port_connected (const jack_port_t *port);
  89. EXPORT int jack_port_connected_to (const jack_port_t *port,
  90. const char *port_name);
  91. EXPORT const char ** jack_port_get_connections (const jack_port_t *port);
  92. EXPORT const char ** jack_port_get_all_connections (const jack_client_t *client,
  93. const jack_port_t *port);
  94. EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst);
  95. EXPORT int jack_port_untie (jack_port_t *port);
  96. EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port);
  97. EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *,
  98. jack_port_t *port);
  99. EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t);
  100. EXPORT int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
  101. EXPORT int jack_recompute_total_latencies (jack_client_t*);
  102. EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name);
  103. EXPORT int jack_port_set_alias (jack_port_t *port, const char *alias);
  104. EXPORT int jack_port_unset_alias (jack_port_t *port, const char *alias);
  105. EXPORT int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
  106. EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff);
  107. EXPORT int jack_port_request_monitor_by_name (jack_client_t *client,
  108. const char *port_name, int onoff);
  109. EXPORT int jack_port_ensure_monitor (jack_port_t *port, int onoff);
  110. EXPORT int jack_port_monitoring_input (jack_port_t *port);
  111. EXPORT int jack_connect (jack_client_t *,
  112. const char *source_port,
  113. const char *destination_port);
  114. EXPORT int jack_disconnect (jack_client_t *,
  115. const char *source_port,
  116. const char *destination_port);
  117. EXPORT int jack_port_disconnect (jack_client_t *, jack_port_t *);
  118. EXPORT int jack_port_name_size(void);
  119. EXPORT int jack_port_type_size(void);
  120. EXPORT jack_nframes_t jack_get_sample_rate (jack_client_t *);
  121. EXPORT jack_nframes_t jack_get_buffer_size (jack_client_t *);
  122. EXPORT const char ** jack_get_ports (jack_client_t *,
  123. const char *port_name_pattern,
  124. const char *type_name_pattern,
  125. unsigned long flags);
  126. EXPORT jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
  127. EXPORT jack_port_t * jack_port_by_id (jack_client_t *client,
  128. jack_port_id_t port_id);
  129. EXPORT int jack_engine_takeover_timebase (jack_client_t *);
  130. EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
  131. EXPORT jack_time_t jack_get_time();
  132. EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t time);
  133. EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames);
  134. EXPORT jack_nframes_t jack_frame_time (const jack_client_t *);
  135. EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client);
  136. EXPORT float jack_cpu_load (jack_client_t *client);
  137. EXPORT pthread_t jack_client_thread_id (jack_client_t *);
  138. EXPORT void jack_set_error_function (void (*func)(const char *));
  139. EXPORT void jack_set_info_function (void (*func)(const char *));
  140. EXPORT float jack_get_max_delayed_usecs (jack_client_t *client);
  141. EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client);
  142. EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client);
  143. EXPORT int jack_release_timebase (jack_client_t *client);
  144. EXPORT int jack_set_sync_callback (jack_client_t *client,
  145. JackSyncCallback sync_callback,
  146. void *arg);
  147. EXPORT int jack_set_sync_timeout (jack_client_t *client,
  148. jack_time_t timeout);
  149. EXPORT int jack_set_timebase_callback (jack_client_t *client,
  150. int conditional,
  151. JackTimebaseCallback timebase_callback,
  152. void *arg);
  153. EXPORT int jack_transport_locate (jack_client_t *client,
  154. jack_nframes_t frame);
  155. EXPORT jack_transport_state_t jack_transport_query (const jack_client_t *client,
  156. jack_position_t *pos);
  157. EXPORT jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
  158. EXPORT int jack_transport_reposition (jack_client_t *client,
  159. jack_position_t *pos);
  160. EXPORT void jack_transport_start (jack_client_t *client);
  161. EXPORT void jack_transport_stop (jack_client_t *client);
  162. EXPORT void jack_get_transport_info (jack_client_t *client,
  163. jack_transport_info_t *tinfo);
  164. EXPORT void jack_set_transport_info (jack_client_t *client,
  165. jack_transport_info_t *tinfo);
  166. EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
  167. EXPORT int jack_client_create_thread (jack_client_t* client,
  168. pthread_t *thread,
  169. int priority,
  170. int realtime, // boolean
  171. void *(*start_routine)(void*),
  172. void *arg);
  173. EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
  174. EXPORT char * jack_get_internal_client_name (jack_client_t *client,
  175. jack_intclient_t intclient);
  176. EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client,
  177. const char *client_name,
  178. jack_status_t *status);
  179. EXPORT jack_intclient_t jack_internal_client_load (jack_client_t *client,
  180. const char *client_name,
  181. jack_options_t options,
  182. jack_status_t *status, ...);
  183. EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
  184. jack_intclient_t intclient);
  185. EXPORT jack_client_t * jack_client_open (const char *client_name,
  186. jack_options_t options,
  187. jack_status_t *status, ...);
  188. EXPORT jack_client_t * jack_client_new (const char *client_name);
  189. EXPORT int jack_client_close (jack_client_t *client);
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193. #define JACK_LIB "libjack.so.0.0"
  194. #define JACKMP_LIB "libjackmp.so"
  195. // client
  196. static void* gLibrary = 0;
  197. static bool open_library();
  198. static void close_library();
  199. static void (*error_fun)(const char *) = 0;
  200. static void (*info_fun)(const char *) = 0;
  201. static void RewriteName(const char* name, char* new_name)
  202. {
  203. size_t i;
  204. for (i = 0; i < strlen(name); i++) {
  205. if ((name[i] == '/') || (name[i] == '\\'))
  206. new_name[i] = '_';
  207. else
  208. new_name[i] = name[i];
  209. }
  210. new_name[i] = '\0';
  211. }
  212. static void jack_log(const char *fmt,...)
  213. {
  214. /*
  215. va_list ap;
  216. va_start(ap, fmt);
  217. f//printf(stderr,"Jack: ");
  218. vfprintf(stderr, fmt, ap);
  219. fprintf(stderr,"\n");
  220. va_end(ap);
  221. */
  222. }
  223. /* Exec the JACK server in this process. Does not return. */
  224. static void start_server_aux(const char* server_name)
  225. {
  226. FILE* fp = 0;
  227. char filename[255];
  228. char arguments[255];
  229. char buffer[255];
  230. char* command = 0;
  231. size_t pos = 0;
  232. size_t result = 0;
  233. char** argv = 0;
  234. int i = 0;
  235. int good = 0;
  236. int ret;
  237. jack_log("start_server_aux");
  238. snprintf(filename, 255, "%s/.jackdrc", getenv("HOME"));
  239. fp = fopen(filename, "r");
  240. if (!fp) {
  241. fp = fopen("/etc/jackdrc", "r");
  242. }
  243. /* if still not found, check old config name for backwards compatability */
  244. if (!fp) {
  245. fp = fopen("/etc/jackd.conf", "r");
  246. }
  247. if (fp) {
  248. arguments[0] = '\0';
  249. ret = fscanf(fp, "%s", buffer);
  250. while (ret != 0 && ret != EOF) {
  251. strcat(arguments, buffer);
  252. strcat(arguments, " ");
  253. ret = fscanf(fp, "%s", buffer);
  254. }
  255. if (strlen(arguments) > 0) {
  256. good = 1;
  257. }
  258. fclose(fp);
  259. }
  260. if (!good) {
  261. command = (char*)(JACK_LOCATION "/jackd");
  262. strncpy(arguments, JACK_LOCATION "/jackd -T -d "JACK_DEFAULT_DRIVER, 255);
  263. } else {
  264. result = strcspn(arguments, " ");
  265. command = (char*)malloc(result + 1);
  266. strncpy(command, arguments, result);
  267. command[result] = '\0';
  268. }
  269. argv = (char**)malloc(255);
  270. while (1) {
  271. /* insert -T and -nserver_name in front of arguments */
  272. if (i == 1) {
  273. argv[i] = (char*)malloc(strlen ("-T") + 1);
  274. strcpy (argv[i++], "-T");
  275. if (server_name) {
  276. size_t optlen = strlen("-n");
  277. char* buf = (char*)malloc(optlen + strlen(server_name) + 1);
  278. strcpy(buf, "-n");
  279. strcpy(buf + optlen, server_name);
  280. argv[i++] = buf;
  281. }
  282. }
  283. result = strcspn(arguments + pos, " ");
  284. if (result == 0) {
  285. break;
  286. }
  287. argv[i] = (char*)malloc(result + 1);
  288. strncpy(argv[i], arguments + pos, result);
  289. argv[i][result] = '\0';
  290. pos += result + 1;
  291. ++i;
  292. }
  293. argv[i] = 0;
  294. execv(command, argv);
  295. /* If execv() succeeds, it does not return. There's no point
  296. * in calling jack_error() here in the child process. */
  297. fprintf(stderr, "exec of JACK server (command = \"%s\") failed: %s\n", command, strerror(errno));
  298. }
  299. int start_server(const char* server_name, jack_options_t options)
  300. {
  301. jack_log("start_server 0");
  302. if ((options & JackNoStartServer) || getenv("JACK_NO_START_SERVER")) {
  303. return 1;
  304. }
  305. jack_log("start_server 1");
  306. /* The double fork() forces the server to become a child of
  307. * init, which will always clean up zombie process state on
  308. * termination. This even works in cases where the server
  309. * terminates but this client does not.
  310. *
  311. * Since fork() is usually implemented using copy-on-write
  312. * virtual memory tricks, the overhead of the second fork() is
  313. * probably relatively small.
  314. */
  315. switch (fork()) {
  316. case 0: /* child process */
  317. switch (fork()) {
  318. case 0: /* grandchild process */
  319. start_server_aux(server_name);
  320. _exit(99); /* exec failed */
  321. case - 1:
  322. _exit(98);
  323. default:
  324. _exit(0);
  325. }
  326. case - 1: /* fork() error */
  327. return 1; /* failed to start server */
  328. }
  329. /* only the original parent process goes here */
  330. sleep(1);
  331. return 0; /* (probably) successful */
  332. }
  333. // Function definition
  334. typedef void* (*jack_port_get_buffer_fun_def)(jack_port_t* port, jack_nframes_t frames);
  335. static jack_port_get_buffer_fun_def jack_port_get_buffer_fun = 0;
  336. EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
  337. {
  338. jack_log("jack_port_get_buffer");
  339. return (*jack_port_get_buffer_fun)(port, frames);
  340. }
  341. typedef const char* (*jack_port_name_fun_def)(const jack_port_t* port);
  342. static jack_port_name_fun_def jack_port_name_fun = 0;
  343. EXPORT const char* jack_port_name(const jack_port_t* port)
  344. {
  345. jack_log("jack_port_name");
  346. return (*jack_port_name_fun)(port);
  347. }
  348. typedef const char* (*jack_port_short_name_fun_def) (const jack_port_t* port);
  349. static jack_port_short_name_fun_def jack_port_short_name_fun = 0;
  350. EXPORT const char* jack_port_short_name(const jack_port_t* port)
  351. {
  352. jack_log("jack_port_short_name");
  353. return (*jack_port_short_name_fun)(port);
  354. }
  355. typedef int (*jack_port_flags_fun_def)(const jack_port_t* port);
  356. static jack_port_flags_fun_def jack_port_flags_fun = 0;
  357. EXPORT int jack_port_flags(const jack_port_t* port)
  358. {
  359. jack_log("jack_port_flags");
  360. return (*jack_port_flags_fun)(port);
  361. }
  362. typedef const char* (*jack_port_type_fun_def)(const jack_port_t* port);
  363. static jack_port_type_fun_def jack_port_type_fun = 0;
  364. EXPORT const char* jack_port_type(const jack_port_t* port)
  365. {
  366. jack_log("jack_port_type");
  367. return (*jack_port_type_fun)(port);
  368. }
  369. typedef int (*jack_port_connected_fun_def)(const jack_port_t* port);
  370. static jack_port_connected_fun_def jack_port_connected_fun = 0;
  371. EXPORT int jack_port_connected(const jack_port_t* port)
  372. {
  373. jack_log("jack_port_connected");
  374. return (*jack_port_connected_fun)(port);
  375. }
  376. typedef int (*jack_port_connected_to_fun_def)(const jack_port_t* port, const char* portname);
  377. static jack_port_connected_to_fun_def jack_port_connected_to_fun = 0;
  378. EXPORT int jack_port_connected_to(const jack_port_t* port, const char* portname)
  379. {
  380. jack_log("jack_port_connected_to");
  381. return (*jack_port_connected_to_fun)(port, portname);
  382. }
  383. typedef int (*jack_port_tie_fun_def)(jack_port_t* src, jack_port_t* dst);
  384. static jack_port_tie_fun_def jack_port_tie_fun = 0;
  385. EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
  386. {
  387. jack_log("jack_port_tie");
  388. return (*jack_port_tie_fun)(src, dst);
  389. }
  390. typedef int (*jack_port_untie_fun_def)(jack_port_t* port);
  391. static jack_port_untie_fun_def jack_port_untie_fun = 0;
  392. EXPORT int jack_port_untie(jack_port_t* port)
  393. {
  394. jack_log("jack_port_untie");
  395. return (*jack_port_untie_fun)(port);
  396. }
  397. typedef jack_nframes_t (*jack_port_get_latency_fun_def)(jack_port_t* port);
  398. static jack_port_get_latency_fun_def jack_port_get_latency_fun = 0;
  399. EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
  400. {
  401. jack_log("jack_port_get_latency");
  402. return (*jack_port_get_latency_fun)(port);
  403. }
  404. typedef void (*jack_port_set_latency_fun_def)(jack_port_t* port, jack_nframes_t frames);
  405. static jack_port_set_latency_fun_def jack_port_set_latency_fun = 0;
  406. EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
  407. {
  408. jack_log("jack_port_set_latency");
  409. (*jack_port_set_latency_fun)(port, frames);
  410. }
  411. typedef int (*jack_recompute_total_latency_fun_def)(jack_client_t* ext_client, jack_port_t* port);
  412. static jack_recompute_total_latency_fun_def jack_recompute_total_latency_fun = 0;
  413. EXPORT int jack_recompute_total_latency(jack_client_t* ext_client, jack_port_t* port)
  414. {
  415. jack_log("jack_recompute_total_latency");
  416. return (*jack_recompute_total_latency_fun)(ext_client, port);
  417. }
  418. typedef int (*jack_recompute_total_latencies_fun_def)(jack_client_t* ext_client);
  419. static jack_recompute_total_latencies_fun_def jack_recompute_total_latencies_fun = 0;
  420. EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
  421. {
  422. jack_log("jack_recompute_total_latencies");
  423. return (*jack_recompute_total_latencies_fun)(ext_client);
  424. }
  425. typedef int (*jack_port_set_name_fun_def)(jack_port_t* port, const char* name);
  426. static jack_port_set_name_fun_def jack_port_set_name_fun = 0;
  427. EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
  428. {
  429. jack_log("jack_port_set_name");
  430. return (*jack_port_set_name_fun)(port, name);
  431. }
  432. typedef int (*jack_port_set_alias_fun_def)(jack_port_t* port, const char* alias);
  433. static jack_port_set_alias_fun_def jack_port_set_alias_fun = 0;
  434. EXPORT int jack_port_set_alias(jack_port_t* port, const char* alias)
  435. {
  436. jack_log("jack_port_set_alias");
  437. return (*jack_port_set_alias_fun)(port, alias);
  438. }
  439. typedef int (*jack_port_unset_alias_fun_def)(jack_port_t* port, const char* alias);
  440. static jack_port_unset_alias_fun_def jack_port_unset_alias_fun = 0;
  441. EXPORT int jack_port_unset_alias(jack_port_t* port, const char* alias)
  442. {
  443. jack_log("jack_port_unset_alias");
  444. return (*jack_port_unset_alias_fun)(port, alias);
  445. }
  446. typedef int (*jack_port_get_aliases_fun_def)(jack_port_t* port, char* const aliases[2]);
  447. static jack_port_get_aliases_fun_def jack_port_get_aliases_fun = 0;
  448. EXPORT int jack_port_get_aliases(jack_port_t* port, char* const aliases[2])
  449. {
  450. jack_log("jack_port_get_aliases");
  451. return (*jack_port_get_aliases_fun)(port, aliases);
  452. }
  453. typedef int (*jack_port_request_monitor_fun_def)(jack_port_t* port, int onoff);
  454. static jack_port_request_monitor_fun_def jack_port_request_monitor_fun = 0;
  455. EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
  456. {
  457. jack_log("jack_port_request_monitor");
  458. return (*jack_port_request_monitor_fun)(port, onoff);
  459. }
  460. typedef int (*jack_port_request_monitor_by_name_fun_def)(jack_client_t* ext_client, const char* port_name, int onoff);
  461. static jack_port_request_monitor_by_name_fun_def jack_port_request_monitor_by_name_fun = 0;
  462. EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
  463. {
  464. jack_log("jack_port_request_monitor_by_name");
  465. return (*jack_port_request_monitor_by_name_fun)(ext_client, port_name, onoff);
  466. }
  467. typedef int (*jack_port_ensure_monitor_fun_def)(jack_port_t* port, int onoff);
  468. static jack_port_ensure_monitor_fun_def jack_port_ensure_monitor_fun = 0;
  469. EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
  470. {
  471. jack_log("jack_port_ensure_monitor");
  472. return (*jack_port_ensure_monitor_fun)(port, onoff);
  473. }
  474. typedef int (*jack_port_monitoring_input_fun_def)(jack_port_t* port);
  475. static jack_port_monitoring_input_fun_def jack_port_monitoring_input_fun = 0;
  476. EXPORT int jack_port_monitoring_input(jack_port_t* port)
  477. {
  478. jack_log("jack_port_monitoring_input");
  479. return (*jack_port_monitoring_input_fun)(port);
  480. }
  481. typedef int (*jack_is_realtime_fun_def)(jack_client_t* ext_client);
  482. static jack_is_realtime_fun_def jack_is_realtime_fun = 0;
  483. EXPORT int jack_is_realtime(jack_client_t* ext_client)
  484. {
  485. jack_log("jack_is_realtime");
  486. return (*jack_is_realtime_fun)(ext_client);
  487. }
  488. typedef void (*shutdown_fun)(void* arg);
  489. typedef void (*jack_on_shutdown_fun_def)(jack_client_t* ext_client, shutdown_fun callback, void* arg);
  490. static jack_on_shutdown_fun_def jack_on_shutdown_fun = 0;
  491. EXPORT void jack_on_shutdown(jack_client_t* ext_client, shutdown_fun callback, void* arg)
  492. {
  493. jack_log("jack_on_shutdown");
  494. (*jack_on_shutdown_fun)(ext_client, callback, arg);
  495. }
  496. typedef int (*jack_set_process_callback_fun_def)(jack_client_t* ext_client, JackProcessCallback callback, void* arg);
  497. static jack_set_process_callback_fun_def jack_set_process_callback_fun = 0;
  498. EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
  499. {
  500. jack_log("jack_set_process_callback");
  501. return (*jack_set_process_callback_fun)(ext_client, callback, arg);
  502. }
  503. typedef jack_nframes_t (*jack_cycle_wait_fun_def)(jack_client_t* ext_client);
  504. static jack_cycle_wait_fun_def jack_cycle_wait_fun = 0;
  505. EXPORT jack_nframes_t jack_cycle_wait(jack_client_t* ext_client)
  506. {
  507. jack_log("jack_cycle_wait");
  508. return (*jack_cycle_wait_fun)(ext_client);
  509. }
  510. typedef void (*jack_cycle_signal_fun_def)(jack_client_t* ext_client, int status);
  511. static jack_cycle_signal_fun_def jack_cycle_signal_fun = 0;
  512. EXPORT void jack_cycle_signal(jack_client_t* ext_client, int status)
  513. {
  514. jack_log("jack_cycle_signal");
  515. (*jack_cycle_signal_fun)(ext_client, status);
  516. }
  517. typedef jack_nframes_t (*jack_thread_wait_fun_def)(jack_client_t* ext_client, int status);
  518. static jack_thread_wait_fun_def jack_thread_wait_fun = 0;
  519. EXPORT jack_nframes_t jack_thread_wait(jack_client_t* ext_client, int status)
  520. {
  521. jack_log("jack_thread_wait");
  522. return (*jack_thread_wait_fun)(ext_client, status);
  523. }
  524. typedef int (*jack_set_freewheel_callback_fun_def)(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg);
  525. static jack_set_freewheel_callback_fun_def jack_set_freewheel_callback_fun = 0;
  526. EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
  527. {
  528. jack_log("jack_set_freewheel_callback");
  529. return (*jack_set_freewheel_callback_fun)(ext_client, freewheel_callback, arg);
  530. }
  531. typedef int (*jack_set_freewheel_fun_def)(jack_client_t* ext_client, int onoff);
  532. static jack_set_freewheel_fun_def jack_set_freewheel_fun = 0;
  533. EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
  534. {
  535. jack_log("jack_set_freewheel");
  536. return (*jack_set_freewheel_fun)(ext_client, onoff);
  537. }
  538. typedef int (*jack_set_buffer_size_fun_def)(jack_client_t* ext_client, jack_nframes_t buffer_size);
  539. static jack_set_buffer_size_fun_def jack_set_buffer_size_fun = 0;
  540. EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
  541. {
  542. jack_log("jack_set_buffer_size");
  543. return (*jack_set_buffer_size_fun)(ext_client, buffer_size);
  544. }
  545. typedef int (*jack_set_buffer_size_callback_fun_def)(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg);
  546. static jack_set_buffer_size_callback_fun_def jack_set_buffer_size_callback_fun = 0;
  547. EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
  548. {
  549. jack_log("jack_set_buffer_size_callback");
  550. return (*jack_set_buffer_size_callback_fun)(ext_client, bufsize_callback, arg);
  551. }
  552. typedef int (*jack_set_sample_rate_callback_fun_def)(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg);
  553. static jack_set_sample_rate_callback_fun_def jack_set_sample_rate_callback_fun = 0;
  554. EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
  555. {
  556. jack_log("jack_set_sample_rate_callback");
  557. return (*jack_set_sample_rate_callback_fun)(ext_client, srate_callback, arg);
  558. }
  559. typedef int (*jack_set_client_registration_callback_fun_def)(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg);
  560. static jack_set_client_registration_callback_fun_def jack_set_client_registration_callback_fun = 0;
  561. EXPORT int jack_set_client_registration_callback(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg)
  562. {
  563. jack_log("jack_set_client_registration_callback");
  564. return (*jack_set_client_registration_callback_fun)(ext_client, registration_callback, arg);
  565. }
  566. typedef int (*jack_set_port_registration_callback_fun_def)(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg);
  567. static jack_set_port_registration_callback_fun_def jack_set_port_registration_callback_fun = 0;
  568. EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
  569. {
  570. jack_log("jack_set_port_registration_callback");
  571. return (*jack_set_port_registration_callback_fun)(ext_client, registration_callback, arg);
  572. }
  573. typedef int (*jack_set_port_connect_callback_fun_def)(jack_client_t* ext_client, JackPortConnectCallback connect_callback, void* arg);
  574. static jack_set_port_connect_callback_fun_def jack_set_port_connect_callback_fun = 0;
  575. EXPORT int jack_set_port_connect_callback(jack_client_t* ext_client, JackPortConnectCallback connect_callback, void* arg)
  576. {
  577. jack_log("jack_set_port_connect_callback");
  578. return (*jack_set_port_connect_callback_fun)(ext_client, connect_callback, arg);
  579. }
  580. typedef int (*jack_set_graph_order_callback_fun_def)(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg);
  581. static jack_set_graph_order_callback_fun_def jack_set_graph_order_callback_fun = 0;
  582. EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
  583. {
  584. jack_log("jack_set_graph_order_callback");
  585. return (*jack_set_graph_order_callback_fun)(ext_client, graph_callback, arg);
  586. }
  587. typedef int (*jack_set_xrun_callback_fun_def)(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg);
  588. static jack_set_xrun_callback_fun_def jack_set_xrun_callback_fun = 0;
  589. EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
  590. {
  591. jack_log("jack_set_xrun_callback");
  592. return (*jack_set_xrun_callback_fun)(ext_client, xrun_callback, arg);
  593. }
  594. typedef int (*jack_set_thread_init_callback_fun_def)(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg);
  595. static jack_set_thread_init_callback_fun_def jack_set_thread_init_callback_fun = 0;
  596. EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
  597. {
  598. jack_log("jack_set_thread_init_callback");
  599. return (*jack_set_thread_init_callback_fun)(ext_client, init_callback, arg);
  600. }
  601. typedef int (*jack_activate_fun_def)(jack_client_t* ext_client);
  602. static jack_activate_fun_def jack_activate_fun = 0;
  603. EXPORT int jack_activate(jack_client_t* ext_client)
  604. {
  605. jack_log("jack_activate");
  606. return (*jack_activate_fun)(ext_client);
  607. }
  608. typedef int (*jack_deactivate_fun_def)(jack_client_t* ext_client);
  609. static jack_deactivate_fun_def jack_deactivate_fun = 0;
  610. EXPORT int jack_deactivate(jack_client_t* ext_client)
  611. {
  612. jack_log("jack_deactivate");
  613. return (*jack_deactivate_fun)(ext_client);
  614. }
  615. typedef jack_port_t* (*jack_port_register_fun_def)(jack_client_t* ext_client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
  616. static jack_port_register_fun_def jack_port_register_fun = 0;
  617. 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)
  618. {
  619. jack_log("jack_port_register");
  620. return (*jack_port_register_fun)(ext_client, port_name, port_type, flags, buffer_size);
  621. }
  622. typedef int (*jack_port_unregister_fun_def)(jack_client_t* ext_client, jack_port_t* port);
  623. static jack_port_unregister_fun_def jack_port_unregister_fun = 0;
  624. EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port)
  625. {
  626. jack_log("jack_port_unregister");
  627. return (*jack_port_unregister_fun)(ext_client, port);
  628. }
  629. typedef int (*jack_port_is_mine_fun_def)(const jack_client_t* ext_client, const jack_port_t* port);
  630. static jack_port_is_mine_fun_def jack_port_is_mine_fun = 0;
  631. EXPORT int jack_port_is_mine(const jack_client_t* ext_client, const jack_port_t* port)
  632. {
  633. jack_log("jack_port_is_mine");
  634. return (*jack_port_is_mine_fun)(ext_client, port);
  635. }
  636. typedef const char** (*jack_port_get_connections_fun_def)(const jack_port_t* port);
  637. static jack_port_get_connections_fun_def jack_port_get_connections_fun = 0;
  638. EXPORT const char** jack_port_get_connections(const jack_port_t* port)
  639. {
  640. jack_log("jack_port_get_connections");
  641. return (*jack_port_get_connections_fun)(port);
  642. }
  643. // Calling client does not need to "own" the port
  644. typedef const char** (*jack_port_get_all_connections_fun_def)(const jack_client_t* ext_client, const jack_port_t* port);
  645. static jack_port_get_all_connections_fun_def jack_port_get_all_connections_fun = 0;
  646. EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_client, const jack_port_t* port)
  647. {
  648. jack_log("jack_port_get_all_connections");
  649. return (*jack_port_get_all_connections_fun)(ext_client, port);
  650. }
  651. typedef jack_nframes_t (*jack_port_get_total_latency_fun_def)(jack_client_t* ext_client, jack_port_t* port);
  652. static jack_port_get_total_latency_fun_def jack_port_get_total_latency_fun = 0;
  653. EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port)
  654. {
  655. jack_log("jack_port_get_total_latency");
  656. return (*jack_port_get_total_latency_fun)(ext_client, port);
  657. }
  658. typedef int (*jack_connect_fun_def)(jack_client_t* ext_client, const char* src, const char* dst);
  659. static jack_connect_fun_def jack_connect_fun = 0;
  660. EXPORT int jack_connect(jack_client_t* ext_client, const char* src, const char* dst)
  661. {
  662. jack_log("jack_connect");
  663. return (*jack_connect_fun)(ext_client, src, dst);
  664. }
  665. typedef int (*jack_disconnect_fun_def)(jack_client_t* ext_client, const char* src, const char* dst);
  666. static jack_disconnect_fun_def jack_disconnect_fun = 0;
  667. EXPORT int jack_disconnect(jack_client_t* ext_client, const char* src, const char* dst)
  668. {
  669. jack_log("jack_disconnect");
  670. return (*jack_disconnect_fun)(ext_client, src, dst);
  671. }
  672. typedef int (*jack_port_disconnect_fun_def)(jack_client_t* ext_client, jack_port_t* src);
  673. static jack_port_disconnect_fun_def jack_port_disconnect_fun = 0;
  674. EXPORT int jack_port_disconnect(jack_client_t* ext_client, jack_port_t* src)
  675. {
  676. jack_log("jack_port_disconnect");
  677. return (*jack_port_disconnect_fun)(ext_client, src);
  678. }
  679. typedef jack_nframes_t (*jack_get_sample_rate_fun_def)(jack_client_t* ext_client);
  680. static jack_get_sample_rate_fun_def jack_get_sample_rate_fun = 0;
  681. EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t* ext_client)
  682. {
  683. jack_log("jack_get_sample_rate");
  684. return (*jack_get_sample_rate_fun)(ext_client);
  685. }
  686. typedef jack_nframes_t (*jack_get_buffer_size_fun_def)(jack_client_t* ext_client);
  687. static jack_get_buffer_size_fun_def jack_get_buffer_size_fun = 0;
  688. EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client)
  689. {
  690. jack_log("jack_get_buffer_size");
  691. return (*jack_get_buffer_size_fun)(ext_client);
  692. }
  693. typedef const char** (*jack_get_ports_fun_def)(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  694. static jack_get_ports_fun_def jack_get_ports_fun = 0;
  695. EXPORT const char** jack_get_ports(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
  696. {
  697. jack_log("jack_get_ports");
  698. return (*jack_get_ports_fun)(ext_client, port_name_pattern, type_name_pattern, flags);
  699. }
  700. typedef jack_port_t* (*jack_port_by_name_fun_def)(jack_client_t* ext_client, const char* portname);
  701. static jack_port_by_name_fun_def jack_port_by_name_fun = 0;
  702. EXPORT jack_port_t* jack_port_by_name(jack_client_t* ext_client, const char* portname)
  703. {
  704. jack_log("jack_port_by_name");
  705. return (*jack_port_by_name_fun)(ext_client, portname);
  706. }
  707. typedef jack_port_t* (*jack_port_by_id_fun_def)(const jack_client_t* ext_client, jack_port_id_t id);
  708. static jack_port_by_id_fun_def jack_port_by_id_fun = 0;
  709. EXPORT jack_port_t* jack_port_by_id(const jack_client_t* ext_client, jack_port_id_t id)
  710. {
  711. jack_log("jack_port_by_id");
  712. return (*jack_port_by_id_fun)(ext_client, id);
  713. }
  714. typedef int (*jack_engine_takeover_timebase_fun_def)(jack_client_t* ext_client);
  715. static jack_engine_takeover_timebase_fun_def jack_engine_takeover_timebase_fun = 0;
  716. EXPORT int jack_engine_takeover_timebase(jack_client_t* ext_client)
  717. {
  718. jack_log("jack_engine_takeover_timebase");
  719. return (*jack_engine_takeover_timebase_fun)(ext_client);
  720. }
  721. typedef jack_nframes_t (*jack_frames_since_cycle_start_fun_def)(const jack_client_t* ext_client);
  722. static jack_frames_since_cycle_start_fun_def jack_frames_since_cycle_start_fun = 0;
  723. EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t* ext_client)
  724. {
  725. jack_log("jack_frames_since_cycle_start");
  726. return (*jack_frames_since_cycle_start_fun)(ext_client);
  727. }
  728. typedef jack_time_t (*jack_get_time_fun_def)();
  729. static jack_get_time_fun_def jack_get_time_fun = 0;
  730. EXPORT jack_time_t jack_get_time()
  731. {
  732. jack_log("jack_get_time");
  733. return (*jack_get_time_fun)();
  734. }
  735. typedef jack_nframes_t (*jack_time_to_frames_fun_def)(const jack_client_t* ext_client, jack_time_t time);
  736. static jack_time_to_frames_fun_def jack_time_to_frames_fun = 0;
  737. EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t* ext_client, jack_time_t time)
  738. {
  739. jack_log("jack_time_to_frames");
  740. return (*jack_time_to_frames_fun)(ext_client, time);
  741. }
  742. typedef jack_time_t (*jack_frames_to_time_fun_def)(const jack_client_t* ext_client, jack_nframes_t frames);
  743. static jack_frames_to_time_fun_def jack_frames_to_time_fun = 0;
  744. EXPORT jack_time_t jack_frames_to_time(const jack_client_t* ext_client, jack_nframes_t frames)
  745. {
  746. jack_log("jack_frames_to_time");
  747. return (*jack_frames_to_time_fun)(ext_client, frames);
  748. }
  749. typedef jack_nframes_t (*jack_frame_time_fun_def)(const jack_client_t* ext_client);
  750. static jack_frame_time_fun_def jack_frame_time_fun = 0;
  751. EXPORT jack_nframes_t jack_frame_time(const jack_client_t* ext_client)
  752. {
  753. jack_log("jack_frame_time");
  754. return (*jack_frame_time_fun)(ext_client);
  755. }
  756. typedef jack_nframes_t (*jack_last_frame_time_fun_def)(const jack_client_t* ext_client);
  757. static jack_last_frame_time_fun_def jack_last_frame_time_fun = 0;
  758. EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
  759. {
  760. jack_log("jack_last_frame_time");
  761. return (*jack_last_frame_time_fun)(ext_client);
  762. }
  763. typedef float (*jack_cpu_load_fun_def)(jack_client_t* ext_client);
  764. static jack_cpu_load_fun_def jack_cpu_load_fun = 0;
  765. EXPORT float jack_cpu_load(jack_client_t* ext_client)
  766. {
  767. jack_log("jack_cpu_load");
  768. return (*jack_cpu_load_fun)(ext_client);
  769. }
  770. typedef pthread_t (*jack_client_thread_id_fun_def)(jack_client_t* ext_client);
  771. static jack_client_thread_id_fun_def jack_client_thread_id_fun = 0;
  772. EXPORT pthread_t jack_client_thread_id(jack_client_t* ext_client)
  773. {
  774. jack_log("jack_client_thread_id");
  775. return (*jack_client_thread_id_fun)(ext_client);
  776. }
  777. typedef void (*jack_set_error_function_fun_def)(void (*func)(const char *));
  778. static jack_set_error_function_fun_def jack_set_error_function_fun = 0;
  779. EXPORT void jack_set_error_function(void (*func)(const char *))
  780. {
  781. jack_log("jack_set_error_function");
  782. if (gLibrary) {
  783. (*jack_set_error_function_fun)(func);
  784. } else {
  785. error_fun = func; // Keep the function
  786. }
  787. }
  788. typedef void (*jack_set_info_function_fun_def)(void (*func)(const char *));
  789. static jack_set_info_function_fun_def jack_set_info_function_fun = 0;
  790. EXPORT void jack_set_info_function(void (*func)(const char *))
  791. {
  792. jack_log("jack_set_info_function");
  793. if (gLibrary) {
  794. (*jack_set_error_function_fun)(func);
  795. } else {
  796. info_fun = func; // Keep the function
  797. }
  798. }
  799. typedef char* (*jack_get_client_name_fun_def)(jack_client_t* ext_client);
  800. static jack_get_client_name_fun_def jack_get_client_name_fun = 0;
  801. EXPORT char* jack_get_client_name (jack_client_t* ext_client)
  802. {
  803. jack_log("jack_get_client_name");
  804. return (*jack_get_client_name_fun)(ext_client);
  805. }
  806. typedef int (*jack_internal_client_new_fun_def)(const char *client_name,
  807. const char *load_name,
  808. const char *load_init);
  809. static jack_internal_client_new_fun_def jack_internal_client_new_fun = 0;
  810. EXPORT int jack_internal_client_new (const char *client_name,
  811. const char *load_name,
  812. const char *load_init)
  813. {
  814. jack_log("jack_internal_client_new");
  815. return (*jack_internal_client_new_fun)(client_name, load_name, load_init);
  816. }
  817. typedef void (*jack_internal_client_close_fun_def)(const char *client_name);
  818. static jack_internal_client_close_fun_def jack_internal_client_close_fun = 0;
  819. EXPORT void jack_internal_client_close (const char *client_name)
  820. {
  821. jack_log("jack_internal_client_close");
  822. (*jack_internal_client_close_fun)(client_name);
  823. }
  824. typedef int (*jack_client_name_size_fun_def)(void);
  825. static jack_client_name_size_fun_def jack_client_name_size_fun = 0;
  826. EXPORT int jack_client_name_size(void)
  827. {
  828. jack_log("jack_client_name_size");
  829. return (*jack_client_name_size_fun)();
  830. }
  831. typedef int (*jack_port_name_size_fun_def)(void);
  832. static jack_port_name_size_fun_def jack_port_name_size_fun = 0;
  833. EXPORT int jack_port_name_size(void)
  834. {
  835. jack_log("jack_port_name_size");
  836. return (*jack_port_name_size_fun)();
  837. }
  838. typedef int (*jack_port_type_size_fun_def)(void);
  839. static jack_port_type_size_fun_def jack_port_type_size_fun = 0;
  840. EXPORT int jack_port_type_size(void)
  841. {
  842. jack_log("jack_port_type_size");
  843. return (*jack_port_type_size_fun)();
  844. }
  845. // transport.h
  846. typedef int (*jack_release_timebase_fun_def)(jack_client_t* ext_client);
  847. static jack_release_timebase_fun_def jack_release_timebase_fun = 0;
  848. EXPORT int jack_release_timebase(jack_client_t* ext_client)
  849. {
  850. jack_log("jack_release_timebase");
  851. return (*jack_release_timebase_fun)(ext_client);
  852. }
  853. typedef int (*jack_set_sync_callback_fun_def)(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg);
  854. static jack_set_sync_callback_fun_def jack_set_sync_callback_fun = 0;
  855. EXPORT int jack_set_sync_callback(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg)
  856. {
  857. jack_log("jack_set_sync_callback");
  858. return (*jack_set_sync_callback_fun)(ext_client, sync_callback, arg);
  859. }
  860. typedef int (*jack_set_sync_timeout_fun_def)(jack_client_t* ext_client, jack_time_t timeout);
  861. static jack_set_sync_timeout_fun_def jack_set_sync_timeout_fun = 0;
  862. EXPORT int jack_set_sync_timeout(jack_client_t* ext_client, jack_time_t timeout)
  863. {
  864. jack_log("jack_set_sync_timeout");
  865. return (*jack_set_sync_timeout_fun)(ext_client, timeout);
  866. }
  867. typedef int (*jack_set_timebase_callback_fun_def)(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg);
  868. static jack_set_timebase_callback_fun_def jack_set_timebase_callback_fun = 0;
  869. EXPORT int jack_set_timebase_callback(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg)
  870. {
  871. jack_log("jack_set_timebase_callback");
  872. return (*jack_set_timebase_callback_fun)(ext_client, conditional, timebase_callback, arg);
  873. }
  874. typedef int (*jack_transport_locate_fun_def)(jack_client_t* ext_client, jack_nframes_t frame);
  875. static jack_transport_locate_fun_def jack_transport_locate_fun = 0;
  876. EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame)
  877. {
  878. jack_log("jack_transport_locate");
  879. return (*jack_transport_locate_fun)(ext_client, frame);
  880. }
  881. typedef jack_transport_state_t (*jack_transport_query_fun_def)(const jack_client_t* ext_client, jack_position_t* pos);
  882. static jack_transport_query_fun_def jack_transport_query_fun = 0;
  883. EXPORT jack_transport_state_t jack_transport_query(const jack_client_t* ext_client, jack_position_t* pos)
  884. {
  885. jack_log("jack_transport_query");
  886. return (*jack_transport_query_fun)(ext_client, pos);
  887. }
  888. typedef jack_nframes_t (*jack_get_current_transport_frame_fun_def)(const jack_client_t* ext_client);
  889. static jack_get_current_transport_frame_fun_def jack_get_current_transport_frame_fun = 0;
  890. EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t* ext_client)
  891. {
  892. jack_log("jack_get_current_transport_frame");
  893. return (*jack_get_current_transport_frame_fun)(ext_client);
  894. }
  895. typedef int (*jack_transport_reposition_fun_def)(jack_client_t* ext_client, jack_position_t* pos);
  896. static jack_transport_reposition_fun_def jack_transport_reposition_fun = 0;
  897. EXPORT int jack_transport_reposition(jack_client_t* ext_client, jack_position_t* pos)
  898. {
  899. jack_log("jack_transport_reposition");
  900. return (*jack_transport_reposition_fun)(ext_client, pos);
  901. }
  902. typedef void (*jack_transport_start_fun_def)(jack_client_t* ext_client);
  903. static jack_transport_start_fun_def jack_transport_start_fun = 0;
  904. EXPORT void jack_transport_start(jack_client_t* ext_client)
  905. {
  906. jack_log("jack_transport_start");
  907. (*jack_transport_start_fun)(ext_client);
  908. }
  909. typedef void (*jack_transport_stop_fun_def)(jack_client_t* ext_client);
  910. static jack_transport_stop_fun_def jack_transport_stop_fun = 0;
  911. EXPORT void jack_transport_stop(jack_client_t* ext_client)
  912. {
  913. jack_log("jack_transport_stop");
  914. (*jack_transport_stop_fun)(ext_client);
  915. }
  916. // deprecated
  917. typedef void (*jack_get_transport_info_fun_def)(jack_client_t* ext_client, jack_transport_info_t* tinfo);
  918. static jack_get_transport_info_fun_def jack_get_transport_info_fun = 0;
  919. EXPORT void jack_get_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  920. {
  921. jack_log("jack_get_transport_info");
  922. (*jack_get_transport_info_fun)(ext_client, tinfo);
  923. }
  924. typedef void (*jack_set_transport_info_fun_def)(jack_client_t* ext_client, jack_transport_info_t* tinfo);
  925. static jack_set_transport_info_fun_def jack_set_transport_info_fun = 0;
  926. EXPORT void jack_set_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  927. {
  928. jack_log("jack_set_transport_info");
  929. (*jack_set_transport_info_fun)(ext_client, tinfo);
  930. }
  931. // statistics.h
  932. typedef float (*jack_get_max_delayed_usecs_fun_def)(jack_client_t* ext_client);
  933. static jack_get_max_delayed_usecs_fun_def jack_get_max_delayed_usecs_fun = 0;
  934. EXPORT float jack_get_max_delayed_usecs(jack_client_t* ext_client)
  935. {
  936. jack_log("jack_get_max_delayed_usecs");
  937. return (*jack_get_max_delayed_usecs_fun)(ext_client);
  938. }
  939. typedef float (*jack_get_xrun_delayed_usecs_fun_def)(jack_client_t* ext_client);
  940. static jack_get_xrun_delayed_usecs_fun_def jack_get_xrun_delayed_usecs_fun = 0;
  941. EXPORT float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
  942. {
  943. jack_log("jack_get_xrun_delayed_usecs");
  944. return (*jack_get_xrun_delayed_usecs_fun)(ext_client);
  945. }
  946. typedef void (*jack_reset_max_delayed_usecs_fun_def)(jack_client_t* ext_client);
  947. static jack_reset_max_delayed_usecs_fun_def jack_reset_max_delayed_usecs_fun = 0;
  948. EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
  949. {
  950. jack_log("jack_reset_max_delayed_usecs");
  951. (*jack_reset_max_delayed_usecs_fun)(ext_client);
  952. }
  953. // thread.h
  954. typedef int (*jack_acquire_real_time_scheduling_fun_def)(pthread_t thread, int priority);
  955. static jack_acquire_real_time_scheduling_fun_def jack_acquire_real_time_scheduling_fun = 0;
  956. EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority)
  957. {
  958. jack_log("jack_acquire_real_time_scheduling");
  959. return (*jack_acquire_real_time_scheduling_fun)(thread, priority);
  960. }
  961. typedef void *(*start_routine)(void*);
  962. typedef int (*jack_client_create_thread_fun_def)(jack_client_t* client,
  963. pthread_t *thread,
  964. int priority,
  965. int realtime, // boolean
  966. start_routine callback,
  967. void *arg);
  968. static jack_client_create_thread_fun_def jack_client_create_thread_fun = 0;
  969. EXPORT int jack_client_create_thread(jack_client_t* client,
  970. pthread_t *thread,
  971. int priority,
  972. int realtime, // boolean
  973. start_routine callback,
  974. void *arg)
  975. {
  976. jack_log("jack_client_create_thread");
  977. return (*jack_client_create_thread_fun)(client, thread, priority, realtime, callback, arg);
  978. }
  979. typedef int (*jack_drop_real_time_scheduling_fun_def)(pthread_t thread);
  980. static jack_drop_real_time_scheduling_fun_def jack_drop_real_time_scheduling_fun = 0;
  981. EXPORT int jack_drop_real_time_scheduling(pthread_t thread)
  982. {
  983. jack_log("jack_client_create_thread");
  984. return (*jack_drop_real_time_scheduling_fun)(thread);
  985. }
  986. // intclient.h
  987. typedef char* (*jack_get_internal_client_name_fun_def)(jack_client_t* ext_client, jack_intclient_t intclient);
  988. static jack_get_internal_client_name_fun_def jack_get_internal_client_name_fun = 0;
  989. EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
  990. {
  991. jack_log("jack_get_internal_client_name");
  992. return (*jack_get_internal_client_name_fun)(ext_client, intclient);
  993. }
  994. typedef jack_intclient_t (*jack_internal_client_handle_fun_def)(jack_client_t* ext_client, const char* client_name, jack_status_t* status);
  995. static jack_internal_client_handle_fun_def jack_internal_client_handle_fun = 0;
  996. EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, const char* client_name, jack_status_t* status)
  997. {
  998. jack_log("jack_internal_client_handle");
  999. return (*jack_internal_client_handle_fun)(ext_client, client_name, status);
  1000. }
  1001. typedef jack_intclient_t (*jack_internal_client_load_aux_fun_def)(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, va_list ap);
  1002. static jack_internal_client_load_aux_fun_def jack_internal_client_load_aux_fun = 0;
  1003. EXPORT jack_intclient_t jack_internal_client_load(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, ...)
  1004. {
  1005. jack_log("jack_internal_client_load");
  1006. va_list ap;
  1007. va_start(ap, status);
  1008. jack_intclient_t res = (*jack_internal_client_load_aux_fun)(ext_client, client_name, options, status, ap);
  1009. va_end(ap);
  1010. return res;
  1011. }
  1012. typedef jack_status_t (*jack_internal_client_unload_fun_def)(jack_client_t* ext_client, jack_intclient_t intclient);
  1013. static jack_internal_client_unload_fun_def jack_internal_client_unload_fun = 0;
  1014. EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
  1015. {
  1016. jack_log("jack_internal_client_unload");
  1017. return (*jack_internal_client_unload_fun)(ext_client, intclient);
  1018. }
  1019. typedef jack_client_t * (*jack_client_open_aux_fun_def)(const char *ext_client_name, jack_options_t options, jack_status_t *status, va_list ap);
  1020. static jack_client_open_aux_fun_def jack_client_open_aux_fun = 0;
  1021. EXPORT jack_client_t * jack_client_open(const char *ext_client_name, jack_options_t options, jack_status_t *status, ...)
  1022. {
  1023. jack_log("jack_client_open");
  1024. // Library check...
  1025. if (open_library()) {
  1026. va_list ap;
  1027. va_start(ap, status);
  1028. jack_client_t* res = (*jack_client_open_aux_fun)(ext_client_name, options, status, ap);
  1029. va_end(ap);
  1030. return res;
  1031. } else {
  1032. jack_varargs_t va; // variable arguments
  1033. jack_status_t my_status;
  1034. char client_name[JACK_CLIENT_NAME_SIZE];
  1035. if (ext_client_name == NULL) {
  1036. jack_log("jack_client_open called with a NULL client_name");
  1037. return NULL;
  1038. }
  1039. RewriteName(ext_client_name, client_name);
  1040. if (status == NULL) // no status from caller?
  1041. status = &my_status; // use local status word
  1042. *status = (jack_status_t)0;
  1043. // validate parameters
  1044. if ((options & ~JackOpenOptions)) {
  1045. int my_status1 = *status | (JackFailure | JackInvalidOption);
  1046. *status = (jack_status_t)my_status1;
  1047. return NULL;
  1048. }
  1049. // parse variable arguments
  1050. va_list ap;
  1051. va_start(ap, status);
  1052. jack_varargs_parse(options, ap, &va);
  1053. va_end(ap);
  1054. if (start_server(va.server_name, options)) {
  1055. int my_status1 = *status | JackFailure | JackServerFailed;
  1056. *status = (jack_status_t)my_status1;
  1057. return NULL;
  1058. } else if (open_library()) {
  1059. va_list ap;
  1060. va_start(ap, status);
  1061. jack_client_t* res = (*jack_client_open_aux_fun)(ext_client_name, options, status, ap);
  1062. va_end(ap);
  1063. return res;
  1064. } else {
  1065. return NULL;
  1066. }
  1067. }
  1068. }
  1069. typedef jack_client_t * (*jack_client_new_fun_def)(const char *client_name);
  1070. static jack_client_new_fun_def jack_client_new_fun = 0;
  1071. EXPORT jack_client_t * jack_client_new(const char *client_name)
  1072. {
  1073. jack_log("jack_client_new");
  1074. // Library check...
  1075. if (!open_library())
  1076. return 0;
  1077. return (*jack_client_new_fun)(client_name);
  1078. }
  1079. typedef int (*jack_client_close_fun_def)(jack_client_t *client);
  1080. static jack_client_close_fun_def jack_client_close_fun = 0;
  1081. EXPORT int jack_client_close(jack_client_t *client)
  1082. {
  1083. jack_log("jack_client_close");
  1084. if (client) {
  1085. int res = (*jack_client_close_fun)(client);
  1086. close_library();
  1087. return res;
  1088. } else {
  1089. return -1;
  1090. }
  1091. }
  1092. // Library loader
  1093. static bool get_jack_library_in_directory(const char* dir_name, const char* library_name, char* library_res_name)
  1094. {
  1095. jack_log("get_jack_library_in_directory");
  1096. struct dirent * dir_entry;
  1097. DIR * dir_stream = opendir(dir_name);
  1098. if (!dir_stream)
  1099. return false;
  1100. while ((dir_entry = readdir(dir_stream))) {
  1101. if (strncmp(library_name, dir_entry->d_name, strlen(library_name)) == 0) {
  1102. jack_log("found");
  1103. sprintf(library_res_name, "%s/%s", dir_name, dir_entry->d_name);
  1104. closedir(dir_stream);
  1105. return true;
  1106. }
  1107. }
  1108. closedir(dir_stream);
  1109. return false;
  1110. }
  1111. static bool get_jack_library(const char* library_name, char* library_res_name)
  1112. {
  1113. if (get_jack_library_in_directory("/usr/lib", library_name, library_res_name))
  1114. return true;
  1115. if (get_jack_library_in_directory("/usr/local/lib", library_name, library_res_name))
  1116. return true;
  1117. return false;
  1118. }
  1119. static void close_library()
  1120. {
  1121. jack_log("close_library");
  1122. if (gLibrary) {
  1123. dlclose(gLibrary);
  1124. gLibrary = 0;
  1125. }
  1126. }
  1127. static bool check_client(void* library)
  1128. {
  1129. jack_client_t* client = 0;
  1130. jack_log("check_client");
  1131. // Get "new" and "close" entry points...
  1132. jack_client_new_fun = (jack_client_new_fun_def)dlsym(library, "jack_client_new");
  1133. jack_client_close_fun = (jack_client_close_fun_def)dlsym(library, "jack_client_close");
  1134. // Try opening a client...
  1135. if ((client = (*jack_client_new_fun)("dummy"))) { // server is running....
  1136. jack_log("check_client 1 %x", jack_client_close_fun);
  1137. (*jack_client_close_fun)(client);
  1138. jack_log("check_client 2");
  1139. return true;
  1140. } else {
  1141. jack_log("check_client NO");
  1142. return false;
  1143. }
  1144. }
  1145. static bool open_library()
  1146. {
  1147. char library_res_name[256];
  1148. void* jackLibrary = (get_jack_library(JACK_LIB, library_res_name)) ? dlopen(library_res_name, RTLD_LAZY) : 0;
  1149. void* jackmpLibrary = (get_jack_library(JACKMP_LIB, library_res_name)) ? dlopen(library_res_name, RTLD_LAZY) : 0;
  1150. if (jackLibrary) {
  1151. jack_log("jackLibrary");
  1152. if (check_client(jackLibrary)) { // jackd is running...
  1153. jack_log("jackd is running");
  1154. gLibrary = jackLibrary;
  1155. if (jackmpLibrary)
  1156. dlclose(jackmpLibrary);
  1157. jack_log("jackd is running OK");
  1158. } else if (check_client(jackmpLibrary)) { // jackdmp is running...
  1159. gLibrary = jackmpLibrary;
  1160. if (jackLibrary)
  1161. dlclose(jackLibrary);
  1162. } else {
  1163. goto error;
  1164. }
  1165. } else if (jackmpLibrary) {
  1166. jack_log("jackmpLibrary");
  1167. if (check_client(jackmpLibrary)) { // jackd is running...
  1168. gLibrary = jackmpLibrary;
  1169. } else {
  1170. goto error;
  1171. }
  1172. } else {
  1173. jack_log("Jack libraries not found, failure...");
  1174. goto error;
  1175. }
  1176. // Load entry points...
  1177. jack_client_open_aux_fun = (jack_client_open_aux_fun_def)dlsym(gLibrary, "jack_client_open_aux");
  1178. jack_client_new_fun = (jack_client_new_fun_def)dlsym(gLibrary, "jack_client_new");
  1179. jack_client_close_fun = (jack_client_close_fun_def)dlsym(gLibrary, "jack_client_close");
  1180. jack_client_name_size_fun = (jack_client_name_size_fun_def)dlsym(gLibrary, "jack_client_name_size");
  1181. jack_get_client_name_fun = (jack_get_client_name_fun_def)dlsym(gLibrary, "jack_get_client_name");
  1182. jack_internal_client_new_fun = (jack_internal_client_new_fun_def)dlsym(gLibrary, "jack_internal_client_new");
  1183. jack_internal_client_close_fun = (jack_internal_client_close_fun_def)dlsym(gLibrary, "jack_internal_client_close");
  1184. jack_is_realtime_fun = (jack_is_realtime_fun_def)dlsym(gLibrary, "jack_is_realtime");
  1185. jack_on_shutdown_fun = (jack_on_shutdown_fun_def)dlsym(gLibrary, "jack_on_shutdown");
  1186. jack_set_process_callback_fun = (jack_set_process_callback_fun_def)dlsym(gLibrary, "jack_set_process_callback");
  1187. jack_thread_wait_fun = (jack_thread_wait_fun_def)dlsym(gLibrary, "jack_thread_wait");
  1188. jack_cycle_wait_fun = (jack_cycle_wait_fun_def)dlsym(gLibrary, "jack_cycle_wait");
  1189. jack_cycle_signal_fun = (jack_cycle_signal_fun_def)dlsym(gLibrary, "jack_cycle_signal");
  1190. jack_set_thread_init_callback_fun = (jack_set_thread_init_callback_fun_def)dlsym(gLibrary, "jack_set_thread_init_callback");
  1191. jack_set_freewheel_callback_fun = (jack_set_freewheel_callback_fun_def)dlsym(gLibrary, "jack_set_freewheel_callback");
  1192. jack_set_freewheel_fun = (jack_set_freewheel_fun_def)dlsym(gLibrary, "jack_set_freewheel");
  1193. jack_set_buffer_size_fun = (jack_set_buffer_size_fun_def)dlsym(gLibrary, "jack_set_buffer_size");
  1194. jack_set_buffer_size_callback_fun = (jack_set_buffer_size_callback_fun_def)dlsym(gLibrary, "jack_set_buffer_size_callback");
  1195. jack_set_sample_rate_callback_fun = (jack_set_sample_rate_callback_fun_def)dlsym(gLibrary, "jack_set_sample_rate_callback");
  1196. jack_set_client_registration_callback_fun = (jack_set_client_registration_callback_fun_def)dlsym(gLibrary, "jack_set_client_registration_callback");
  1197. jack_set_port_registration_callback_fun = (jack_set_port_registration_callback_fun_def)dlsym(gLibrary, "jack_set_port_registration_callback");
  1198. jack_set_port_connect_callback_fun = (jack_set_port_connect_callback_fun_def)dlsym(gLibrary, "jack_set_port_connect_callback");
  1199. jack_set_graph_order_callback_fun = (jack_set_graph_order_callback_fun_def)dlsym(gLibrary, "jack_set_graph_order_callback");
  1200. jack_set_xrun_callback_fun = (jack_set_xrun_callback_fun_def)dlsym(gLibrary, "jack_set_xrun_callback");
  1201. jack_activate_fun = (jack_activate_fun_def)dlsym(gLibrary, "jack_activate");
  1202. jack_deactivate_fun = (jack_deactivate_fun_def)dlsym(gLibrary, "jack_deactivate");
  1203. jack_port_register_fun = (jack_port_register_fun_def)dlsym(gLibrary, "jack_port_register");
  1204. jack_port_unregister_fun = (jack_port_unregister_fun_def)dlsym(gLibrary, "jack_port_unregister");
  1205. jack_port_get_buffer_fun = (jack_port_get_buffer_fun_def)dlsym(gLibrary, "jack_port_get_buffer");
  1206. jack_port_name_fun = (jack_port_name_fun_def)dlsym(gLibrary, "jack_port_name");
  1207. jack_port_short_name_fun = (jack_port_short_name_fun_def)dlsym(gLibrary, "jack_port_short_name");
  1208. jack_port_flags_fun = (jack_port_flags_fun_def)dlsym(gLibrary, "jack_port_flags");
  1209. jack_port_type_fun = (jack_port_type_fun_def)dlsym(gLibrary, "jack_port_type");
  1210. jack_port_is_mine_fun = (jack_port_is_mine_fun_def)dlsym(gLibrary, "jack_port_is_mine");
  1211. jack_port_connected_fun = (jack_port_connected_fun_def)dlsym(gLibrary, "jack_port_connected");
  1212. jack_port_connected_to_fun = (jack_port_connected_to_fun_def)dlsym(gLibrary, "jack_port_connected_to");
  1213. jack_port_get_connections_fun = (jack_port_get_connections_fun_def)dlsym(gLibrary, "jack_port_get_connections");
  1214. jack_port_get_all_connections_fun = (jack_port_get_all_connections_fun_def)dlsym(gLibrary, "jack_port_get_all_connections");
  1215. jack_port_tie_fun = (jack_port_tie_fun_def)dlsym(gLibrary, "jack_port_tie");
  1216. jack_port_untie_fun = (jack_port_untie_fun_def)dlsym(gLibrary, "jack_port_untie");
  1217. jack_port_get_latency_fun = (jack_port_get_latency_fun_def)dlsym(gLibrary, "jack_port_get_latency");
  1218. jack_port_get_total_latency_fun = (jack_port_get_total_latency_fun_def)dlsym(gLibrary, "jack_port_get_total_latency");
  1219. jack_port_set_latency_fun = (jack_port_set_latency_fun_def)dlsym(gLibrary, "jack_port_set_latency");
  1220. jack_recompute_total_latency_fun = (jack_recompute_total_latency_fun_def)dlsym(gLibrary, "jack_recompute_total_latency");
  1221. jack_recompute_total_latencies_fun = (jack_recompute_total_latencies_fun_def)dlsym(gLibrary, "jack_recompute_total_latencies");
  1222. jack_port_set_name_fun = (jack_port_set_name_fun_def)dlsym(gLibrary, "jack_port_set_name");
  1223. jack_port_set_alias_fun = (jack_port_set_alias_fun_def)dlsym(gLibrary, "jack_port_set_alias");
  1224. jack_port_unset_alias_fun = (jack_port_unset_alias_fun_def)dlsym(gLibrary, "jack_port_unset_alias");
  1225. jack_port_get_aliases_fun = (jack_port_get_aliases_fun_def)dlsym(gLibrary, "jack_port_get_aliases");
  1226. jack_port_request_monitor_fun = (jack_port_request_monitor_fun_def)dlsym(gLibrary, "jack_port_request_monitor");
  1227. jack_port_request_monitor_by_name_fun = (jack_port_request_monitor_by_name_fun_def)dlsym(gLibrary, "jack_port_request_monitor_by_name");
  1228. jack_port_ensure_monitor_fun = (jack_port_ensure_monitor_fun_def)dlsym(gLibrary, "jack_port_ensure_monitor");
  1229. jack_port_monitoring_input_fun = (jack_port_monitoring_input_fun_def)dlsym(gLibrary, "jack_port_monitoring_input");
  1230. jack_connect_fun = (jack_connect_fun_def)dlsym(gLibrary, "jack_connect");
  1231. jack_disconnect_fun = (jack_disconnect_fun_def)dlsym(gLibrary, "jack_disconnect");
  1232. jack_port_disconnect_fun = (jack_port_disconnect_fun_def)dlsym(gLibrary, "jack_port_disconnect");
  1233. jack_port_name_size_fun = (jack_port_name_size_fun_def)dlsym(gLibrary, "jack_port_name_size");
  1234. jack_port_type_size_fun = (jack_port_type_size_fun_def)dlsym(gLibrary, "jack_port_type_size");
  1235. jack_get_sample_rate_fun = (jack_get_sample_rate_fun_def)dlsym(gLibrary, "jack_get_sample_rate");
  1236. jack_get_buffer_size_fun = (jack_get_buffer_size_fun_def)dlsym(gLibrary, "jack_get_buffer_size");
  1237. jack_get_ports_fun = (jack_get_ports_fun_def)dlsym(gLibrary, "jack_get_ports");
  1238. jack_port_by_name_fun = (jack_port_by_name_fun_def)dlsym(gLibrary, "jack_port_by_name");
  1239. jack_port_by_id_fun = (jack_port_by_id_fun_def)dlsym(gLibrary, "jack_port_by_id");
  1240. jack_engine_takeover_timebase_fun = (jack_engine_takeover_timebase_fun_def)dlsym(gLibrary, "jack_engine_takeover_timebase");
  1241. jack_frames_since_cycle_start_fun = (jack_frames_since_cycle_start_fun_def)dlsym(gLibrary, "jack_frames_since_cycle_start");
  1242. jack_get_time_fun = (jack_get_time_fun_def)dlsym(gLibrary, "jack_get_time");
  1243. jack_time_to_frames_fun = (jack_time_to_frames_fun_def)dlsym(gLibrary, "jack_time_to_frames");
  1244. jack_frames_to_time_fun = (jack_frames_to_time_fun_def)dlsym(gLibrary, "jack_frames_to_time");
  1245. jack_frame_time_fun = (jack_frame_time_fun_def)dlsym(gLibrary, "jack_frame_time");
  1246. jack_last_frame_time_fun = (jack_last_frame_time_fun_def)dlsym(gLibrary, "jack_last_frame_time");
  1247. jack_cpu_load_fun = (jack_cpu_load_fun_def)dlsym(gLibrary, "jack_cpu_load");
  1248. jack_client_thread_id_fun = (jack_client_thread_id_fun_def)dlsym(gLibrary, "jack_client_thread_id");
  1249. jack_set_error_function_fun = (jack_set_error_function_fun_def)dlsym(gLibrary, "jack_set_error_function");
  1250. jack_set_info_function_fun = (jack_set_info_function_fun_def)dlsym(gLibrary, "jack_set_info_function");
  1251. jack_get_max_delayed_usecs_fun = (jack_get_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_max_delayed_usecs");
  1252. jack_get_xrun_delayed_usecs_fun = (jack_get_xrun_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_xrun_delayed_usecs");
  1253. jack_reset_max_delayed_usecs_fun = (jack_reset_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_reset_max_delayed_usecs");
  1254. jack_release_timebase_fun = (jack_release_timebase_fun_def)dlsym(gLibrary, "jack_release_timebase");
  1255. jack_set_sync_callback_fun = (jack_set_sync_callback_fun_def)dlsym(gLibrary, "jack_set_sync_callback");
  1256. jack_set_sync_timeout_fun = (jack_set_sync_timeout_fun_def)dlsym(gLibrary, "jack_set_sync_timeout");
  1257. jack_set_timebase_callback_fun = (jack_set_timebase_callback_fun_def)dlsym(gLibrary, "jack_set_timebase_callback");
  1258. jack_transport_locate_fun = (jack_transport_locate_fun_def)dlsym(gLibrary, "jack_transport_locate");
  1259. jack_transport_query_fun = (jack_transport_query_fun_def)dlsym(gLibrary, "jack_transport_query");
  1260. jack_get_current_transport_frame_fun = (jack_get_current_transport_frame_fun_def)dlsym(gLibrary, "jack_get_current_transport_frame");
  1261. jack_transport_reposition_fun = (jack_transport_reposition_fun_def)dlsym(gLibrary, "jack_transport_reposition");
  1262. jack_transport_start_fun = (jack_transport_start_fun_def)dlsym(gLibrary, "jack_transport_start");
  1263. jack_transport_stop_fun = (jack_transport_stop_fun_def)dlsym(gLibrary, "jack_transport_stop");
  1264. jack_get_transport_info_fun = (jack_get_transport_info_fun_def)dlsym(gLibrary, "jack_get_transport_info");
  1265. jack_set_transport_info_fun = (jack_set_transport_info_fun_def)dlsym(gLibrary, "jack_set_transport_info");
  1266. jack_acquire_real_time_scheduling_fun = (jack_acquire_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_acquire_real_time_scheduling");
  1267. jack_client_create_thread_fun = (jack_client_create_thread_fun_def)dlsym(gLibrary, "jack_client_create_thread");
  1268. jack_drop_real_time_scheduling_fun = (jack_drop_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_drop_real_time_scheduling");
  1269. jack_get_internal_client_name_fun = (jack_get_internal_client_name_fun_def)dlsym(gLibrary, "jack_get_internal_client_name");
  1270. jack_internal_client_handle_fun = (jack_internal_client_handle_fun_def)dlsym(gLibrary, "jack_internal_client_handle");
  1271. jack_internal_client_load_aux_fun = (jack_internal_client_load_aux_fun_def)dlsym(gLibrary, "jack_internal_client_load_aux");
  1272. jack_internal_client_unload_fun = (jack_internal_client_unload_fun_def)dlsym(gLibrary, "jack_internal_client_unload");
  1273. // Functions were kept...
  1274. if (error_fun)
  1275. jack_set_error_function_fun(error_fun);
  1276. if (info_fun)
  1277. jack_set_info_function_fun(info_fun);
  1278. jack_log("init_library OK");
  1279. return true;
  1280. error:
  1281. if (jackLibrary)
  1282. dlclose(jackLibrary);
  1283. if (jackmpLibrary)
  1284. dlclose(jackmpLibrary);
  1285. gLibrary = 0;
  1286. return false;
  1287. }