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.

1235 lines
56KB

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