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.

1416 lines
62KB

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