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.

998 lines
46KB

  1. /*
  2. Copyright (C) 2006 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 <dlfcn.h>
  19. #include <stdarg.h>
  20. #include <stdio.h>
  21. #include <dirent.h>
  22. #include <string.h>
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. EXPORT int jack_client_name_size (void);
  28. EXPORT char* jack_get_client_name (jack_client_t *client);
  29. EXPORT int jack_internal_client_new (const char *client_name,
  30. const char *load_name,
  31. const char *load_init);
  32. EXPORT void jack_internal_client_close (const char *client_name);
  33. EXPORT int jack_is_realtime (jack_client_t *client);
  34. EXPORT void jack_on_shutdown (jack_client_t *client,
  35. void (*function)(void *arg), void *arg);
  36. EXPORT int jack_set_process_callback (jack_client_t *client,
  37. JackProcessCallback process_callback,
  38. void *arg);
  39. EXPORT int jack_set_thread_init_callback (jack_client_t *client,
  40. JackThreadInitCallback thread_init_callback,
  41. void *arg);
  42. EXPORT int jack_set_freewheel_callback (jack_client_t *client,
  43. JackFreewheelCallback freewheel_callback,
  44. void *arg);
  45. EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
  46. EXPORT int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
  47. EXPORT int jack_set_buffer_size_callback (jack_client_t *client,
  48. JackBufferSizeCallback bufsize_callback,
  49. void *arg);
  50. EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
  51. JackSampleRateCallback srate_callback,
  52. void *arg);
  53. EXPORT int jack_set_port_registration_callback (jack_client_t *,
  54. JackPortRegistrationCallback
  55. registration_callback, void *arg);
  56. EXPORT int jack_set_graph_order_callback (jack_client_t *,
  57. JackGraphOrderCallback graph_callback,
  58. void *);
  59. EXPORT int jack_set_xrun_callback (jack_client_t *,
  60. JackXRunCallback xrun_callback, void *arg);
  61. EXPORT int jack_activate (jack_client_t *client);
  62. EXPORT int jack_deactivate (jack_client_t *client);
  63. EXPORT jack_port_t * jack_port_register (jack_client_t *client,
  64. const char *port_name,
  65. const char *port_type,
  66. unsigned long flags,
  67. unsigned long buffer_size);
  68. EXPORT int jack_port_unregister (jack_client_t *, jack_port_t *);
  69. EXPORT void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
  70. EXPORT const char * jack_port_name (const jack_port_t *port);
  71. EXPORT const char * jack_port_short_name (const jack_port_t *port);
  72. EXPORT int jack_port_flags (const jack_port_t *port);
  73. EXPORT const char * jack_port_type (const jack_port_t *port);
  74. EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
  75. EXPORT int jack_port_connected (const jack_port_t *port);
  76. EXPORT int jack_port_connected_to (const jack_port_t *port,
  77. const char *port_name);
  78. EXPORT const char ** jack_port_get_connections (const jack_port_t *port);
  79. EXPORT const char ** jack_port_get_all_connections (const jack_client_t *client,
  80. const jack_port_t *port);
  81. EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst);
  82. EXPORT int jack_port_untie (jack_port_t *port);
  83. EXPORT int jack_port_lock (jack_client_t *, jack_port_t *);
  84. EXPORT int jack_port_unlock (jack_client_t *, jack_port_t *);
  85. EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port);
  86. EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *,
  87. jack_port_t *port);
  88. EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t);
  89. EXPORT int jack_recompute_total_latencies (jack_client_t*);
  90. EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name);
  91. EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff);
  92. EXPORT int jack_port_request_monitor_by_name (jack_client_t *client,
  93. const char *port_name, int onoff);
  94. EXPORT int jack_port_ensure_monitor (jack_port_t *port, int onoff);
  95. EXPORT int jack_port_monitoring_input (jack_port_t *port);
  96. EXPORT int jack_connect (jack_client_t *,
  97. const char *source_port,
  98. const char *destination_port);
  99. EXPORT int jack_disconnect (jack_client_t *,
  100. const char *source_port,
  101. const char *destination_port);
  102. EXPORT int jack_port_disconnect (jack_client_t *, jack_port_t *);
  103. EXPORT int jack_port_name_size(void);
  104. EXPORT int jack_port_type_size(void);
  105. EXPORT jack_nframes_t jack_get_sample_rate (jack_client_t *);
  106. EXPORT jack_nframes_t jack_get_buffer_size (jack_client_t *);
  107. EXPORT const char ** jack_get_ports (jack_client_t *,
  108. const char *port_name_pattern,
  109. const char *type_name_pattern,
  110. unsigned long flags);
  111. EXPORT jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
  112. EXPORT jack_port_t * jack_port_by_id (jack_client_t *client,
  113. jack_port_id_t port_id);
  114. EXPORT int jack_engine_takeover_timebase (jack_client_t *);
  115. EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
  116. EXPORT jack_nframes_t jack_frame_time (const jack_client_t *);
  117. EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client);
  118. EXPORT float jack_cpu_load (jack_client_t *client);
  119. EXPORT pthread_t jack_client_thread_id (jack_client_t *);
  120. EXPORT void jack_set_error_function (void (*func)(const char *));
  121. EXPORT float jack_get_max_delayed_usecs (jack_client_t *client);
  122. EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client);
  123. EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client);
  124. EXPORT int jack_release_timebase (jack_client_t *client);
  125. EXPORT int jack_set_sync_callback (jack_client_t *client,
  126. JackSyncCallback sync_callback,
  127. void *arg);
  128. EXPORT int jack_set_sync_timeout (jack_client_t *client,
  129. jack_time_t timeout);
  130. EXPORT int jack_set_timebase_callback (jack_client_t *client,
  131. int conditional,
  132. JackTimebaseCallback timebase_callback,
  133. void *arg);
  134. EXPORT int jack_transport_locate (jack_client_t *client,
  135. jack_nframes_t frame);
  136. EXPORT jack_transport_state_t jack_transport_query (const jack_client_t *client,
  137. jack_position_t *pos);
  138. EXPORT jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
  139. EXPORT int jack_transport_reposition (jack_client_t *client,
  140. jack_position_t *pos);
  141. EXPORT void jack_transport_start (jack_client_t *client);
  142. EXPORT void jack_transport_stop (jack_client_t *client);
  143. EXPORT void jack_get_transport_info (jack_client_t *client,
  144. jack_transport_info_t *tinfo);
  145. EXPORT void jack_set_transport_info (jack_client_t *client,
  146. jack_transport_info_t *tinfo);
  147. EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
  148. EXPORT int jack_client_create_thread (jack_client_t* client,
  149. pthread_t *thread,
  150. int priority,
  151. int realtime, // boolean
  152. void *(*start_routine)(void*),
  153. void *arg);
  154. EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
  155. EXPORT char * jack_get_internal_client_name (jack_client_t *client,
  156. jack_intclient_t intclient);
  157. EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client,
  158. const char *client_name,
  159. jack_status_t *status);
  160. EXPORT jack_intclient_t jack_internal_client_load (jack_client_t *client,
  161. const char *client_name,
  162. jack_options_t options,
  163. jack_status_t *status, ...);
  164. EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
  165. jack_intclient_t intclient);
  166. EXPORT jack_client_t * jack_client_open (const char *client_name,
  167. jack_options_t options,
  168. jack_status_t *status, ...);
  169. EXPORT jack_client_t * jack_client_new (const char *client_name);
  170. EXPORT int jack_client_close (jack_client_t *client);
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. // Function definition
  175. typedef void* (*jack_port_get_buffer_fun_def)(jack_port_t* port, jack_nframes_t frames);
  176. static jack_port_get_buffer_fun_def jack_port_get_buffer_fun = 0;
  177. EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
  178. {
  179. return (*jack_port_get_buffer_fun)(port, frames);
  180. }
  181. typedef const char* (*jack_port_name_fun_def)(const jack_port_t* port);
  182. static jack_port_name_fun_def jack_port_name_fun = 0;
  183. EXPORT const char* jack_port_name(const jack_port_t* port)
  184. {
  185. return (*jack_port_name_fun)(port);
  186. }
  187. typedef const char* (*jack_port_short_name_fun_def) (const jack_port_t* port);
  188. static jack_port_short_name_fun_def jack_port_short_name_fun = 0;
  189. EXPORT const char* jack_port_short_name(const jack_port_t* port)
  190. {
  191. return (*jack_port_short_name_fun)(port);
  192. }
  193. typedef int (*jack_port_flags_fun_def)(const jack_port_t* port);
  194. static jack_port_flags_fun_def jack_port_flags_fun = 0;
  195. EXPORT int jack_port_flags(const jack_port_t* port)
  196. {
  197. return (*jack_port_flags_fun)(port);
  198. }
  199. typedef const char* (*jack_port_type_fun_def)(const jack_port_t* port);
  200. static jack_port_type_fun_def jack_port_type_fun = 0;
  201. EXPORT const char* jack_port_type(const jack_port_t* port)
  202. {
  203. return (*jack_port_type_fun)(port);
  204. }
  205. typedef int (*jack_port_connected_fun_def)(const jack_port_t* port);
  206. static jack_port_connected_fun_def jack_port_connected_fun = 0;
  207. EXPORT int jack_port_connected(const jack_port_t* port)
  208. {
  209. return (*jack_port_connected_fun)(port);
  210. }
  211. typedef int (*jack_port_connected_to_fun_def)(const jack_port_t* port, const char* portname);
  212. static jack_port_connected_to_fun_def jack_port_connected_to_fun = 0;
  213. EXPORT int jack_port_connected_to(const jack_port_t* port, const char* portname)
  214. {
  215. return (*jack_port_connected_to_fun)(port, portname);
  216. }
  217. typedef int (*jack_port_tie_fun_def)(jack_port_t* src, jack_port_t* dst);
  218. static jack_port_tie_fun_def jack_port_tie_fun = 0;
  219. EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
  220. {
  221. return (*jack_port_tie_fun)(src, dst);
  222. }
  223. typedef int (*jack_port_untie_fun_def)(jack_port_t* port);
  224. static jack_port_untie_fun_def jack_port_untie_fun = 0;
  225. EXPORT int jack_port_untie(jack_port_t* port)
  226. {
  227. return (*jack_port_untie_fun)(port);
  228. }
  229. typedef jack_nframes_t (*jack_port_get_latency_fun_def)(jack_port_t* port);
  230. static jack_port_get_latency_fun_def jack_port_get_latency_fun = 0;
  231. EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
  232. {
  233. return (*jack_port_get_latency)(port);
  234. }
  235. typedef void (*jack_port_set_latency_fun_def)(jack_port_t* port, jack_nframes_t frames);
  236. static jack_port_set_latency_fun_def jack_port_set_latency_fun = 0;
  237. EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
  238. {
  239. (*jack_port_set_latency_fun)(port, frames);
  240. }
  241. typedef int (*jack_recompute_total_latencies_fun_def)(jack_client_t* ext_client);
  242. static jack_recompute_total_latencies_fun_def jack_recompute_total_latencies_fun = 0;
  243. EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
  244. {
  245. return (*jack_recompute_total_latencies_fun)(ext_client);
  246. }
  247. typedef int (*jack_port_set_name_fun_def)(jack_port_t* port, const char* name);
  248. static jack_port_set_name_fun_def jack_port_set_name_fun = 0;
  249. EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
  250. {
  251. return (*jack_port_set_name_fun)(port, name);
  252. }
  253. typedef int (*jack_port_request_monitor_fun_def)(jack_port_t* port, int onoff);
  254. static jack_port_request_monitor_fun_def jack_port_request_monitor_fun = 0;
  255. EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
  256. {
  257. return (*jack_port_request_monitor_fun)(port, onoff);
  258. }
  259. typedef int (*jack_port_request_monitor_by_name_fun_def)(jack_client_t* ext_client, const char* port_name, int onoff);
  260. static jack_port_request_monitor_by_name_fun_def jack_port_request_monitor_by_name_fun = 0;
  261. EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
  262. {
  263. return (*jack_port_request_monitor_by_name_fun)(ext_client, port_name, onoff);
  264. }
  265. typedef int (*jack_port_ensure_monitor_fun_def)(jack_port_t* port, int onoff);
  266. static jack_port_ensure_monitor_fun_def jack_port_ensure_monitor_fun = 0;
  267. EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
  268. {
  269. return (*jack_port_ensure_monitor_fun)(port, onoff);
  270. }
  271. typedef int (*jack_port_monitoring_input_fun_def)(jack_port_t* port);
  272. static jack_port_monitoring_input_fun_def jack_port_monitoring_input_fun = 0;
  273. EXPORT int jack_port_monitoring_input(jack_port_t* port)
  274. {
  275. return (*jack_port_monitoring_input_fun)(port);
  276. }
  277. typedef int (*jack_is_realtime_fun_def)(jack_client_t* ext_client);
  278. static jack_is_realtime_fun_def jack_is_realtime_fun = 0;
  279. EXPORT int jack_is_realtime(jack_client_t* ext_client)
  280. {
  281. return (*jack_is_realtime_fun)(ext_client);
  282. }
  283. typedef void (*shutdown_fun)(void* arg);
  284. typedef void (*jack_on_shutdown_fun_def)(jack_client_t* ext_client, shutdown_fun callback, void* arg);
  285. static jack_on_shutdown_fun_def jack_on_shutdown_fun = 0;
  286. EXPORT void jack_on_shutdown(jack_client_t* ext_client, shutdown_fun callback, void* arg)
  287. {
  288. return (*jack_on_shutdown_fun)(ext_client, callback, arg);
  289. }
  290. typedef int (*jack_set_process_callback_fun_def)(jack_client_t* ext_client, JackProcessCallback callback, void* arg);
  291. static jack_set_process_callback_fun_def jack_set_process_callback_fun = 0;
  292. EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
  293. {
  294. return (*jack_set_process_callback_fun)(ext_client, callback, arg);
  295. }
  296. typedef int (*jack_set_freewheel_callback_fun_def)(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg);
  297. static jack_set_freewheel_callback_fun_def jack_set_freewheel_callback_fun = 0;
  298. EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
  299. {
  300. return (*jack_set_freewheel_callback_fun)(ext_client, freewheel_callback, arg);
  301. }
  302. typedef int (*jack_set_freewheel_fun_def)(jack_client_t* ext_client, int onoff);
  303. static jack_set_freewheel_fun_def jack_set_freewheel_fun = 0;
  304. EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
  305. {
  306. return (*jack_set_freewheel_fun)(ext_client, onoff);
  307. }
  308. typedef int (*jack_set_buffer_size_fun_def)(jack_client_t* ext_client, jack_nframes_t buffer_size);
  309. static jack_set_buffer_size_fun_def jack_set_buffer_size_fun = 0;
  310. EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
  311. {
  312. return (*jack_set_buffer_size_fun)(ext_client, buffer_size);
  313. }
  314. typedef int (*jack_set_buffer_size_callback_fun_def)(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg);
  315. static jack_set_buffer_size_callback_fun_def jack_set_buffer_size_callback_fun = 0;
  316. EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
  317. {
  318. return (*jack_set_buffer_size_callback_fun)(ext_client, bufsize_callback, arg);
  319. }
  320. typedef int (*jack_set_sample_rate_callback_fun_def)(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg);
  321. static jack_set_sample_rate_callback_fun_def jack_set_sample_rate_callback_fun = 0;
  322. EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
  323. {
  324. return (*jack_set_sample_rate_callback_fun)(ext_client, srate_callback, arg);
  325. }
  326. typedef int (*jack_set_port_registration_callback_fun_def)(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg);
  327. static jack_set_port_registration_callback_fun_def jack_set_port_registration_callback_fun = 0;
  328. EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
  329. {
  330. return (*jack_set_port_registration_callback_fun)(ext_client, registration_callback, arg);
  331. }
  332. typedef int (*jack_set_graph_order_callback_fun_def)(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg);
  333. static jack_set_graph_order_callback_fun_def jack_set_graph_order_callback_fun = 0;
  334. EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
  335. {
  336. return (*jack_set_graph_order_callback_fun)(ext_client, graph_callback, arg);
  337. }
  338. typedef int (*jack_set_xrun_callback_fun_def)(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg);
  339. static jack_set_xrun_callback_fun_def jack_set_xrun_callback_fun = 0;
  340. EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
  341. {
  342. return (*jack_set_xrun_callback_fun)(ext_client, xrun_callback, arg);
  343. }
  344. typedef int (*jack_set_thread_init_callback_fun_def)(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg);
  345. static jack_set_thread_init_callback_fun_def jack_set_thread_init_callback_fun = 0;
  346. EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
  347. {
  348. return (*jack_set_thread_init_callback_fun)(ext_client, init_callback, arg);
  349. }
  350. typedef int (*jack_activate_fun_def)(jack_client_t* ext_client);
  351. static jack_activate_fun_def jack_activate_fun = 0;
  352. EXPORT int jack_activate(jack_client_t* ext_client)
  353. {
  354. return (*jack_activate_fun)(ext_client);
  355. }
  356. typedef int (*jack_deactivate_fun_def)(jack_client_t* ext_client);
  357. static jack_deactivate_fun_def jack_deactivate_fun = 0;
  358. EXPORT int jack_deactivate(jack_client_t* ext_client)
  359. {
  360. return (*jack_deactivate_fun)(ext_client);
  361. }
  362. 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);
  363. static jack_port_register_fun_def jack_port_register_fun = 0;
  364. 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)
  365. {
  366. return (*jack_port_register_fun)(ext_client, port_name, port_type, flags, buffer_size);
  367. }
  368. typedef int (*jack_port_unregister_fun_def)(jack_client_t* ext_client, jack_port_t* port);
  369. static jack_port_unregister_fun_def jack_port_unregister_fun = 0;
  370. EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port)
  371. {
  372. return (*jack_port_unregister_fun)(ext_client, port);
  373. }
  374. typedef int (*jack_port_is_mine_fun_def)(const jack_client_t* ext_client, const jack_port_t* port);
  375. static jack_port_is_mine_fun_def jack_port_is_mine_fun = 0;
  376. EXPORT int jack_port_is_mine(const jack_client_t* ext_client, const jack_port_t* port)
  377. {
  378. return (*jack_port_is_mine_fun)(ext_client, port);
  379. }
  380. typedef const char** (*jack_port_get_connections_fun_def)(const jack_port_t* port);
  381. static jack_port_get_connections_fun_def jack_port_get_connections_fun = 0;
  382. EXPORT const char** jack_port_get_connections(const jack_port_t* port)
  383. {
  384. return (*jack_port_get_connections_fun)(port);
  385. }
  386. // Calling client does not need to "own" the port
  387. typedef const char** (*jack_port_get_all_connections_fun_def)(const jack_client_t* ext_client, const jack_port_t* port);
  388. static jack_port_get_all_connections_fun_def jack_port_get_all_connections_fun = 0;
  389. EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_client, const jack_port_t* port)
  390. {
  391. return (*jack_port_get_all_connections_fun)(ext_client, port);
  392. }
  393. // Does not use the client parameter
  394. typedef int (*jack_port_lock_fun_def)(jack_client_t* ext_client, jack_port_t* port);
  395. static jack_port_lock_fun_def jack_port_lock_fun = 0;
  396. EXPORT int jack_port_lock(jack_client_t* ext_client, jack_port_t* port)
  397. {
  398. return (*jack_port_lock_fun)(ext_client, port);
  399. }
  400. // Does not use the client parameter
  401. typedef int (*jack_port_unlock_fun_def)(jack_client_t* ext_client, jack_port_t* port);
  402. static jack_port_unlock_fun_def jack_port_unlock_fun = 0;
  403. EXPORT int jack_port_ununlock(jack_client_t* ext_client, jack_port_t* port)
  404. {
  405. return (*jack_port_unlock_fun)(ext_client, port);
  406. }
  407. typedef jack_nframes_t (*jack_port_get_total_latency_fun_def)(jack_client_t* ext_client, jack_port_t* port);
  408. static jack_port_get_total_latency_fun_def jack_port_get_total_latency_fun = 0;
  409. EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port)
  410. {
  411. return (*jack_port_get_total_latency_fun)(ext_client, port);
  412. }
  413. typedef int (*jack_connect_fun_def)(jack_client_t* ext_client, const char* src, const char* dst);
  414. static jack_connect_fun_def jack_connect_fun = 0;
  415. EXPORT int jack_connect(jack_client_t* ext_client, const char* src, const char* dst)
  416. {
  417. return (*jack_connect_fun)(ext_client, src, dst);
  418. }
  419. typedef int (*jack_disconnect_fun_def)(jack_client_t* ext_client, const char* src, const char* dst);
  420. static jack_disconnect_fun_def jack_disconnect_fun = 0;
  421. EXPORT int jack_disconnect(jack_client_t* ext_client, const char* src, const char* dst)
  422. {
  423. return (*jack_disconnect_fun)(ext_client, src, dst);
  424. }
  425. typedef int (*jack_port_connect_fun_def)(jack_client_t* ext_client, jack_port_t* src, jack_port_t* dst);
  426. static jack_port_connect_fun_def jack_port_connect_fun = 0;
  427. EXPORT int jack_port_connect(jack_client_t* ext_client, jack_port_t* src, jack_port_t* dst)
  428. {
  429. return (*jack_port_connect_fun)(ext_client, src, dst);
  430. }
  431. typedef int (*jack_port_disconnect_fun_def)(jack_client_t* ext_client, jack_port_t* src);
  432. static jack_port_disconnect_fun_def jack_port_disconnect_fun = 0;
  433. EXPORT int jack_port_disconnect(jack_client_t* ext_client, jack_port_t* src)
  434. {
  435. return (*jack_port_disconnect_fun)(ext_client, src);
  436. }
  437. typedef jack_nframes_t (*jack_get_sample_rate_fun_def)(jack_client_t* ext_client);
  438. static jack_get_sample_rate_fun_def jack_get_sample_rate_fun = 0;
  439. EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t* ext_client)
  440. {
  441. return (*jack_get_sample_rate_fun)(ext_client);
  442. }
  443. typedef jack_nframes_t (*jack_get_buffer_size_fun_def)(jack_client_t* ext_client);
  444. static jack_get_buffer_size_fun_def jack_get_buffer_size_fun = 0;
  445. EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client)
  446. {
  447. return (*jack_get_buffer_size_fun)(ext_client);
  448. }
  449. 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);
  450. static jack_get_ports_fun_def jack_get_ports_fun = 0;
  451. EXPORT const char** jack_get_ports(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
  452. {
  453. return (*jack_get_ports_fun)(ext_client, port_name_pattern, type_name_pattern, flags);
  454. }
  455. typedef jack_port_t* (*jack_port_by_name_fun_def)(jack_client_t* ext_client, const char* portname);
  456. static jack_port_by_name_fun_def jack_port_by_name_fun = 0;
  457. EXPORT jack_port_t* jack_port_by_name(jack_client_t* ext_client, const char* portname)
  458. {
  459. return (*jack_port_by_name_fun)(ext_client, portname);
  460. }
  461. typedef jack_port_t* (*jack_port_by_id_fun_def)(const jack_client_t* ext_client, jack_port_id_t id);
  462. static jack_port_by_id_fun_def jack_port_by_id_fun = 0;
  463. EXPORT jack_port_t* jack_port_by_id(const jack_client_t* ext_client, jack_port_id_t id)
  464. {
  465. return (*jack_port_by_id_fun)(ext_client, id);
  466. }
  467. typedef int (*jack_engine_takeover_timebase_fun_def)(jack_client_t* ext_client);
  468. static jack_engine_takeover_timebase_fun_def jack_engine_takeover_timebase_fun = 0;
  469. EXPORT int jack_engine_takeover_timebase(jack_client_t* ext_client)
  470. {
  471. return (*jack_engine_takeover_timebase_fun)(ext_client);
  472. }
  473. typedef jack_nframes_t (*jack_frames_since_cycle_start_fun_def)(const jack_client_t* ext_client);
  474. static jack_frames_since_cycle_start_fun_def jack_frames_since_cycle_start_fun = 0;
  475. EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t* ext_client)
  476. {
  477. return (*jack_frames_since_cycle_start_fun)(ext_client);
  478. }
  479. typedef jack_nframes_t (*jack_frame_time_fun_def)(const jack_client_t* ext_client);
  480. static jack_frame_time_fun_def jack_frame_time_fun = 0;
  481. EXPORT jack_nframes_t jack_frame_time(const jack_client_t* ext_client)
  482. {
  483. return (*jack_frame_time_fun)(ext_client);
  484. }
  485. typedef jack_nframes_t (*jack_last_frame_time_fun_def)(const jack_client_t* ext_client);
  486. static jack_last_frame_time_fun_def jack_last_frame_time_fun = 0;
  487. EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
  488. {
  489. return (*jack_last_frame_time_fun)(ext_client);
  490. }
  491. typedef float (*jack_cpu_load_fun_def)(jack_client_t* ext_client);
  492. static jack_cpu_load_fun_def jack_cpu_load_fun = 0;
  493. EXPORT float jack_cpu_load(jack_client_t* ext_client)
  494. {
  495. return (*jack_cpu_load_fun)(ext_client);
  496. }
  497. typedef pthread_t (*jack_client_thread_id_fun_def)(jack_client_t* ext_client);
  498. static jack_client_thread_id_fun_def jack_client_thread_id_fun = 0;
  499. EXPORT pthread_t jack_client_thread_id(jack_client_t* ext_client)
  500. {
  501. return (*jack_client_thread_id_fun)(ext_client);
  502. }
  503. typedef char* (*jack_get_client_name_fun_def)(jack_client_t* ext_client);
  504. static jack_get_client_name_fun_def jack_get_client_name_fun = 0;
  505. EXPORT char* jack_get_client_name (jack_client_t* ext_client)
  506. {
  507. return (*jack_get_client_name_fun)(ext_client);
  508. }
  509. typedef int (*jack_client_name_size_fun_def)(void);
  510. static jack_client_name_size_fun_def jack_client_name_size_fun = 0;
  511. EXPORT int jack_client_name_size(void)
  512. {
  513. return (*jack_client_name_size_fun)();
  514. }
  515. typedef int (*jack_port_name_size_fun_def)(void);
  516. static jack_port_name_size_fun_def jack_port_name_size_fun = 0;
  517. EXPORT int jack_port_name_size(void)
  518. {
  519. return (*jack_port_name_size_fun)();
  520. }
  521. // transport.h
  522. typedef int (*jack_release_timebase_fun_def)(jack_client_t* ext_client);
  523. static jack_release_timebase_fun_def jack_release_timebase_fun = 0;
  524. EXPORT int jack_release_timebase(jack_client_t* ext_client)
  525. {
  526. return (*jack_release_timebase_fun)(ext_client);
  527. }
  528. typedef int (*jack_set_sync_callback_fun_def)(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg);
  529. static jack_set_sync_callback_fun_def jack_set_sync_callback_fun = 0;
  530. EXPORT int jack_set_sync_callback(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg)
  531. {
  532. return (*jack_set_sync_callback_fun)(ext_client, sync_callback, arg);
  533. }
  534. typedef int (*jack_set_sync_timeout_fun_def)(jack_client_t* ext_client, jack_time_t timeout);
  535. static jack_set_sync_timeout_fun_def jack_set_sync_timeout_fun = 0;
  536. EXPORT int jack_set_sync_timeout(jack_client_t* ext_client, jack_time_t timeout)
  537. {
  538. return (*jack_set_sync_timeout_fun)(ext_client, timeout);
  539. }
  540. typedef int (*jack_set_timebase_callback_fun_def)(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg);
  541. static jack_set_timebase_callback_fun_def jack_set_timebase_callback_fun = 0;
  542. EXPORT int jack_set_timebase_callback(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg)
  543. {
  544. return (*jack_set_timebase_callback_fun)(ext_client, conditional, timebase_callback, arg);
  545. }
  546. typedef int (*jack_transport_locate_fun_def)(jack_client_t* ext_client, jack_nframes_t frame);
  547. static jack_transport_locate_fun_def jack_transport_locate_fun = 0;
  548. EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame)
  549. {
  550. return (*jack_transport_locate_fun)(ext_client, frame);
  551. }
  552. typedef jack_transport_state_t (*jack_transport_query_fun_def)(const jack_client_t* ext_client, jack_position_t* pos);
  553. static jack_transport_query_fun_def jack_transport_query_fun = 0;
  554. EXPORT jack_transport_state_t jack_transport_query(const jack_client_t* ext_client, jack_position_t* pos)
  555. {
  556. return (*jack_transport_query_fun)(ext_client, pos);
  557. }
  558. typedef jack_nframes_t (*jack_get_current_transport_frame_fun_def)(const jack_client_t* ext_client);
  559. static jack_get_current_transport_frame_fun_def jack_get_current_transport_frame_fun = 0;
  560. EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t* ext_client)
  561. {
  562. return (*jack_get_current_transport_frame_fun)(ext_client);
  563. }
  564. typedef int (*jack_transport_reposition_fun_def)(jack_client_t* ext_client, jack_position_t* pos);
  565. static jack_transport_reposition_fun_def jack_transport_reposition_fun = 0;
  566. EXPORT int jack_transport_reposition(jack_client_t* ext_client, jack_position_t* pos)
  567. {
  568. return (*jack_transport_reposition_fun)(ext_client, pos);
  569. }
  570. typedef void (*jack_transport_start_fun_def)(jack_client_t* ext_client);
  571. static jack_transport_start_fun_def jack_transport_start_fun = 0;
  572. EXPORT void jack_transport_start(jack_client_t* ext_client)
  573. {
  574. return (*jack_transport_start_fun)(ext_client);
  575. }
  576. typedef void (*jack_transport_stop_fun_def)(jack_client_t* ext_client);
  577. static jack_transport_stop_fun_def jack_transport_stop_fun = 0;
  578. EXPORT void jack_transport_stop(jack_client_t* ext_client)
  579. {
  580. return (*jack_transport_stop_fun)(ext_client);
  581. }
  582. // deprecated
  583. typedef void (*jack_get_transport_info_fun_def)(jack_client_t* ext_client, jack_transport_info_t* tinfo);
  584. static jack_get_transport_info_fun_def jack_get_transport_info_fun = 0;
  585. EXPORT void jack_get_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  586. {
  587. (*jack_get_transport_info_fun)(ext_client, tinfo);
  588. }
  589. typedef void (*jack_set_transport_info_fun_def)(jack_client_t* ext_client, jack_transport_info_t* tinfo);
  590. static jack_set_transport_info_fun_def jack_set_transport_info_fun = 0;
  591. EXPORT void jack_set_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  592. {
  593. (*jack_set_transport_info_fun)(ext_client, tinfo);
  594. }
  595. // statistics.h
  596. typedef float (*jack_get_max_delayed_usecs_fun_def)(jack_client_t* ext_client);
  597. static jack_get_max_delayed_usecs_fun_def jack_get_max_delayed_usecs_fun = 0;
  598. EXPORT float jack_get_max_delayed_usecs(jack_client_t* ext_client)
  599. {
  600. return (*jack_get_max_delayed_usecs_fun)(ext_client);
  601. }
  602. typedef float (*jack_get_xrun_delayed_usecs_fun_def)(jack_client_t* ext_client);
  603. static jack_get_xrun_delayed_usecs_fun_def jack_get_xrun_delayed_usecs_fun = 0;
  604. EXPORT float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
  605. {
  606. return (*jack_get_xrun_delayed_usecs_fun)(ext_client);
  607. }
  608. typedef void (*jack_reset_max_delayed_usecs_fun_def)(jack_client_t* ext_client);
  609. static jack_reset_max_delayed_usecs_fun_def jack_reset_max_delayed_usecs_fun = 0;
  610. EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
  611. {
  612. (*jack_reset_max_delayed_usecs)(ext_client);
  613. }
  614. // thread.h
  615. typedef int (*jack_acquire_real_time_scheduling_fun_def)(pthread_t thread, int priority);
  616. static jack_acquire_real_time_scheduling_fun_def jack_acquire_real_time_scheduling_fun = 0;
  617. EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority)
  618. {
  619. return (*jack_acquire_real_time_scheduling_fun)(thread, priority);
  620. }
  621. typedef void *(*start_routine)(void*);
  622. typedef int (*jack_client_create_thread_fun_def)(jack_client_t* client,
  623. pthread_t *thread,
  624. int priority,
  625. int realtime, // boolean
  626. start_routine callback,
  627. void *arg);
  628. static jack_client_create_thread_fun_def jack_client_create_thread_fun = 0;
  629. EXPORT int jack_client_create_thread(jack_client_t* client,
  630. pthread_t *thread,
  631. int priority,
  632. int realtime, // boolean
  633. start_routine callback,
  634. void *arg)
  635. {
  636. return (*jack_client_create_thread_fun)(client, thread, priority, realtime, callback, arg);
  637. }
  638. typedef int (*jack_drop_real_time_scheduling_fun_def)(pthread_t thread);
  639. static jack_drop_real_time_scheduling_fun_def jack_drop_real_time_scheduling_fun = 0;
  640. EXPORT int jack_drop_real_time_scheduling(pthread_t thread)
  641. {
  642. return (*jack_drop_real_time_scheduling_fun)(thread);
  643. }
  644. // intclient.h
  645. typedef char* (*jack_get_internal_client_name_fun_def)(jack_client_t* ext_client, jack_intclient_t intclient);
  646. static jack_get_internal_client_name_fun_def jack_get_internal_client_name_fun = 0;
  647. EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
  648. {
  649. return (*jack_get_internal_client_name_fun)(ext_client, intclient);
  650. }
  651. typedef jack_intclient_t (*jack_internal_client_handle_fun_def)(jack_client_t* ext_client, const char* client_name, jack_status_t* status);
  652. static jack_internal_client_handle_fun_def jack_internal_client_handle_fun = 0;
  653. EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, const char* client_name, jack_status_t* status)
  654. {
  655. return (*jack_internal_client_handle_fun)(ext_client, client_name, status);
  656. }
  657. typedef jack_intclient_t (*jack_internal_client_load_fun_def)(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, ...);
  658. static jack_internal_client_load_fun_def jack_internal_client_load_fun = 0;
  659. 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, ...)
  660. {
  661. va_list ap;
  662. va_start(ap, status);
  663. jack_intclient_t res = (*jack_internal_client_load_fun)(ext_client, client_name, options, status, ap);
  664. va_end(ap);
  665. return res;
  666. }
  667. typedef jack_status_t (*jack_internal_client_unload_fun_def)(jack_client_t* ext_client, jack_intclient_t intclient);
  668. static jack_internal_client_unload_fun_def jack_internal_client_unload_fun = 0;
  669. EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
  670. {
  671. return (*jack_internal_client_unload_fun)(ext_client, intclient);
  672. }
  673. // client
  674. static long gClientCount = 0;
  675. static void* gLibrary = 0;
  676. static bool init_library();
  677. static bool open_library();
  678. static void close_library();
  679. typedef jack_client_t * (*jack_client_open_fun_def)(const char *client_name, jack_options_t options, jack_status_t *status, ...);
  680. static jack_client_open_fun_def jack_client_open_fun = 0;
  681. EXPORT jack_client_t * jack_client_open(const char *client_name, jack_options_t options, jack_status_t *status, ...)
  682. {
  683. // Library check...
  684. if (!open_library())
  685. return 0;
  686. va_list ap;
  687. va_start(ap, status);
  688. jack_client_t* res = (*jack_client_open_fun)(client_name, options, status, ap);
  689. va_end(ap);
  690. return res;
  691. }
  692. typedef jack_client_t * (*jack_client_new_fun_def)(const char *client_name);
  693. static jack_client_new_fun_def jack_client_new_fun = 0;
  694. EXPORT jack_client_t * jack_client_new(const char *client_name)
  695. {
  696. // Library check...
  697. if (!open_library())
  698. return 0;
  699. return (*jack_client_new_fun)(client_name);
  700. }
  701. typedef int (*jack_client_close_fun_def)(jack_client_t *client);
  702. static jack_client_close_fun_def jack_client_close_fun = 0;
  703. EXPORT int jack_client_close(jack_client_t *client)
  704. {
  705. int res = (*jack_client_close_fun)(client);
  706. close_library();
  707. return res;
  708. }
  709. // Library loader
  710. static bool get_jack_library_in_directory(const char* dir_name, char* library_name)
  711. {
  712. struct dirent * dir_entry;
  713. DIR * dir_stream = opendir(dir_name);
  714. if (!dir_stream)
  715. return false;
  716. while ((dir_entry = readdir(dir_stream))) {
  717. if (strncmp("libjack.so", dir_entry->d_name, 10) == 0) {
  718. strcpy(library_name, dir_entry->d_name);
  719. closedir(dir_stream);
  720. return true;
  721. }
  722. }
  723. closedir(dir_stream);
  724. return false;
  725. }
  726. static bool get_jack_library(char* library_name)
  727. {
  728. if (get_jack_library_in_directory("/usr/lib", library_name))
  729. return true;
  730. if (get_jack_library_in_directory("/usr/local/lib", library_name))
  731. return true;
  732. return false;
  733. }
  734. static bool open_library()
  735. {
  736. if (gClientCount++ == 0) {
  737. return init_library();
  738. } else {
  739. return true;
  740. }
  741. }
  742. static void close_library()
  743. {
  744. if (--gClientCount == 0) {
  745. dlclose(gLibrary);
  746. }
  747. }
  748. static bool check_client(void* library)
  749. {
  750. jack_client_t* client = 0;
  751. // Get "new", "open" and "close" entry points...
  752. jack_client_new_fun = (jack_client_new_fun_def)dlsym(library, "jack_client_new");
  753. jack_client_close_fun = (jack_client_close_fun_def)dlsym(library, "jack_client_close");
  754. jack_client_open_fun = (jack_client_open_fun_def)dlsym(gLibrary, "jack_client_open");
  755. // Try opening a client...
  756. if ((client = (*jack_client_new_fun)("dummy"))) { // jackd server is running....
  757. (*jack_client_close_fun)(client);
  758. return true;
  759. } else {
  760. return false;
  761. }
  762. }
  763. static bool init_library()
  764. {
  765. char library_name[64];
  766. void* jackLibrary = (get_jack_library(library_name)) ? dlopen(library_name, RTLD_LAZY) : 0;
  767. void* jackmpLibrary = dlopen("libjackmp.so", RTLD_LAZY);
  768. if (jackLibrary) {
  769. if (check_client(jackLibrary)) { // jackd is running...
  770. gLibrary = jackLibrary;
  771. if (jackmpLibrary) dlclose(jackmpLibrary);
  772. } else if (check_client(jackmpLibrary)) { // jackdmp is running...
  773. gLibrary = jackmpLibrary;
  774. if (jackLibrary) dlclose(jackLibrary);
  775. } else {
  776. goto error;
  777. }
  778. } else if (jackmpLibrary) {
  779. if (check_client(jackmpLibrary)) { // jackd is running...
  780. gLibrary = jackmpLibrary;
  781. } else {
  782. goto error;
  783. }
  784. } else {
  785. printf("Jack libraries not found, failure...\n");
  786. goto error;
  787. }
  788. // Load entry points...
  789. jack_port_get_buffer_fun = (jack_port_get_buffer_fun_def)dlsym(gLibrary, "jack_port_get_buffer");
  790. jack_port_name_fun = (jack_port_name_fun_def)dlsym(gLibrary, "jack_port_name");
  791. jack_port_short_name_fun = (jack_port_short_name_fun_def)dlsym(gLibrary, "jack_port_short_name");
  792. jack_port_flags_fun = (jack_port_flags_fun_def)dlsym(gLibrary, "jack_port_flags");
  793. jack_port_type_fun = (jack_port_type_fun_def)dlsym(gLibrary, "jack_port_type");
  794. jack_port_connected_fun = (jack_port_connected_fun_def)dlsym(gLibrary, "jack_port_connected");
  795. jack_port_connected_to_fun = (jack_port_connected_to_fun_def)dlsym(gLibrary, "jack_port_connected_to");
  796. jack_port_tie_fun = (jack_port_tie_fun_def)dlsym(gLibrary, "jack_port_tie");
  797. jack_port_untie_fun = (jack_port_untie_fun_def)dlsym(gLibrary, "jack_port_untie");
  798. jack_port_get_latency_fun = (jack_port_get_latency_fun_def)dlsym(gLibrary, "jack_port_get_latency");
  799. jack_port_set_latency_fun = (jack_port_set_latency_fun_def)dlsym(gLibrary, "jack_port_set_latency");
  800. jack_recompute_total_latencies_fun = (jack_recompute_total_latencies_fun_def)dlsym(gLibrary, "jack_recompute_total_latencies");
  801. jack_port_set_name_fun = (jack_port_set_name_fun_def)dlsym(gLibrary, "jack_port_set_name");
  802. jack_port_request_monitor_fun = (jack_port_request_monitor_fun_def)dlsym(gLibrary, "jack_port_request_monitor");
  803. jack_port_request_monitor_by_name_fun = (jack_port_request_monitor_by_name_fun_def)dlsym(gLibrary, "jack_port_request_monitor_by_name");
  804. jack_port_ensure_monitor_fun = (jack_port_ensure_monitor_fun_def)dlsym(gLibrary, "jack_port_ensure_monitor");
  805. jack_port_monitoring_input_fun = (jack_port_monitoring_input_fun_def)dlsym(gLibrary, "jack_port_monitoring_input_fun");
  806. jack_is_realtime_fun = (jack_is_realtime_fun_def)dlsym(gLibrary, "jack_is_realtime");
  807. jack_on_shutdown_fun = (jack_on_shutdown_fun_def)dlsym(gLibrary, "jack_on_shutdown");
  808. jack_set_process_callback_fun = (jack_set_process_callback_fun_def)dlsym(gLibrary, "jack_set_process_callback");
  809. jack_set_freewheel_callback_fun = (jack_set_freewheel_callback_fun_def)dlsym(gLibrary, "jack_set_freewheel_callback");
  810. jack_set_freewheel_fun = (jack_set_freewheel_fun_def)dlsym(gLibrary, "jack_set_freewheel");
  811. jack_set_buffer_size_fun = (jack_set_buffer_size_fun_def)dlsym(gLibrary, "jack_set_buffer_size");
  812. jack_set_buffer_size_callback_fun = (jack_set_buffer_size_callback_fun_def)dlsym(gLibrary, "jack_set_buffer_size_callback");
  813. jack_set_sample_rate_callback_fun = (jack_set_sample_rate_callback_fun_def)dlsym(gLibrary, "jack_set_sample_rate_callback");
  814. jack_set_port_registration_callback_fun = (jack_set_port_registration_callback_fun_def)dlsym(gLibrary, "jack_set_port_registration_callback");
  815. jack_set_graph_order_callback_fun = (jack_set_graph_order_callback_fun_def)dlsym(gLibrary, "jack_set_graph_order_callback");
  816. jack_set_xrun_callback_fun = (jack_set_xrun_callback_fun_def)dlsym(gLibrary, "jack_set_xrun_callback");
  817. jack_set_thread_init_callback_fun = (jack_set_thread_init_callback_fun_def)dlsym(gLibrary, "jack_set_thread_init_callback");
  818. jack_activate_fun = (jack_activate_fun_def)dlsym(gLibrary, "jack_activate");
  819. jack_deactivate_fun = (jack_deactivate_fun_def)dlsym(gLibrary, "jack_deactivate");
  820. jack_port_register_fun = (jack_port_register_fun_def)dlsym(gLibrary, "jack_port_register");
  821. jack_port_unregister_fun = (jack_port_unregister_fun_def)dlsym(gLibrary, "jack_port_unregister");
  822. jack_port_is_mine_fun = (jack_port_is_mine_fun_def)dlsym(gLibrary, "jack_port_is_mine");
  823. jack_port_get_connections_fun = (jack_port_get_connections_fun_def)dlsym(gLibrary, "jack_port_get_connections");
  824. jack_port_get_all_connections_fun = (jack_port_get_all_connections_fun_def)dlsym(gLibrary, "jack_port_get_all_connections_fun");
  825. jack_port_lock_fun = (jack_port_lock_fun_def)dlsym(gLibrary, "jack_port_lock");
  826. jack_port_unlock_fun = (jack_port_unlock_fun_def)dlsym(gLibrary, "jack_port_unlock");
  827. jack_port_get_total_latency_fun = (jack_port_get_total_latency_fun_def)dlsym(gLibrary, "jack_port_get_total_latency");
  828. jack_connect_fun = (jack_connect_fun_def)dlsym(gLibrary, "jack_connect");
  829. jack_disconnect_fun = (jack_disconnect_fun_def)dlsym(gLibrary, "jack_disconnect");
  830. jack_port_connect_fun = (jack_port_connect_fun_def)dlsym(gLibrary, "jack_port_connect");
  831. jack_port_disconnect_fun = (jack_port_disconnect_fun_def)dlsym(gLibrary, "jack_port_disconnect");
  832. jack_get_sample_rate_fun = (jack_get_sample_rate_fun_def)dlsym(gLibrary, "jack_get_sample_rate");
  833. jack_get_buffer_size_fun = (jack_get_buffer_size_fun_def)dlsym(gLibrary, "jack_get_buffer_size");
  834. jack_get_ports_fun = (jack_get_ports_fun_def)dlsym(gLibrary, "jack_get_ports");
  835. jack_port_by_name_fun = (jack_port_by_name_fun_def)dlsym(gLibrary, "jack_port_by_name");
  836. jack_port_by_id_fun = (jack_port_by_id_fun_def)dlsym(gLibrary, "jack_port_by_id");
  837. jack_engine_takeover_timebase_fun = (jack_engine_takeover_timebase_fun_def)dlsym(gLibrary, "jack_engine_takeover_timebase");
  838. jack_frames_since_cycle_start_fun = (jack_frames_since_cycle_start_fun_def)dlsym(gLibrary, "jack_frames_since_cycle_start");
  839. jack_frame_time_fun = (jack_frame_time_fun_def)dlsym(gLibrary, "jack_frame_time_fun");
  840. jack_last_frame_time_fun = (jack_last_frame_time_fun_def)dlsym(gLibrary, "jack_last_frame_time");
  841. jack_cpu_load_fun = (jack_cpu_load_fun_def)dlsym(gLibrary, "jack_cpu_load");
  842. jack_client_thread_id_fun = (jack_client_thread_id_fun_def)dlsym(gLibrary, "jack_client_thread_id");
  843. jack_get_client_name_fun = (jack_get_client_name_fun_def)dlsym(gLibrary, "jack_get_client_name");
  844. jack_port_name_size_fun = (jack_port_name_size_fun_def)dlsym(gLibrary, "jack_port_name_size");
  845. jack_client_name_size_fun = (jack_client_name_size_fun_def)dlsym(gLibrary, "jack_client_name_size");
  846. jack_release_timebase_fun = (jack_release_timebase_fun_def)dlsym(gLibrary, "jack_release_timebase");
  847. jack_set_sync_callback_fun = (jack_set_sync_callback_fun_def)dlsym(gLibrary, "jack_set_sync_callback");
  848. jack_set_sync_timeout_fun = (jack_set_sync_timeout_fun_def)dlsym(gLibrary, "jack_set_sync_timeout");
  849. jack_set_timebase_callback_fun = (jack_set_timebase_callback_fun_def)dlsym(gLibrary, "jack_set_timebase_callback");
  850. jack_transport_locate_fun = (jack_transport_locate_fun_def)dlsym(gLibrary, "jack_transport_locate_fun");
  851. jack_transport_query_fun = (jack_transport_query_fun_def)dlsym(gLibrary, "jack_transport_query");
  852. jack_get_current_transport_frame_fun = (jack_get_current_transport_frame_fun_def)dlsym(gLibrary, "jack_get_current_transport_frame");
  853. jack_transport_reposition_fun = (jack_transport_reposition_fun_def)dlsym(gLibrary, "jack_transport_reposition");
  854. jack_transport_start_fun = (jack_transport_start_fun_def)dlsym(gLibrary, "jack_transport_start");
  855. jack_transport_stop_fun = (jack_transport_stop_fun_def)dlsym(gLibrary, "jack_transport_stop");
  856. jack_get_transport_info_fun = (jack_get_transport_info_fun_def)dlsym(gLibrary, "jack_get_transport_info");
  857. jack_set_transport_info_fun = (jack_set_transport_info_fun_def)dlsym(gLibrary, "jack_set_transport_info");
  858. jack_get_max_delayed_usecs_fun = (jack_get_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_max_delayed_usecs");
  859. jack_get_xrun_delayed_usecs_fun = (jack_get_xrun_delayed_usecs_fun_def)dlsym(gLibrary, "jack_get_xrun_delayed_usecs");
  860. jack_reset_max_delayed_usecs_fun = (jack_reset_max_delayed_usecs_fun_def)dlsym(gLibrary, "jack_reset_max_delayed_usecs");
  861. jack_acquire_real_time_scheduling_fun = (jack_acquire_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_acquire_real_time_scheduling");
  862. jack_client_create_thread_fun = (jack_client_create_thread_fun_def)dlsym(gLibrary, "jack_client_create_thread");
  863. jack_drop_real_time_scheduling_fun = (jack_drop_real_time_scheduling_fun_def)dlsym(gLibrary, "jack_drop_real_time_scheduling");
  864. jack_get_internal_client_name_fun = (jack_get_internal_client_name_fun_def)dlsym(gLibrary, "jack_get_internal_client_name");
  865. jack_internal_client_handle_fun = (jack_internal_client_handle_fun_def)dlsym(gLibrary, "jack_internal_client_handle");
  866. jack_internal_client_load_fun = (jack_internal_client_load_fun_def)dlsym(gLibrary, "jack_internal_client_load");
  867. jack_internal_client_unload_fun = (jack_internal_client_unload_fun_def)dlsym(gLibrary, "jack_internal_client_unload");
  868. jack_client_open_fun = (jack_client_open_fun_def)dlsym(gLibrary, "jack_client_open");
  869. jack_client_new_fun = (jack_client_new_fun_def)dlsym(gLibrary, "jack_client_new");
  870. jack_client_close_fun = (jack_client_close_fun_def)dlsym(gLibrary, "jack_client_close");
  871. return true;
  872. error:
  873. if (jackLibrary) dlclose(jackLibrary);
  874. if (jackmpLibrary) dlclose(jackmpLibrary);
  875. return false;
  876. }