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.

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