Audio plugin host https://kx.studio/carla
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.

1596 lines
52KB

  1. /*
  2. * JackBridge (Part 1, JACK functions)
  3. * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "JackBridge.hpp"
  17. #if ! (defined(JACKBRIDGE_DIRECT) || defined(JACKBRIDGE_DUMMY))
  18. #include "CarlaLibUtils.hpp"
  19. // -----------------------------------------------------------------------------
  20. typedef void (*jacksym_get_version)(int*, int*, int*, int*);
  21. typedef const char* (*jacksym_get_version_string)();
  22. typedef jack_client_t* (*jacksym_client_open)(const char*, jack_options_t, jack_status_t*, ...);
  23. typedef const char* (*jacksym_client_rename)(jack_client_t* client, const char* new_name);
  24. typedef int (*jacksym_client_close)(jack_client_t*);
  25. typedef int (*jacksym_client_name_size)();
  26. typedef char* (*jacksym_get_client_name)(jack_client_t*);
  27. typedef char* (*jacksym_get_uuid_for_client_name)(jack_client_t*, const char*);
  28. typedef char* (*jacksym_get_client_name_by_uuid)(jack_client_t*, const char*);
  29. typedef int (*jacksym_activate)(jack_client_t*);
  30. typedef int (*jacksym_deactivate)(jack_client_t*);
  31. typedef int (*jacksym_is_realtime)(jack_client_t*);
  32. typedef int (*jacksym_set_thread_init_callback)(jack_client_t*, JackThreadInitCallback, void*);
  33. typedef void (*jacksym_on_shutdown)(jack_client_t*, JackShutdownCallback, void*);
  34. typedef void (*jacksym_on_info_shutdown)(jack_client_t*, JackInfoShutdownCallback, void*);
  35. typedef int (*jacksym_set_process_callback)(jack_client_t*, JackProcessCallback, void*);
  36. typedef int (*jacksym_set_freewheel_callback)(jack_client_t*, JackFreewheelCallback, void*);
  37. typedef int (*jacksym_set_buffer_size_callback)(jack_client_t*, JackBufferSizeCallback, void*);
  38. typedef int (*jacksym_set_sample_rate_callback)(jack_client_t*, JackSampleRateCallback, void*);
  39. typedef int (*jacksym_set_client_registration_callback)(jack_client_t*, JackClientRegistrationCallback, void*);
  40. typedef int (*jacksym_set_port_registration_callback)(jack_client_t*, JackPortRegistrationCallback, void*);
  41. typedef int (*jacksym_set_port_rename_callback)(jack_client_t*, JackPortRenameCallback, void*);
  42. typedef int (*jacksym_set_port_connect_callback)(jack_client_t*, JackPortConnectCallback, void*);
  43. typedef int (*jacksym_set_graph_order_callback)(jack_client_t*, JackGraphOrderCallback, void*);
  44. typedef int (*jacksym_set_xrun_callback)(jack_client_t*, JackXRunCallback, void*);
  45. typedef int (*jacksym_set_latency_callback)(jack_client_t*, JackLatencyCallback, void*);
  46. typedef int (*jacksym_set_freewheel)(jack_client_t*, int);
  47. typedef int (*jacksym_set_buffer_size)(jack_client_t*, jack_nframes_t);
  48. typedef jack_nframes_t (*jacksym_get_sample_rate)(jack_client_t*);
  49. typedef jack_nframes_t (*jacksym_get_buffer_size)(jack_client_t*);
  50. typedef float (*jacksym_cpu_load)(jack_client_t*);
  51. typedef jack_port_t* (*jacksym_port_register)(jack_client_t*, const char*, const char*, unsigned long, unsigned long);
  52. typedef int (*jacksym_port_unregister)(jack_client_t*, jack_port_t*);
  53. typedef void* (*jacksym_port_get_buffer)(jack_port_t*, jack_nframes_t);
  54. typedef const char* (*jacksym_port_name)(const jack_port_t*);
  55. typedef jack_uuid_t (*jacksym_port_uuid)(const jack_port_t*);
  56. typedef const char* (*jacksym_port_short_name)(const jack_port_t*);
  57. typedef int (*jacksym_port_flags)(const jack_port_t*);
  58. typedef const char* (*jacksym_port_type)(const jack_port_t*);
  59. typedef int (*jacksym_port_is_mine)(const jack_client_t*, const jack_port_t*);
  60. typedef int (*jacksym_port_connected)(const jack_port_t*);
  61. typedef int (*jacksym_port_connected_to)(const jack_port_t*, const char*);
  62. typedef const char** (*jacksym_port_get_connections)(const jack_port_t*);
  63. typedef const char** (*jacksym_port_get_all_connections)(const jack_client_t*, const jack_port_t*);
  64. typedef int (*jacksym_port_set_name)(jack_port_t*, const char*);
  65. typedef int (*jacksym_port_set_alias)(jack_port_t*, const char*);
  66. typedef int (*jacksym_port_unset_alias)(jack_port_t*, const char*);
  67. typedef int (*jacksym_port_get_aliases)(const jack_port_t*, char* const aliases[2]);
  68. typedef int (*jacksym_port_request_monitor)(jack_port_t*, int);
  69. typedef int (*jacksym_port_request_monitor_by_name)(jack_client_t*, const char*, int);
  70. typedef int (*jacksym_port_ensure_monitor)(jack_port_t*, int);
  71. typedef int (*jacksym_port_monitoring_input)(jack_port_t*);
  72. typedef int (*jacksym_connect)(jack_client_t*, const char*, const char*);
  73. typedef int (*jacksym_disconnect)(jack_client_t*, const char*, const char*);
  74. typedef int (*jacksym_port_disconnect)(jack_client_t*, jack_port_t*);
  75. typedef int (*jacksym_port_name_size)();
  76. typedef int (*jacksym_port_type_size)();
  77. typedef size_t (*jacksym_port_type_get_buffer_size)(jack_client_t*, const char*);
  78. typedef void (*jacksym_port_get_latency_range)(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*);
  79. typedef void (*jacksym_port_set_latency_range)(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*);
  80. typedef int (*jacksym_recompute_total_latencies)(jack_client_t*);
  81. typedef const char** (*jacksym_get_ports)(jack_client_t*, const char*, const char*, unsigned long);
  82. typedef jack_port_t* (*jacksym_port_by_name)(jack_client_t*, const char*);
  83. typedef jack_port_t* (*jacksym_port_by_id)(jack_client_t*, jack_port_id_t);
  84. typedef void (*jacksym_free)(void*);
  85. typedef uint32_t (*jacksym_midi_get_event_count)(void*);
  86. typedef int (*jacksym_midi_event_get)(jack_midi_event_t*, void*, uint32_t);
  87. typedef void (*jacksym_midi_clear_buffer)(void*);
  88. typedef int (*jacksym_midi_event_write)(void*, jack_nframes_t, const jack_midi_data_t*, size_t);
  89. typedef jack_midi_data_t* (*jacksym_midi_event_reserve)(void*, jack_nframes_t, size_t);
  90. typedef int (*jacksym_release_timebase)(jack_client_t*);
  91. typedef int (*jacksym_set_sync_callback)(jack_client_t*, JackSyncCallback, void*);
  92. typedef int (*jacksym_set_sync_timeout)(jack_client_t*, jack_time_t);
  93. typedef int (*jacksym_set_timebase_callback)(jack_client_t*, int, JackTimebaseCallback, void*);
  94. typedef int (*jacksym_transport_locate)(jack_client_t*, jack_nframes_t);
  95. typedef jack_transport_state_t (*jacksym_transport_query)(const jack_client_t*, jack_position_t*);
  96. typedef jack_nframes_t (*jacksym_get_current_transport_frame)(const jack_client_t*);
  97. typedef int (*jacksym_transport_reposition)(jack_client_t*, const jack_position_t*);
  98. typedef void (*jacksym_transport_start)(jack_client_t*);
  99. typedef void (*jacksym_transport_stop)(jack_client_t*);
  100. typedef int (*jacksym_set_property)(jack_client_t*, jack_uuid_t, const char*, const char*, const char*);
  101. typedef int (*jacksym_get_property)(jack_uuid_t, const char*, char**, char**);
  102. typedef void (*jacksym_free_description)(jack_description_t*, int);
  103. typedef int (*jacksym_get_properties)(jack_uuid_t, jack_description_t*);
  104. typedef int (*jacksym_get_all_properties)(jack_description_t**);
  105. typedef int (*jacksym_remove_property)(jack_client_t*, jack_uuid_t, const char*);
  106. typedef int (*jacksym_remove_properties)(jack_client_t*, jack_uuid_t);
  107. typedef int (*jacksym_remove_all_properties)(jack_client_t*);
  108. typedef int (*jacksym_set_property_change_callback)(jack_client_t*, JackPropertyChangeCallback, void*);
  109. // -----------------------------------------------------------------------------
  110. struct JackBridge {
  111. void* lib;
  112. jacksym_get_version get_version_ptr;
  113. jacksym_get_version_string get_version_string_ptr;
  114. jacksym_client_open client_open_ptr;
  115. jacksym_client_rename client_rename_ptr;
  116. jacksym_client_close client_close_ptr;
  117. jacksym_client_name_size client_name_size_ptr;
  118. jacksym_get_client_name get_client_name_ptr;
  119. jacksym_get_uuid_for_client_name get_uuid_for_client_name_ptr;
  120. jacksym_get_client_name_by_uuid get_client_name_by_uuid_ptr;
  121. jacksym_activate activate_ptr;
  122. jacksym_deactivate deactivate_ptr;
  123. jacksym_is_realtime is_realtime_ptr;
  124. jacksym_set_thread_init_callback set_thread_init_callback_ptr;
  125. jacksym_on_shutdown on_shutdown_ptr;
  126. jacksym_on_info_shutdown on_info_shutdown_ptr;
  127. jacksym_set_process_callback set_process_callback_ptr;
  128. jacksym_set_freewheel_callback set_freewheel_callback_ptr;
  129. jacksym_set_buffer_size_callback set_buffer_size_callback_ptr;
  130. jacksym_set_sample_rate_callback set_sample_rate_callback_ptr;
  131. jacksym_set_client_registration_callback set_client_registration_callback_ptr;
  132. jacksym_set_port_registration_callback set_port_registration_callback_ptr;
  133. jacksym_set_port_rename_callback set_port_rename_callback_ptr;
  134. jacksym_set_port_connect_callback set_port_connect_callback_ptr;
  135. jacksym_set_xrun_callback set_xrun_callback_ptr;
  136. jacksym_set_latency_callback set_latency_callback_ptr;
  137. jacksym_set_freewheel set_freewheel_ptr;
  138. jacksym_set_buffer_size set_buffer_size_ptr;
  139. jacksym_get_sample_rate get_sample_rate_ptr;
  140. jacksym_get_buffer_size get_buffer_size_ptr;
  141. jacksym_cpu_load cpu_load_ptr;
  142. jacksym_port_register port_register_ptr;
  143. jacksym_port_unregister port_unregister_ptr;
  144. jacksym_port_get_buffer port_get_buffer_ptr;
  145. jacksym_port_name port_name_ptr;
  146. jacksym_port_uuid port_uuid_ptr;
  147. jacksym_port_short_name port_short_name_ptr;
  148. jacksym_port_flags port_flags_ptr;
  149. jacksym_port_type port_type_ptr;
  150. jacksym_port_is_mine port_is_mine_ptr;
  151. jacksym_port_connected port_connected_ptr;
  152. jacksym_port_connected_to port_connected_to_ptr;
  153. jacksym_port_get_connections port_get_connections_ptr;
  154. jacksym_port_get_all_connections port_get_all_connections_ptr;
  155. jacksym_port_set_name port_set_name_ptr;
  156. jacksym_port_set_alias port_set_alias_ptr;
  157. jacksym_port_unset_alias port_unset_alias_ptr;
  158. jacksym_port_get_aliases port_get_aliases_ptr;
  159. jacksym_port_request_monitor port_request_monitor_ptr;
  160. jacksym_port_request_monitor_by_name port_request_monitor_by_name_ptr;
  161. jacksym_port_ensure_monitor port_ensure_monitor_ptr;
  162. jacksym_port_monitoring_input port_monitoring_input_ptr;
  163. jacksym_connect connect_ptr;
  164. jacksym_disconnect disconnect_ptr;
  165. jacksym_port_disconnect port_disconnect_ptr;
  166. jacksym_port_name_size port_name_size_ptr;
  167. jacksym_port_type_size port_type_size_ptr;
  168. jacksym_port_type_get_buffer_size port_type_get_buffer_size_ptr;
  169. jacksym_port_get_latency_range port_get_latency_range_ptr;
  170. jacksym_port_set_latency_range port_set_latency_range_ptr;
  171. jacksym_recompute_total_latencies recompute_total_latencies_ptr;
  172. jacksym_get_ports get_ports_ptr;
  173. jacksym_port_by_name port_by_name_ptr;
  174. jacksym_port_by_id port_by_id_ptr;
  175. jacksym_free free_ptr;
  176. jacksym_midi_get_event_count midi_get_event_count_ptr;
  177. jacksym_midi_event_get midi_event_get_ptr;
  178. jacksym_midi_clear_buffer midi_clear_buffer_ptr;
  179. jacksym_midi_event_write midi_event_write_ptr;
  180. jacksym_midi_event_reserve midi_event_reserve_ptr;
  181. jacksym_release_timebase release_timebase_ptr;
  182. jacksym_set_sync_callback set_sync_callback_ptr;
  183. jacksym_set_sync_timeout set_sync_timeout_ptr;
  184. jacksym_set_timebase_callback set_timebase_callback_ptr;
  185. jacksym_transport_locate transport_locate_ptr;
  186. jacksym_transport_query transport_query_ptr;
  187. jacksym_get_current_transport_frame get_current_transport_frame_ptr;
  188. jacksym_transport_reposition transport_reposition_ptr;
  189. jacksym_transport_start transport_start_ptr;
  190. jacksym_transport_stop transport_stop_ptr;
  191. jacksym_set_property set_property_ptr;
  192. jacksym_get_property get_property_ptr;
  193. jacksym_free_description free_description_ptr;
  194. jacksym_get_properties get_properties_ptr;
  195. jacksym_get_all_properties get_all_properties_ptr;
  196. jacksym_remove_property remove_property_ptr;
  197. jacksym_remove_properties remove_properties_ptr;
  198. jacksym_remove_all_properties remove_all_properties_ptr;
  199. jacksym_set_property_change_callback set_property_change_callback_ptr;
  200. JackBridge()
  201. : lib(nullptr),
  202. get_version_ptr(nullptr),
  203. get_version_string_ptr(nullptr),
  204. client_open_ptr(nullptr),
  205. client_rename_ptr(nullptr),
  206. client_close_ptr(nullptr),
  207. client_name_size_ptr(nullptr),
  208. get_client_name_ptr(nullptr),
  209. get_uuid_for_client_name_ptr(nullptr),
  210. get_client_name_by_uuid_ptr(nullptr),
  211. activate_ptr(nullptr),
  212. deactivate_ptr(nullptr),
  213. is_realtime_ptr(nullptr),
  214. set_thread_init_callback_ptr(nullptr),
  215. on_shutdown_ptr(nullptr),
  216. on_info_shutdown_ptr(nullptr),
  217. set_process_callback_ptr(nullptr),
  218. set_freewheel_callback_ptr(nullptr),
  219. set_buffer_size_callback_ptr(nullptr),
  220. set_sample_rate_callback_ptr(nullptr),
  221. set_client_registration_callback_ptr(nullptr),
  222. set_port_registration_callback_ptr(nullptr),
  223. set_port_rename_callback_ptr(nullptr),
  224. set_port_connect_callback_ptr(nullptr),
  225. set_xrun_callback_ptr(nullptr),
  226. set_latency_callback_ptr(nullptr),
  227. set_freewheel_ptr(nullptr),
  228. set_buffer_size_ptr(nullptr),
  229. get_sample_rate_ptr(nullptr),
  230. get_buffer_size_ptr(nullptr),
  231. cpu_load_ptr(nullptr),
  232. port_register_ptr(nullptr),
  233. port_unregister_ptr(nullptr),
  234. port_get_buffer_ptr(nullptr),
  235. port_name_ptr(nullptr),
  236. port_uuid_ptr(nullptr),
  237. port_short_name_ptr(nullptr),
  238. port_flags_ptr(nullptr),
  239. port_type_ptr(nullptr),
  240. port_is_mine_ptr(nullptr),
  241. port_connected_ptr(nullptr),
  242. port_connected_to_ptr(nullptr),
  243. port_get_connections_ptr(nullptr),
  244. port_get_all_connections_ptr(nullptr),
  245. port_set_name_ptr(nullptr),
  246. port_set_alias_ptr(nullptr),
  247. port_unset_alias_ptr(nullptr),
  248. port_get_aliases_ptr(nullptr),
  249. port_request_monitor_ptr(nullptr),
  250. port_request_monitor_by_name_ptr(nullptr),
  251. port_ensure_monitor_ptr(nullptr),
  252. port_monitoring_input_ptr(nullptr),
  253. connect_ptr(nullptr),
  254. disconnect_ptr(nullptr),
  255. port_disconnect_ptr(nullptr),
  256. port_name_size_ptr(nullptr),
  257. port_type_size_ptr(nullptr),
  258. port_type_get_buffer_size_ptr(nullptr),
  259. port_get_latency_range_ptr(nullptr),
  260. port_set_latency_range_ptr(nullptr),
  261. recompute_total_latencies_ptr(nullptr),
  262. get_ports_ptr(nullptr),
  263. port_by_name_ptr(nullptr),
  264. port_by_id_ptr(nullptr),
  265. free_ptr(nullptr),
  266. midi_get_event_count_ptr(nullptr),
  267. midi_event_get_ptr(nullptr),
  268. midi_clear_buffer_ptr(nullptr),
  269. midi_event_write_ptr(nullptr),
  270. midi_event_reserve_ptr(nullptr),
  271. release_timebase_ptr(nullptr),
  272. set_sync_callback_ptr(nullptr),
  273. set_sync_timeout_ptr(nullptr),
  274. set_timebase_callback_ptr(nullptr),
  275. transport_locate_ptr(nullptr),
  276. transport_query_ptr(nullptr),
  277. get_current_transport_frame_ptr(nullptr),
  278. transport_reposition_ptr(nullptr),
  279. transport_start_ptr(nullptr),
  280. transport_stop_ptr(nullptr),
  281. set_property_ptr(nullptr),
  282. get_property_ptr(nullptr),
  283. free_description_ptr(nullptr),
  284. get_properties_ptr(nullptr),
  285. get_all_properties_ptr(nullptr),
  286. remove_property_ptr(nullptr),
  287. remove_properties_ptr(nullptr),
  288. remove_all_properties_ptr(nullptr),
  289. set_property_change_callback_ptr(nullptr)
  290. {
  291. # if defined(CARLA_OS_MAC)
  292. const char* const filename("libjack.dylib");
  293. # elif defined(CARLA_OS_WIN)
  294. const char* const filename("libjack.dll");
  295. # else
  296. const char* const filename("libjack.so.0");
  297. # endif
  298. lib = lib_open(filename);
  299. if (lib == nullptr)
  300. {
  301. fprintf(stderr, "Failed to load JACK DLL, reason:\n%s\n", lib_error(filename));
  302. return;
  303. }
  304. else
  305. {
  306. fprintf(stdout, "%s loaded sucessfully!\n", filename);
  307. }
  308. #define JOIN(a, b) a ## b
  309. #define LIB_SYMBOL(NAME) JOIN(NAME, _ptr) = (jacksym_##NAME)lib_symbol(lib, "jack_" #NAME);
  310. LIB_SYMBOL(get_version)
  311. LIB_SYMBOL(get_version_string)
  312. LIB_SYMBOL(client_open)
  313. LIB_SYMBOL(client_rename)
  314. LIB_SYMBOL(client_close)
  315. LIB_SYMBOL(client_name_size)
  316. LIB_SYMBOL(get_client_name)
  317. LIB_SYMBOL(get_uuid_for_client_name)
  318. LIB_SYMBOL(get_client_name_by_uuid)
  319. LIB_SYMBOL(activate)
  320. LIB_SYMBOL(deactivate)
  321. LIB_SYMBOL(is_realtime)
  322. LIB_SYMBOL(set_thread_init_callback)
  323. LIB_SYMBOL(on_shutdown)
  324. LIB_SYMBOL(on_info_shutdown)
  325. LIB_SYMBOL(set_process_callback)
  326. LIB_SYMBOL(set_freewheel_callback)
  327. LIB_SYMBOL(set_buffer_size_callback)
  328. LIB_SYMBOL(set_sample_rate_callback)
  329. LIB_SYMBOL(set_client_registration_callback)
  330. LIB_SYMBOL(set_port_registration_callback)
  331. LIB_SYMBOL(set_port_rename_callback)
  332. LIB_SYMBOL(set_port_connect_callback)
  333. LIB_SYMBOL(set_xrun_callback)
  334. LIB_SYMBOL(set_latency_callback)
  335. LIB_SYMBOL(set_freewheel)
  336. LIB_SYMBOL(set_buffer_size)
  337. LIB_SYMBOL(get_sample_rate)
  338. LIB_SYMBOL(get_buffer_size)
  339. LIB_SYMBOL(cpu_load)
  340. LIB_SYMBOL(port_register)
  341. LIB_SYMBOL(port_unregister)
  342. LIB_SYMBOL(port_get_buffer)
  343. LIB_SYMBOL(port_name)
  344. LIB_SYMBOL(port_uuid)
  345. LIB_SYMBOL(port_short_name)
  346. LIB_SYMBOL(port_flags)
  347. LIB_SYMBOL(port_type)
  348. LIB_SYMBOL(port_is_mine)
  349. LIB_SYMBOL(port_connected)
  350. LIB_SYMBOL(port_connected_to)
  351. LIB_SYMBOL(port_get_connections)
  352. LIB_SYMBOL(port_get_all_connections)
  353. LIB_SYMBOL(port_set_name)
  354. LIB_SYMBOL(port_set_alias)
  355. LIB_SYMBOL(port_unset_alias)
  356. LIB_SYMBOL(port_get_aliases)
  357. LIB_SYMBOL(port_request_monitor)
  358. LIB_SYMBOL(port_request_monitor_by_name)
  359. LIB_SYMBOL(port_ensure_monitor)
  360. LIB_SYMBOL(port_monitoring_input)
  361. LIB_SYMBOL(connect)
  362. LIB_SYMBOL(disconnect)
  363. LIB_SYMBOL(port_disconnect)
  364. LIB_SYMBOL(port_name_size)
  365. LIB_SYMBOL(port_type_size)
  366. LIB_SYMBOL(port_type_get_buffer_size)
  367. LIB_SYMBOL(port_get_latency_range)
  368. LIB_SYMBOL(port_set_latency_range)
  369. LIB_SYMBOL(recompute_total_latencies)
  370. LIB_SYMBOL(get_ports)
  371. LIB_SYMBOL(port_by_name)
  372. LIB_SYMBOL(port_by_id)
  373. LIB_SYMBOL(free)
  374. LIB_SYMBOL(midi_get_event_count)
  375. LIB_SYMBOL(midi_event_get)
  376. LIB_SYMBOL(midi_clear_buffer)
  377. LIB_SYMBOL(midi_event_write)
  378. LIB_SYMBOL(midi_event_reserve)
  379. LIB_SYMBOL(release_timebase)
  380. LIB_SYMBOL(set_sync_callback)
  381. LIB_SYMBOL(set_sync_timeout)
  382. LIB_SYMBOL(set_timebase_callback)
  383. LIB_SYMBOL(transport_locate)
  384. LIB_SYMBOL(transport_query)
  385. LIB_SYMBOL(get_current_transport_frame)
  386. LIB_SYMBOL(transport_reposition)
  387. LIB_SYMBOL(transport_start)
  388. LIB_SYMBOL(transport_stop)
  389. LIB_SYMBOL(set_property)
  390. LIB_SYMBOL(get_property)
  391. LIB_SYMBOL(free_description)
  392. LIB_SYMBOL(get_properties)
  393. LIB_SYMBOL(get_all_properties)
  394. LIB_SYMBOL(remove_property)
  395. LIB_SYMBOL(remove_properties)
  396. LIB_SYMBOL(remove_all_properties)
  397. LIB_SYMBOL(set_property_change_callback)
  398. #undef JOIN
  399. #undef LIB_SYMBOL
  400. }
  401. ~JackBridge()
  402. {
  403. if (lib != nullptr)
  404. {
  405. lib_close(lib);
  406. lib = nullptr;
  407. }
  408. }
  409. };
  410. static const JackBridge bridge;
  411. #endif // ! JACKBRIDGE_DIRECT
  412. // -----------------------------------------------------------------------------
  413. bool jackbridge_is_ok() noexcept
  414. {
  415. #if defined(JACKBRIDGE_DUMMY) || defined(JACKBRIDGE_DIRECT)
  416. return true;
  417. #else
  418. return (bridge.lib != nullptr);
  419. #endif
  420. }
  421. // -----------------------------------------------------------------------------
  422. void jackbridge_get_version(int* major_ptr, int* minor_ptr, int* micro_ptr, int* proto_ptr)
  423. {
  424. #if defined(JACKBRIDGE_DUMMY)
  425. #elif defined(JACKBRIDGE_DIRECT)
  426. return jack_get_version(major_ptr, minor_ptr, micro_ptr, proto_ptr);
  427. #else
  428. if (bridge.get_version_ptr != nullptr)
  429. return bridge.get_version_ptr(major_ptr, minor_ptr, micro_ptr, proto_ptr);
  430. #endif
  431. if (major_ptr != nullptr)
  432. *major_ptr = 0;
  433. if (minor_ptr != nullptr)
  434. *minor_ptr = 0;
  435. if (micro_ptr != nullptr)
  436. *micro_ptr = 0;
  437. if (proto_ptr != nullptr)
  438. *proto_ptr = 0;
  439. }
  440. const char* jackbridge_get_version_string()
  441. {
  442. #if defined(JACKBRIDGE_DUMMY)
  443. #elif defined(JACKBRIDGE_DIRECT)
  444. return jack_get_version_string();
  445. #else
  446. if (bridge.get_version_string_ptr != nullptr)
  447. return bridge.get_version_string_ptr();
  448. #endif
  449. return nullptr;
  450. }
  451. // -----------------------------------------------------------------------------
  452. jack_client_t* jackbridge_client_open(const char* client_name, jack_options_t options, jack_status_t* status, ...)
  453. {
  454. #if defined(JACKBRIDGE_DUMMY)
  455. #elif defined(JACKBRIDGE_DIRECT)
  456. return jack_client_open(client_name, options, status);
  457. #else
  458. if (bridge.client_open_ptr != nullptr)
  459. return bridge.client_open_ptr(client_name, options, status);
  460. #endif
  461. if (status != nullptr)
  462. *status = JackServerError;
  463. return nullptr;
  464. }
  465. bool jackbridge_client_close(jack_client_t* client)
  466. {
  467. #if defined(JACKBRIDGE_DUMMY)
  468. #elif defined(JACKBRIDGE_DIRECT)
  469. return (jack_client_close(client) == 0);
  470. #else
  471. if (bridge.client_close_ptr != nullptr)
  472. return (bridge.client_close_ptr(client) == 0);
  473. #endif
  474. return false;
  475. }
  476. // -----------------------------------------------------------------------------
  477. int jackbridge_client_name_size()
  478. {
  479. #if defined(JACKBRIDGE_DUMMY)
  480. #elif defined(JACKBRIDGE_DIRECT)
  481. return jack_client_name_size();
  482. #else
  483. if (bridge.client_name_size_ptr != nullptr)
  484. return bridge.client_name_size_ptr();
  485. #endif
  486. return 0;
  487. }
  488. char* jackbridge_get_client_name(jack_client_t* client)
  489. {
  490. #if defined(JACKBRIDGE_DUMMY)
  491. #elif defined(JACKBRIDGE_DIRECT)
  492. return jack_get_client_name(client);
  493. #else
  494. if (bridge.get_client_name_ptr != nullptr)
  495. return bridge.get_client_name_ptr(client);
  496. #endif
  497. return nullptr;
  498. }
  499. // -----------------------------------------------------------------------------
  500. char* jackbridge_get_uuid_for_client_name(jack_client_t* client, const char* name)
  501. {
  502. #if defined(JACKBRIDGE_DUMMY)
  503. #elif defined(JACKBRIDGE_DIRECT)
  504. return jack_get_uuid_for_client_name(client, name);
  505. #else
  506. if (bridge.get_uuid_for_client_name_ptr != nullptr)
  507. return bridge.get_uuid_for_client_name_ptr(client, name);
  508. #endif
  509. return nullptr;
  510. }
  511. char* jackbridge_get_client_name_by_uuid(jack_client_t* client, const char* uuid)
  512. {
  513. #if defined(JACKBRIDGE_DUMMY)
  514. #elif defined(JACKBRIDGE_DIRECT)
  515. return jack_get_client_name_by_uuid(client, uuid);
  516. #else
  517. if (bridge.get_client_name_by_uuid_ptr != nullptr)
  518. return bridge.get_client_name_by_uuid_ptr(client, uuid);
  519. #endif
  520. return nullptr;
  521. }
  522. // -----------------------------------------------------------------------------
  523. bool jackbridge_activate(jack_client_t* client)
  524. {
  525. #if defined(JACKBRIDGE_DUMMY)
  526. #elif defined(JACKBRIDGE_DIRECT)
  527. return (jack_activate(client) == 0);
  528. #else
  529. if (bridge.activate_ptr != nullptr)
  530. return (bridge.activate_ptr(client) == 0);
  531. #endif
  532. return false;
  533. }
  534. bool jackbridge_deactivate(jack_client_t* client)
  535. {
  536. #if defined(JACKBRIDGE_DUMMY)
  537. #elif defined(JACKBRIDGE_DIRECT)
  538. return (jack_deactivate(client) == 0);
  539. #else
  540. if (bridge.deactivate_ptr != nullptr)
  541. return (bridge.deactivate_ptr(client) == 0);
  542. #endif
  543. return false;
  544. }
  545. bool jackbridge_is_realtime(jack_client_t* client)
  546. {
  547. #if defined(JACKBRIDGE_DUMMY)
  548. #elif defined(JACKBRIDGE_DIRECT)
  549. return jack_is_realtime(client);
  550. #else
  551. if (bridge.is_realtime_ptr != nullptr)
  552. return bridge.is_realtime_ptr(client);
  553. #endif
  554. return false;
  555. }
  556. // -----------------------------------------------------------------------------
  557. bool jackbridge_set_thread_init_callback(jack_client_t* client, JackThreadInitCallback thread_init_callback, void* arg)
  558. {
  559. #if defined(JACKBRIDGE_DUMMY)
  560. #elif defined(JACKBRIDGE_DIRECT)
  561. return (jack_set_thread_init_callback(client, thread_init_callback, arg) == 0);
  562. #else
  563. if (bridge.set_thread_init_callback_ptr != nullptr)
  564. return (bridge.set_thread_init_callback_ptr(client, thread_init_callback, arg) == 0);
  565. #endif
  566. return false;
  567. }
  568. void jackbridge_on_shutdown(jack_client_t* client, JackShutdownCallback shutdown_callback, void* arg)
  569. {
  570. #if defined(JACKBRIDGE_DUMMY)
  571. #elif defined(JACKBRIDGE_DIRECT)
  572. jack_on_shutdown(client, shutdown_callback, arg);
  573. #else
  574. if (bridge.on_shutdown_ptr != nullptr)
  575. bridge.on_shutdown_ptr(client, shutdown_callback, arg);
  576. #endif
  577. }
  578. void jackbridge_on_info_shutdown(jack_client_t* client, JackInfoShutdownCallback shutdown_callback, void* arg)
  579. {
  580. #if defined(JACKBRIDGE_DUMMY)
  581. #elif defined(JACKBRIDGE_DIRECT)
  582. jack_on_info_shutdown(client, shutdown_callback, arg);
  583. #else
  584. if (bridge.on_info_shutdown_ptr != nullptr)
  585. bridge.on_info_shutdown_ptr(client, shutdown_callback, arg);
  586. #endif
  587. }
  588. bool jackbridge_set_process_callback(jack_client_t* client, JackProcessCallback process_callback, void* arg)
  589. {
  590. #if defined(JACKBRIDGE_DUMMY)
  591. #elif defined(JACKBRIDGE_DIRECT)
  592. return (jack_set_process_callback(client, process_callback, arg) == 0);
  593. #else
  594. if (bridge.set_process_callback_ptr != nullptr)
  595. return (bridge.set_process_callback_ptr(client, process_callback, arg) == 0);
  596. #endif
  597. return false;
  598. }
  599. bool jackbridge_set_freewheel_callback(jack_client_t* client, JackFreewheelCallback freewheel_callback, void* arg)
  600. {
  601. #if defined(JACKBRIDGE_DUMMY)
  602. #elif defined(JACKBRIDGE_DIRECT)
  603. return (jack_set_freewheel_callback(client, freewheel_callback, arg) == 0);
  604. #else
  605. if (bridge.set_freewheel_callback_ptr != nullptr)
  606. return (bridge.set_freewheel_callback_ptr(client, freewheel_callback, arg) == 0);
  607. #endif
  608. return false;
  609. }
  610. bool jackbridge_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCallback bufsize_callback, void* arg)
  611. {
  612. #if defined(JACKBRIDGE_DUMMY)
  613. #elif defined(JACKBRIDGE_DIRECT)
  614. return (jack_set_buffer_size_callback(client, bufsize_callback, arg) == 0);
  615. #else
  616. if (bridge.set_buffer_size_callback_ptr != nullptr)
  617. return (bridge.set_buffer_size_callback_ptr(client, bufsize_callback, arg) == 0);
  618. #endif
  619. return false;
  620. }
  621. bool jackbridge_set_sample_rate_callback(jack_client_t* client, JackSampleRateCallback srate_callback, void* arg)
  622. {
  623. #if defined(JACKBRIDGE_DUMMY)
  624. #elif defined(JACKBRIDGE_DIRECT)
  625. return (jack_set_sample_rate_callback(client, srate_callback, arg) == 0);
  626. #else
  627. if (bridge.set_sample_rate_callback_ptr != nullptr)
  628. return (bridge.set_sample_rate_callback_ptr(client, srate_callback, arg) == 0);
  629. #endif
  630. return false;
  631. }
  632. bool jackbridge_set_client_registration_callback(jack_client_t* client, JackClientRegistrationCallback registration_callback, void* arg)
  633. {
  634. #if defined(JACKBRIDGE_DUMMY)
  635. #elif defined(JACKBRIDGE_DIRECT)
  636. return (jack_set_client_registration_callback(client, registration_callback, arg) == 0);
  637. #else
  638. if (bridge.set_client_registration_callback_ptr != nullptr)
  639. return (bridge.set_client_registration_callback_ptr(client, registration_callback, arg) == 0);
  640. #endif
  641. return false;
  642. }
  643. bool jackbridge_set_port_registration_callback(jack_client_t* client, JackPortRegistrationCallback registration_callback, void *arg)
  644. {
  645. #if defined(JACKBRIDGE_DUMMY)
  646. #elif defined(JACKBRIDGE_DIRECT)
  647. return (jack_set_port_registration_callback(client, registration_callback, arg) == 0);
  648. #else
  649. if (bridge.set_port_registration_callback_ptr != nullptr)
  650. return (bridge.set_port_registration_callback_ptr(client, registration_callback, arg) == 0);
  651. #endif
  652. return false;
  653. }
  654. bool jackbridge_set_port_rename_callback(jack_client_t* client, JackPortRenameCallback rename_callback, void* arg)
  655. {
  656. #if defined(JACKBRIDGE_DUMMY)
  657. #elif defined(JACKBRIDGE_DIRECT)
  658. return (jack_set_port_rename_callback(client, rename_callback, arg) == 0);
  659. #else
  660. if (bridge.set_port_rename_callback_ptr != nullptr)
  661. return (bridge.set_port_rename_callback_ptr(client, rename_callback, arg) == 0);
  662. #endif
  663. return false;
  664. }
  665. bool jackbridge_set_port_connect_callback(jack_client_t* client, JackPortConnectCallback connect_callback, void* arg)
  666. {
  667. #if defined(JACKBRIDGE_DUMMY)
  668. #elif defined(JACKBRIDGE_DIRECT)
  669. return (jack_set_port_connect_callback(client, connect_callback, arg) == 0);
  670. #else
  671. if (bridge.set_port_connect_callback_ptr != nullptr)
  672. return (bridge.set_port_connect_callback_ptr(client, connect_callback, arg) == 0);
  673. #endif
  674. return false;
  675. }
  676. bool jackbridge_set_xrun_callback(jack_client_t* client, JackXRunCallback xrun_callback, void* arg)
  677. {
  678. #if defined(JACKBRIDGE_DUMMY)
  679. #elif defined(JACKBRIDGE_DIRECT)
  680. return (jack_set_xrun_callback(client, xrun_callback, arg) == 0);
  681. #else
  682. if (bridge.set_xrun_callback_ptr != nullptr)
  683. return (bridge.set_xrun_callback_ptr(client, xrun_callback, arg) == 0);
  684. #endif
  685. return false;
  686. }
  687. bool jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback latency_callback, void* arg)
  688. {
  689. #if defined(JACKBRIDGE_DUMMY)
  690. #elif defined(JACKBRIDGE_DIRECT)
  691. return (jack_set_latency_callback(client, latency_callback, arg) == 0);
  692. #else
  693. if (bridge.set_latency_callback_ptr != nullptr)
  694. return (bridge.set_latency_callback_ptr(client, latency_callback, arg) == 0);
  695. #endif
  696. return false;
  697. }
  698. // -----------------------------------------------------------------------------
  699. bool jackbridge_set_freewheel(jack_client_t* client, bool onoff)
  700. {
  701. #if defined(JACKBRIDGE_DUMMY)
  702. #elif defined(JACKBRIDGE_DIRECT)
  703. return jack_set_freewheel(client, onoff);
  704. #else
  705. if (bridge.set_freewheel_ptr != nullptr)
  706. return bridge.set_freewheel_ptr(client, onoff);
  707. #endif
  708. return false;
  709. }
  710. bool jackbridge_set_buffer_size(jack_client_t* client, jack_nframes_t nframes)
  711. {
  712. #if defined(JACKBRIDGE_DUMMY)
  713. #elif defined(JACKBRIDGE_DIRECT)
  714. return jack_set_buffer_size(client, nframes);
  715. #else
  716. if (bridge.set_buffer_size_ptr != nullptr)
  717. return bridge.set_buffer_size_ptr(client, nframes);
  718. #endif
  719. return false;
  720. }
  721. // -----------------------------------------------------------------------------
  722. jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client)
  723. {
  724. #if defined(JACKBRIDGE_DUMMY)
  725. #elif defined(JACKBRIDGE_DIRECT)
  726. return jack_get_sample_rate(client);
  727. #else
  728. if (bridge.get_sample_rate_ptr != nullptr)
  729. return bridge.get_sample_rate_ptr(client);
  730. #endif
  731. return 0;
  732. }
  733. jack_nframes_t jackbridge_get_buffer_size(jack_client_t* client)
  734. {
  735. #if defined(JACKBRIDGE_DUMMY)
  736. #elif defined(JACKBRIDGE_DIRECT)
  737. return jack_get_buffer_size(client);
  738. #else
  739. if (bridge.get_buffer_size_ptr != nullptr)
  740. return bridge.get_buffer_size_ptr(client);
  741. #endif
  742. return 0;
  743. }
  744. float jackbridge_cpu_load(jack_client_t* client)
  745. {
  746. #if defined(JACKBRIDGE_DUMMY)
  747. #elif defined(JACKBRIDGE_DIRECT)
  748. return jack_cpu_load(client);
  749. #else
  750. if (bridge.cpu_load_ptr != nullptr)
  751. return bridge.cpu_load_ptr(client);
  752. #endif
  753. return 0.0f;
  754. }
  755. // -----------------------------------------------------------------------------
  756. jack_port_t* jackbridge_port_register(jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size)
  757. {
  758. #if defined(JACKBRIDGE_DUMMY)
  759. #elif defined(JACKBRIDGE_DIRECT)
  760. return jack_port_register(client, port_name, port_type, flags, buffer_size);
  761. #else
  762. if (bridge.port_register_ptr != nullptr)
  763. return bridge.port_register_ptr(client, port_name, port_type, flags, buffer_size);
  764. #endif
  765. return nullptr;
  766. }
  767. bool jackbridge_port_unregister(jack_client_t* client, jack_port_t* port)
  768. {
  769. #if defined(JACKBRIDGE_DUMMY)
  770. #elif defined(JACKBRIDGE_DIRECT)
  771. return (jack_port_unregister(client, port) == 0);
  772. #else
  773. if (bridge.port_unregister_ptr != nullptr)
  774. return (bridge.port_unregister_ptr(client, port) == 0);
  775. #endif
  776. return false;
  777. }
  778. void* jackbridge_port_get_buffer(jack_port_t* port, jack_nframes_t nframes)
  779. {
  780. #if defined(JACKBRIDGE_DUMMY)
  781. #elif defined(JACKBRIDGE_DIRECT)
  782. return jack_port_get_buffer(port, nframes);
  783. #else
  784. if (bridge.port_get_buffer_ptr != nullptr)
  785. return bridge.port_get_buffer_ptr(port, nframes);
  786. #endif
  787. return nullptr;
  788. }
  789. // -----------------------------------------------------------------------------
  790. const char* jackbridge_port_name(const jack_port_t* port)
  791. {
  792. #if defined(JACKBRIDGE_DUMMY)
  793. #elif defined(JACKBRIDGE_DIRECT)
  794. return jack_port_name(port);
  795. #else
  796. if (bridge.port_name_ptr != nullptr)
  797. return bridge.port_name_ptr(port);
  798. #endif
  799. return nullptr;
  800. }
  801. jack_uuid_t jackbridge_port_uuid(const jack_port_t* port)
  802. {
  803. #if defined(JACKBRIDGE_DUMMY)
  804. #elif defined(JACKBRIDGE_DIRECT)
  805. return jack_port_uuid(port);
  806. #else
  807. if (bridge.port_uuid_ptr != nullptr)
  808. return bridge.port_uuid_ptr(port);
  809. #endif
  810. return 0;
  811. }
  812. const char* jackbridge_port_short_name(const jack_port_t* port)
  813. {
  814. #if defined(JACKBRIDGE_DUMMY)
  815. #elif defined(JACKBRIDGE_DIRECT)
  816. return jack_port_short_name(port);
  817. #else
  818. if (bridge.port_short_name_ptr != nullptr)
  819. return bridge.port_short_name_ptr(port);
  820. #endif
  821. return nullptr;
  822. }
  823. int jackbridge_port_flags(const jack_port_t* port)
  824. {
  825. #if defined(JACKBRIDGE_DUMMY)
  826. #elif defined(JACKBRIDGE_DIRECT)
  827. return jack_port_flags(port);
  828. #else
  829. if (bridge.port_flags_ptr != nullptr)
  830. return bridge.port_flags_ptr(port);
  831. #endif
  832. return 0x0;
  833. }
  834. const char* jackbridge_port_type(const jack_port_t* port)
  835. {
  836. #if defined(JACKBRIDGE_DUMMY)
  837. #elif defined(JACKBRIDGE_DIRECT)
  838. return jack_port_type(port);
  839. #else
  840. if (bridge.port_type_ptr != nullptr)
  841. return bridge.port_type_ptr(port);
  842. #endif
  843. return nullptr;
  844. }
  845. bool jackbridge_port_is_mine(const jack_client_t* client, const jack_port_t* port)
  846. {
  847. #if defined(JACKBRIDGE_DUMMY)
  848. #elif defined(JACKBRIDGE_DIRECT)
  849. return jack_port_is_mine(client, port);
  850. #else
  851. if (bridge.port_is_mine_ptr != nullptr)
  852. return bridge.port_is_mine_ptr(client, port);
  853. #endif
  854. return false;
  855. }
  856. int jackbridge_port_connected(const jack_port_t* port)
  857. {
  858. #if defined(JACKBRIDGE_DUMMY)
  859. #elif defined(JACKBRIDGE_DIRECT)
  860. return jack_port_connected(port);
  861. #else
  862. if (bridge.port_connected_ptr != nullptr)
  863. return bridge.port_connected_ptr(port);
  864. #endif
  865. return 0;
  866. }
  867. bool jackbridge_port_connected_to(const jack_port_t* port, const char* port_name)
  868. {
  869. #if defined(JACKBRIDGE_DUMMY)
  870. #elif defined(JACKBRIDGE_DIRECT)
  871. return jack_port_connected_to(port, port_name);
  872. #else
  873. if (bridge.port_connected_to_ptr != nullptr)
  874. return bridge.port_connected_to_ptr(port, port_name);
  875. #endif
  876. return false;
  877. }
  878. const char** jackbridge_port_get_connections(const jack_port_t* port)
  879. {
  880. #if defined(JACKBRIDGE_DUMMY)
  881. #elif defined(JACKBRIDGE_DIRECT)
  882. return jack_port_get_connections(port);
  883. #else
  884. if (bridge.port_get_connections_ptr != nullptr)
  885. return bridge.port_get_connections_ptr(port);
  886. #endif
  887. return nullptr;
  888. }
  889. const char** jackbridge_port_get_all_connections(const jack_client_t* client, const jack_port_t* port)
  890. {
  891. #if defined(JACKBRIDGE_DUMMY)
  892. #elif defined(JACKBRIDGE_DIRECT)
  893. return jack_port_get_all_connections(client, port);
  894. #else
  895. if (bridge.port_get_all_connections_ptr != nullptr)
  896. return bridge.port_get_all_connections_ptr(client, port);
  897. #endif
  898. return nullptr;
  899. }
  900. // -----------------------------------------------------------------------------
  901. bool jackbridge_port_set_name(jack_port_t* port, const char* port_name)
  902. {
  903. #if defined(JACKBRIDGE_DUMMY)
  904. #elif defined(JACKBRIDGE_DIRECT)
  905. return (jack_port_set_name(port, port_name) == 0);
  906. #else
  907. if (bridge.port_set_name_ptr != nullptr)
  908. return (bridge.port_set_name_ptr(port, port_name) == 0);
  909. #endif
  910. return false;
  911. }
  912. bool jackbridge_port_set_alias(jack_port_t* port, const char* alias)
  913. {
  914. #if defined(JACKBRIDGE_DUMMY)
  915. #elif defined(JACKBRIDGE_DIRECT)
  916. return (jack_port_set_alias(port, alias) == 0);
  917. #else
  918. if (bridge.port_set_alias_ptr != nullptr)
  919. return (bridge.port_set_alias_ptr(port, alias) == 0);
  920. #endif
  921. return false;
  922. }
  923. bool jackbridge_port_unset_alias(jack_port_t* port, const char* alias)
  924. {
  925. #if defined(JACKBRIDGE_DUMMY)
  926. #elif defined(JACKBRIDGE_DIRECT)
  927. return (jack_port_unset_alias(port, alias) == 0);
  928. #else
  929. if (bridge.port_unset_alias_ptr != nullptr)
  930. return (bridge.port_unset_alias_ptr(port, alias) == 0);
  931. #endif
  932. return false;
  933. }
  934. int jackbridge_port_get_aliases(const jack_port_t* port, char* const aliases[2])
  935. {
  936. #if defined(JACKBRIDGE_DUMMY)
  937. #elif defined(JACKBRIDGE_DIRECT)
  938. return (jack_port_get_aliases(port, aliases) == 0);
  939. #else
  940. if (bridge.port_get_aliases_ptr != nullptr)
  941. return bridge.port_get_aliases_ptr(port, aliases);
  942. #endif
  943. return 0;
  944. }
  945. // -----------------------------------------------------------------------------
  946. bool jackbridge_port_request_monitor(jack_port_t* port, bool onoff)
  947. {
  948. #if defined(JACKBRIDGE_DUMMY)
  949. #elif defined(JACKBRIDGE_DIRECT)
  950. return (jack_port_request_monitor(port, onoff) == 0);
  951. #else
  952. if (bridge.port_request_monitor_ptr != nullptr)
  953. return (bridge.port_request_monitor_ptr(port, onoff) == 0);
  954. #endif
  955. return false;
  956. }
  957. bool jackbridge_port_request_monitor_by_name(jack_client_t* client, const char* port_name, bool onoff)
  958. {
  959. #if defined(JACKBRIDGE_DUMMY)
  960. #elif defined(JACKBRIDGE_DIRECT)
  961. return (jack_port_request_monitor_by_name(client, port_name, onoff) == 0);
  962. #else
  963. if (bridge.port_request_monitor_by_name_ptr != nullptr)
  964. return (bridge.port_request_monitor_by_name_ptr(client, port_name, onoff) == 0);
  965. #endif
  966. return false;
  967. }
  968. bool jackbridge_port_ensure_monitor(jack_port_t* port, bool onoff)
  969. {
  970. #if defined(JACKBRIDGE_DUMMY)
  971. #elif defined(JACKBRIDGE_DIRECT)
  972. return (jack_port_ensure_monitor(port, onoff) == 0);
  973. #else
  974. if (bridge.port_ensure_monitor_ptr != nullptr)
  975. return (bridge.port_ensure_monitor_ptr(port, onoff) == 0);
  976. #endif
  977. return false;
  978. }
  979. bool jackbridge_port_monitoring_input(jack_port_t* port)
  980. {
  981. #if defined(JACKBRIDGE_DUMMY)
  982. #elif defined(JACKBRIDGE_DIRECT)
  983. return jack_port_monitoring_input(port);
  984. #else
  985. if (bridge.port_monitoring_input_ptr != nullptr)
  986. return bridge.port_monitoring_input_ptr(port);
  987. #endif
  988. return false;
  989. }
  990. // -----------------------------------------------------------------------------
  991. bool jackbridge_connect(jack_client_t* client, const char* source_port, const char* destination_port)
  992. {
  993. #if defined(JACKBRIDGE_DUMMY)
  994. #elif defined(JACKBRIDGE_DIRECT)
  995. return (jack_connect(client, source_port, destination_port) == 0);
  996. #else
  997. if (bridge.connect_ptr != nullptr)
  998. return (bridge.connect_ptr(client, source_port, destination_port) == 0);
  999. #endif
  1000. return false;
  1001. }
  1002. bool jackbridge_disconnect(jack_client_t* client, const char* source_port, const char* destination_port)
  1003. {
  1004. #if defined(JACKBRIDGE_DUMMY)
  1005. #elif defined(JACKBRIDGE_DIRECT)
  1006. return (jack_disconnect(client, source_port, destination_port) == 0);
  1007. #else
  1008. if (bridge.disconnect_ptr != nullptr)
  1009. return (bridge.disconnect_ptr(client, source_port, destination_port) == 0);
  1010. #endif
  1011. return false;
  1012. }
  1013. bool jackbridge_port_disconnect(jack_client_t* client, jack_port_t* port)
  1014. {
  1015. #if defined(JACKBRIDGE_DUMMY)
  1016. #elif defined(JACKBRIDGE_DIRECT)
  1017. return (jack_port_disconnect(client, port) == 0);
  1018. #else
  1019. if (bridge.port_disconnect_ptr != nullptr)
  1020. return (bridge.port_disconnect_ptr(client, port) == 0);
  1021. #endif
  1022. return false;
  1023. }
  1024. // -----------------------------------------------------------------------------
  1025. int jackbridge_port_name_size()
  1026. {
  1027. #if defined(JACKBRIDGE_DUMMY)
  1028. #elif defined(JACKBRIDGE_DIRECT)
  1029. return jack_port_name_size();
  1030. #else
  1031. if (bridge.port_name_size_ptr != nullptr)
  1032. return bridge.port_name_size_ptr();
  1033. #endif
  1034. return 0;
  1035. }
  1036. int jackbridge_port_type_size()
  1037. {
  1038. #if defined(JACKBRIDGE_DUMMY)
  1039. #elif defined(JACKBRIDGE_DIRECT)
  1040. return jack_port_type_size();
  1041. #else
  1042. if (bridge.port_type_size_ptr != nullptr)
  1043. return bridge.port_type_size_ptr();
  1044. #endif
  1045. return 0;
  1046. }
  1047. size_t jackbridge_port_type_get_buffer_size(jack_client_t* client, const char* port_type)
  1048. {
  1049. #if defined(JACKBRIDGE_DUMMY)
  1050. #elif defined(JACKBRIDGE_DIRECT)
  1051. return jack_port_type_get_buffer_size(client, port_type);
  1052. #else
  1053. if (bridge.port_type_get_buffer_size_ptr != nullptr)
  1054. return bridge.port_type_get_buffer_size_ptr(client, port_type);
  1055. #endif
  1056. return 0;
  1057. }
  1058. // -----------------------------------------------------------------------------
  1059. void jackbridge_port_get_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range)
  1060. {
  1061. #if defined(JACKBRIDGE_DUMMY)
  1062. #elif defined(JACKBRIDGE_DIRECT)
  1063. jack_port_get_latency_range(port, mode, range);
  1064. #else
  1065. if (bridge.port_get_latency_range_ptr != nullptr)
  1066. bridge.port_get_latency_range_ptr(port, mode, range);
  1067. #endif
  1068. }
  1069. void jackbridge_port_set_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range)
  1070. {
  1071. #if defined(JACKBRIDGE_DUMMY)
  1072. #elif defined(JACKBRIDGE_DIRECT)
  1073. jack_port_set_latency_range(port, mode, range);
  1074. #else
  1075. if (bridge.port_set_latency_range_ptr != nullptr)
  1076. bridge.port_set_latency_range_ptr(port, mode, range);
  1077. #endif
  1078. }
  1079. bool jackbridge_recompute_total_latencies(jack_client_t* client)
  1080. {
  1081. #if defined(JACKBRIDGE_DUMMY)
  1082. #elif defined(JACKBRIDGE_DIRECT)
  1083. return (jack_recompute_total_latencies(client) == 0);
  1084. #else
  1085. if (bridge.recompute_total_latencies_ptr != nullptr)
  1086. return (bridge.recompute_total_latencies_ptr(client) == 0);
  1087. #endif
  1088. return false;
  1089. }
  1090. // -----------------------------------------------------------------------------
  1091. const char** jackbridge_get_ports(jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
  1092. {
  1093. #if defined(JACKBRIDGE_DUMMY)
  1094. #elif defined(JACKBRIDGE_DIRECT)
  1095. return jack_get_ports(client, port_name_pattern, type_name_pattern, flags);
  1096. #else
  1097. if (bridge.get_ports_ptr != nullptr)
  1098. return bridge.get_ports_ptr(client, port_name_pattern, type_name_pattern, flags);
  1099. #endif
  1100. return nullptr;
  1101. }
  1102. jack_port_t* jackbridge_port_by_name(jack_client_t* client, const char* port_name)
  1103. {
  1104. #if defined(JACKBRIDGE_DUMMY)
  1105. #elif defined(JACKBRIDGE_DIRECT)
  1106. return jack_port_by_name(client, port_name);
  1107. #else
  1108. if (bridge.port_by_name_ptr != nullptr)
  1109. return bridge.port_by_name_ptr(client, port_name);
  1110. #endif
  1111. return nullptr;
  1112. }
  1113. jack_port_t* jackbridge_port_by_id(jack_client_t* client, jack_port_id_t port_id)
  1114. {
  1115. #if defined(JACKBRIDGE_DUMMY)
  1116. #elif defined(JACKBRIDGE_DIRECT)
  1117. return jack_port_by_id(client, port_id);
  1118. #else
  1119. if (bridge.port_by_id_ptr != nullptr)
  1120. return bridge.port_by_id_ptr(client, port_id);
  1121. #endif
  1122. return nullptr;
  1123. }
  1124. // -----------------------------------------------------------------------------
  1125. void jackbridge_free(void* ptr)
  1126. {
  1127. #if defined(JACKBRIDGE_DUMMY)
  1128. #elif defined(JACKBRIDGE_DIRECT)
  1129. return jack_free(ptr);
  1130. #else
  1131. if (bridge.free_ptr != nullptr)
  1132. return bridge.free_ptr(ptr);
  1133. // just in case
  1134. std::free(ptr);
  1135. #endif
  1136. }
  1137. // -----------------------------------------------------------------------------
  1138. uint32_t jackbridge_midi_get_event_count(void* port_buffer)
  1139. {
  1140. #if defined(JACKBRIDGE_DUMMY)
  1141. #elif defined(JACKBRIDGE_DIRECT)
  1142. return jack_midi_get_event_count(port_buffer);
  1143. #else
  1144. if (bridge.midi_get_event_count_ptr != nullptr)
  1145. return bridge.midi_get_event_count_ptr(port_buffer);
  1146. #endif
  1147. return 0;
  1148. }
  1149. bool jackbridge_midi_event_get(jack_midi_event_t* event, void* port_buffer, uint32_t event_index)
  1150. {
  1151. #if defined(JACKBRIDGE_DUMMY)
  1152. #elif defined(JACKBRIDGE_DIRECT)
  1153. return (jack_midi_event_get(event, port_buffer, event_index) == 0);
  1154. #else
  1155. if (bridge.midi_event_get_ptr != nullptr)
  1156. return (bridge.midi_event_get_ptr(event, port_buffer, event_index) == 0);
  1157. #endif
  1158. return false;
  1159. }
  1160. void jackbridge_midi_clear_buffer(void* port_buffer)
  1161. {
  1162. #if defined(JACKBRIDGE_DUMMY)
  1163. #elif defined(JACKBRIDGE_DIRECT)
  1164. jack_midi_clear_buffer(port_buffer);
  1165. #else
  1166. if (bridge.midi_clear_buffer_ptr != nullptr)
  1167. bridge.midi_clear_buffer_ptr(port_buffer);
  1168. #endif
  1169. }
  1170. bool jackbridge_midi_event_write(void* port_buffer, jack_nframes_t time, const jack_midi_data_t* data, size_t data_size)
  1171. {
  1172. #if defined(JACKBRIDGE_DUMMY)
  1173. #elif defined(JACKBRIDGE_DIRECT)
  1174. return (jack_midi_event_write(port_buffer, time, data, data_size) == 0);
  1175. #else
  1176. if (bridge.midi_event_write_ptr != nullptr)
  1177. return (bridge.midi_event_write_ptr(port_buffer, time, data, data_size) == 0);
  1178. #endif
  1179. return false;
  1180. }
  1181. jack_midi_data_t* jackbridge_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size)
  1182. {
  1183. #if defined(JACKBRIDGE_DUMMY)
  1184. #elif defined(JACKBRIDGE_DIRECT)
  1185. return jack_midi_event_reserve(port_buffer, time, data_size);
  1186. #else
  1187. if (bridge.midi_event_reserve_ptr != nullptr)
  1188. return bridge.midi_event_reserve_ptr(port_buffer, time, data_size);
  1189. #endif
  1190. return nullptr;
  1191. }
  1192. // -----------------------------------------------------------------------------
  1193. bool jackbridge_release_timebase(jack_client_t* client)
  1194. {
  1195. #if defined(JACKBRIDGE_DUMMY)
  1196. #elif defined(JACKBRIDGE_DIRECT)
  1197. return (jack_release_timebase(client) == 0);
  1198. #else
  1199. if (bridge.release_timebase_ptr != nullptr)
  1200. return (bridge.release_timebase_ptr(client) == 0);
  1201. #endif
  1202. return false;
  1203. }
  1204. bool jackbridge_set_sync_callback(jack_client_t* client, JackSyncCallback sync_callback, void* arg)
  1205. {
  1206. #if defined(JACKBRIDGE_DUMMY)
  1207. #elif defined(JACKBRIDGE_DIRECT)
  1208. return (jack_set_sync_callback(client, sync_callback, arg) == 0);
  1209. #else
  1210. if (bridge.set_sync_callback_ptr != nullptr)
  1211. return (bridge.set_sync_callback_ptr(client, sync_callback, arg) == 0);
  1212. #endif
  1213. return false;
  1214. }
  1215. bool jackbridge_set_sync_timeout(jack_client_t* client, jack_time_t timeout)
  1216. {
  1217. #if defined(JACKBRIDGE_DUMMY)
  1218. #elif defined(JACKBRIDGE_DIRECT)
  1219. return (jack_set_sync_timeout(client, timeout) == 0);
  1220. #else
  1221. if (bridge.set_sync_timeout_ptr != nullptr)
  1222. return (bridge.set_sync_timeout_ptr(client, timeout) == 0);
  1223. #endif
  1224. return false;
  1225. }
  1226. bool jackbridge_set_timebase_callback(jack_client_t* client, bool conditional, JackTimebaseCallback timebase_callback, void* arg)
  1227. {
  1228. #if defined(JACKBRIDGE_DUMMY)
  1229. #elif defined(JACKBRIDGE_DIRECT)
  1230. return (jack_set_timebase_callback(client, conditional, timebase_callback, arg) == 0);
  1231. #else
  1232. if (bridge.set_timebase_callback_ptr != nullptr)
  1233. return (bridge.set_timebase_callback_ptr(client, conditional, timebase_callback, arg) == 0);
  1234. #endif
  1235. return false;
  1236. }
  1237. bool jackbridge_transport_locate(jack_client_t* client, jack_nframes_t frame)
  1238. {
  1239. #if defined(JACKBRIDGE_DUMMY)
  1240. #elif defined(JACKBRIDGE_DIRECT)
  1241. return (jack_transport_locate(client, frame) == 0);
  1242. #else
  1243. if (bridge.transport_locate_ptr != nullptr)
  1244. return (bridge.transport_locate_ptr(client, frame) == 0);
  1245. #endif
  1246. return false;
  1247. }
  1248. jack_transport_state_t jackbridge_transport_query(const jack_client_t* client, jack_position_t* pos)
  1249. {
  1250. #if defined(JACKBRIDGE_DUMMY)
  1251. #elif defined(JACKBRIDGE_DIRECT)
  1252. return jack_transport_query(client, pos);
  1253. #else
  1254. if (bridge.transport_query_ptr != nullptr)
  1255. return bridge.transport_query_ptr(client, pos);
  1256. #endif
  1257. if (pos != nullptr)
  1258. {
  1259. // invalidate
  1260. pos->unique_1 = 0;
  1261. pos->unique_2 = 1;
  1262. }
  1263. return JackTransportStopped;
  1264. }
  1265. jack_nframes_t jackbridge_get_current_transport_frame(const jack_client_t* client)
  1266. {
  1267. #if defined(JACKBRIDGE_DUMMY)
  1268. #elif defined(JACKBRIDGE_DIRECT)
  1269. return jack_get_current_transport_frame(client);
  1270. #else
  1271. if (bridge.get_current_transport_frame_ptr != nullptr)
  1272. return bridge.get_current_transport_frame_ptr(client);
  1273. #endif
  1274. return 0;
  1275. }
  1276. bool jackbridge_transport_reposition(jack_client_t* client, const jack_position_t* pos)
  1277. {
  1278. #if defined(JACKBRIDGE_DUMMY)
  1279. #elif defined(JACKBRIDGE_DIRECT)
  1280. return (jack_transport_reposition(client, pos) == 0);
  1281. #else
  1282. if (bridge.transport_reposition_ptr != nullptr)
  1283. return (bridge.transport_reposition_ptr(client, pos) == 0);
  1284. #endif
  1285. return false;
  1286. }
  1287. void jackbridge_transport_start(jack_client_t* client)
  1288. {
  1289. #if defined(JACKBRIDGE_DUMMY)
  1290. #elif defined(JACKBRIDGE_DIRECT)
  1291. jack_transport_start(client);
  1292. #else
  1293. if (bridge.transport_start_ptr != nullptr)
  1294. bridge.transport_start_ptr(client);
  1295. #endif
  1296. }
  1297. void jackbridge_transport_stop(jack_client_t* client)
  1298. {
  1299. #if defined(JACKBRIDGE_DUMMY)
  1300. #elif defined(JACKBRIDGE_DIRECT)
  1301. jack_transport_stop(client);
  1302. #else
  1303. if (bridge.transport_stop_ptr != nullptr)
  1304. bridge.transport_stop_ptr(client);
  1305. #endif
  1306. }
  1307. // -----------------------------------------------------------------------------
  1308. bool jackbridge_set_property(jack_client_t* client, jack_uuid_t subject, const char* key, const char* value, const char* type)
  1309. {
  1310. #if defined(JACKBRIDGE_DUMMY)
  1311. #elif defined(JACKBRIDGE_DIRECT)
  1312. return (jack_set_property(client, subject, key, value, type) == 0);
  1313. #else
  1314. if (bridge.set_property_ptr != nullptr)
  1315. return (bridge.set_property_ptr(client, subject, key, value, type) == 0);
  1316. #endif
  1317. return false;
  1318. }
  1319. bool jackbridge_get_property(jack_uuid_t subject, const char* key, char** value, char** type)
  1320. {
  1321. #if defined(JACKBRIDGE_DUMMY)
  1322. #elif defined(JACKBRIDGE_DIRECT)
  1323. return (jack_get_property(subject, key, value, type) == 0);
  1324. #else
  1325. if (bridge.get_property_ptr != nullptr)
  1326. return (bridge.get_property_ptr(subject, key, value, type) == 0);
  1327. #endif
  1328. return false;
  1329. }
  1330. void jackbridge_free_description(jack_description_t* desc, bool free_description_itself)
  1331. {
  1332. #if defined(JACKBRIDGE_DUMMY)
  1333. #elif defined(JACKBRIDGE_DIRECT)
  1334. jack_free_description(desc, free_description_itself);
  1335. #else
  1336. if (bridge.free_description_ptr != nullptr)
  1337. bridge.free_description_ptr(desc, free_description_itself);
  1338. #endif
  1339. }
  1340. bool jackbridge_get_properties(jack_uuid_t subject, jack_description_t* desc)
  1341. {
  1342. #if defined(JACKBRIDGE_DUMMY)
  1343. #elif defined(JACKBRIDGE_DIRECT)
  1344. return (jack_get_properties(subject, desc) == 0);
  1345. #else
  1346. if (bridge.get_properties_ptr != nullptr)
  1347. return (bridge.get_properties_ptr(subject, desc) == 0);
  1348. #endif
  1349. return false;
  1350. }
  1351. bool jackbridge_get_all_properties(jack_description_t** descs)
  1352. {
  1353. #if defined(JACKBRIDGE_DUMMY)
  1354. #elif defined(JACKBRIDGE_DIRECT)
  1355. return (jack_get_all_properties(descs) == 0);
  1356. #else
  1357. if (bridge.get_all_properties_ptr != nullptr)
  1358. return (bridge.get_all_properties_ptr(descs) == 0);
  1359. #endif
  1360. return false;
  1361. }
  1362. bool jackbridge_remove_property(jack_client_t* client, jack_uuid_t subject, const char* key)
  1363. {
  1364. #if defined(JACKBRIDGE_DUMMY)
  1365. #elif defined(JACKBRIDGE_DIRECT)
  1366. return (jack_remove_property(client, subject, key) == 0);
  1367. #else
  1368. if (bridge.remove_property_ptr != nullptr)
  1369. return (bridge.remove_property_ptr(client, subject, key) == 0);
  1370. #endif
  1371. return false;
  1372. }
  1373. int jackbridge_remove_properties(jack_client_t* client, jack_uuid_t subject)
  1374. {
  1375. #if defined(JACKBRIDGE_DUMMY)
  1376. #elif defined(JACKBRIDGE_DIRECT)
  1377. return jack_remove_properties(client, subject);
  1378. #else
  1379. if (bridge.remove_properties_ptr != nullptr)
  1380. return bridge.remove_properties_ptr(client, subject);
  1381. #endif
  1382. return 0;
  1383. }
  1384. bool jackbridge_remove_all_properties(jack_client_t* client)
  1385. {
  1386. #if defined(JACKBRIDGE_DUMMY)
  1387. #elif defined(JACKBRIDGE_DIRECT)
  1388. return (jack_remove_all_properties(client) == 0);
  1389. #else
  1390. if (bridge.remove_all_properties_ptr != nullptr)
  1391. return (bridge.remove_all_properties_ptr(client) == 0);
  1392. #endif
  1393. return false;
  1394. }
  1395. bool jackbridge_set_property_change_callback(jack_client_t* client, JackPropertyChangeCallback callback, void* arg)
  1396. {
  1397. #if defined(JACKBRIDGE_DUMMY)
  1398. #elif defined(JACKBRIDGE_DIRECT)
  1399. return (jack_set_property_change_callback(client, callback, arg) == 0);
  1400. #else
  1401. if (bridge.set_property_change_callback_ptr != nullptr)
  1402. return (bridge.set_property_change_callback_ptr(client, callback, arg) == 0);
  1403. #endif
  1404. return false;
  1405. }
  1406. // -----------------------------------------------------------------------------