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.

1298 lines
58KB

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