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.

1109 lines
52KB

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