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.

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