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.

1598 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. return jack_port_get_latency_range(port, mode, range);
  1064. #else
  1065. if (bridge.port_get_latency_range_ptr != nullptr)
  1066. return bridge.port_get_latency_range_ptr(port, mode, range);
  1067. #endif
  1068. range->min = 0;
  1069. range->max = 0;
  1070. }
  1071. void jackbridge_port_set_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range)
  1072. {
  1073. #if defined(JACKBRIDGE_DUMMY)
  1074. #elif defined(JACKBRIDGE_DIRECT)
  1075. jack_port_set_latency_range(port, mode, range);
  1076. #else
  1077. if (bridge.port_set_latency_range_ptr != nullptr)
  1078. bridge.port_set_latency_range_ptr(port, mode, range);
  1079. #endif
  1080. }
  1081. bool jackbridge_recompute_total_latencies(jack_client_t* client)
  1082. {
  1083. #if defined(JACKBRIDGE_DUMMY)
  1084. #elif defined(JACKBRIDGE_DIRECT)
  1085. return (jack_recompute_total_latencies(client) == 0);
  1086. #else
  1087. if (bridge.recompute_total_latencies_ptr != nullptr)
  1088. return (bridge.recompute_total_latencies_ptr(client) == 0);
  1089. #endif
  1090. return false;
  1091. }
  1092. // -----------------------------------------------------------------------------
  1093. const char** jackbridge_get_ports(jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
  1094. {
  1095. #if defined(JACKBRIDGE_DUMMY)
  1096. #elif defined(JACKBRIDGE_DIRECT)
  1097. return jack_get_ports(client, port_name_pattern, type_name_pattern, flags);
  1098. #else
  1099. if (bridge.get_ports_ptr != nullptr)
  1100. return bridge.get_ports_ptr(client, port_name_pattern, type_name_pattern, flags);
  1101. #endif
  1102. return nullptr;
  1103. }
  1104. jack_port_t* jackbridge_port_by_name(jack_client_t* client, const char* port_name)
  1105. {
  1106. #if defined(JACKBRIDGE_DUMMY)
  1107. #elif defined(JACKBRIDGE_DIRECT)
  1108. return jack_port_by_name(client, port_name);
  1109. #else
  1110. if (bridge.port_by_name_ptr != nullptr)
  1111. return bridge.port_by_name_ptr(client, port_name);
  1112. #endif
  1113. return nullptr;
  1114. }
  1115. jack_port_t* jackbridge_port_by_id(jack_client_t* client, jack_port_id_t port_id)
  1116. {
  1117. #if defined(JACKBRIDGE_DUMMY)
  1118. #elif defined(JACKBRIDGE_DIRECT)
  1119. return jack_port_by_id(client, port_id);
  1120. #else
  1121. if (bridge.port_by_id_ptr != nullptr)
  1122. return bridge.port_by_id_ptr(client, port_id);
  1123. #endif
  1124. return nullptr;
  1125. }
  1126. // -----------------------------------------------------------------------------
  1127. void jackbridge_free(void* ptr)
  1128. {
  1129. #if defined(JACKBRIDGE_DUMMY)
  1130. #elif defined(JACKBRIDGE_DIRECT)
  1131. return jack_free(ptr);
  1132. #else
  1133. if (bridge.free_ptr != nullptr)
  1134. return bridge.free_ptr(ptr);
  1135. // just in case
  1136. std::free(ptr);
  1137. #endif
  1138. }
  1139. // -----------------------------------------------------------------------------
  1140. uint32_t jackbridge_midi_get_event_count(void* port_buffer)
  1141. {
  1142. #if defined(JACKBRIDGE_DUMMY)
  1143. #elif defined(JACKBRIDGE_DIRECT)
  1144. return jack_midi_get_event_count(port_buffer);
  1145. #else
  1146. if (bridge.midi_get_event_count_ptr != nullptr)
  1147. return bridge.midi_get_event_count_ptr(port_buffer);
  1148. #endif
  1149. return 0;
  1150. }
  1151. bool jackbridge_midi_event_get(jack_midi_event_t* event, void* port_buffer, uint32_t event_index)
  1152. {
  1153. #if defined(JACKBRIDGE_DUMMY)
  1154. #elif defined(JACKBRIDGE_DIRECT)
  1155. return (jack_midi_event_get(event, port_buffer, event_index) == 0);
  1156. #else
  1157. if (bridge.midi_event_get_ptr != nullptr)
  1158. return (bridge.midi_event_get_ptr(event, port_buffer, event_index) == 0);
  1159. #endif
  1160. return false;
  1161. }
  1162. void jackbridge_midi_clear_buffer(void* port_buffer)
  1163. {
  1164. #if defined(JACKBRIDGE_DUMMY)
  1165. #elif defined(JACKBRIDGE_DIRECT)
  1166. jack_midi_clear_buffer(port_buffer);
  1167. #else
  1168. if (bridge.midi_clear_buffer_ptr != nullptr)
  1169. bridge.midi_clear_buffer_ptr(port_buffer);
  1170. #endif
  1171. }
  1172. bool jackbridge_midi_event_write(void* port_buffer, jack_nframes_t time, const jack_midi_data_t* data, size_t data_size)
  1173. {
  1174. #if defined(JACKBRIDGE_DUMMY)
  1175. #elif defined(JACKBRIDGE_DIRECT)
  1176. return (jack_midi_event_write(port_buffer, time, data, data_size) == 0);
  1177. #else
  1178. if (bridge.midi_event_write_ptr != nullptr)
  1179. return (bridge.midi_event_write_ptr(port_buffer, time, data, data_size) == 0);
  1180. #endif
  1181. return false;
  1182. }
  1183. jack_midi_data_t* jackbridge_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size)
  1184. {
  1185. #if defined(JACKBRIDGE_DUMMY)
  1186. #elif defined(JACKBRIDGE_DIRECT)
  1187. return jack_midi_event_reserve(port_buffer, time, data_size);
  1188. #else
  1189. if (bridge.midi_event_reserve_ptr != nullptr)
  1190. return bridge.midi_event_reserve_ptr(port_buffer, time, data_size);
  1191. #endif
  1192. return nullptr;
  1193. }
  1194. // -----------------------------------------------------------------------------
  1195. bool jackbridge_release_timebase(jack_client_t* client)
  1196. {
  1197. #if defined(JACKBRIDGE_DUMMY)
  1198. #elif defined(JACKBRIDGE_DIRECT)
  1199. return (jack_release_timebase(client) == 0);
  1200. #else
  1201. if (bridge.release_timebase_ptr != nullptr)
  1202. return (bridge.release_timebase_ptr(client) == 0);
  1203. #endif
  1204. return false;
  1205. }
  1206. bool jackbridge_set_sync_callback(jack_client_t* client, JackSyncCallback sync_callback, void* arg)
  1207. {
  1208. #if defined(JACKBRIDGE_DUMMY)
  1209. #elif defined(JACKBRIDGE_DIRECT)
  1210. return (jack_set_sync_callback(client, sync_callback, arg) == 0);
  1211. #else
  1212. if (bridge.set_sync_callback_ptr != nullptr)
  1213. return (bridge.set_sync_callback_ptr(client, sync_callback, arg) == 0);
  1214. #endif
  1215. return false;
  1216. }
  1217. bool jackbridge_set_sync_timeout(jack_client_t* client, jack_time_t timeout)
  1218. {
  1219. #if defined(JACKBRIDGE_DUMMY)
  1220. #elif defined(JACKBRIDGE_DIRECT)
  1221. return (jack_set_sync_timeout(client, timeout) == 0);
  1222. #else
  1223. if (bridge.set_sync_timeout_ptr != nullptr)
  1224. return (bridge.set_sync_timeout_ptr(client, timeout) == 0);
  1225. #endif
  1226. return false;
  1227. }
  1228. bool jackbridge_set_timebase_callback(jack_client_t* client, bool conditional, JackTimebaseCallback timebase_callback, void* arg)
  1229. {
  1230. #if defined(JACKBRIDGE_DUMMY)
  1231. #elif defined(JACKBRIDGE_DIRECT)
  1232. return (jack_set_timebase_callback(client, conditional, timebase_callback, arg) == 0);
  1233. #else
  1234. if (bridge.set_timebase_callback_ptr != nullptr)
  1235. return (bridge.set_timebase_callback_ptr(client, conditional, timebase_callback, arg) == 0);
  1236. #endif
  1237. return false;
  1238. }
  1239. bool jackbridge_transport_locate(jack_client_t* client, jack_nframes_t frame)
  1240. {
  1241. #if defined(JACKBRIDGE_DUMMY)
  1242. #elif defined(JACKBRIDGE_DIRECT)
  1243. return (jack_transport_locate(client, frame) == 0);
  1244. #else
  1245. if (bridge.transport_locate_ptr != nullptr)
  1246. return (bridge.transport_locate_ptr(client, frame) == 0);
  1247. #endif
  1248. return false;
  1249. }
  1250. jack_transport_state_t jackbridge_transport_query(const jack_client_t* client, jack_position_t* pos)
  1251. {
  1252. #if defined(JACKBRIDGE_DUMMY)
  1253. #elif defined(JACKBRIDGE_DIRECT)
  1254. return jack_transport_query(client, pos);
  1255. #else
  1256. if (bridge.transport_query_ptr != nullptr)
  1257. return bridge.transport_query_ptr(client, pos);
  1258. #endif
  1259. if (pos != nullptr)
  1260. {
  1261. // invalidate
  1262. pos->unique_1 = 0;
  1263. pos->unique_2 = 1;
  1264. }
  1265. return JackTransportStopped;
  1266. }
  1267. jack_nframes_t jackbridge_get_current_transport_frame(const jack_client_t* client)
  1268. {
  1269. #if defined(JACKBRIDGE_DUMMY)
  1270. #elif defined(JACKBRIDGE_DIRECT)
  1271. return jack_get_current_transport_frame(client);
  1272. #else
  1273. if (bridge.get_current_transport_frame_ptr != nullptr)
  1274. return bridge.get_current_transport_frame_ptr(client);
  1275. #endif
  1276. return 0;
  1277. }
  1278. bool jackbridge_transport_reposition(jack_client_t* client, const jack_position_t* pos)
  1279. {
  1280. #if defined(JACKBRIDGE_DUMMY)
  1281. #elif defined(JACKBRIDGE_DIRECT)
  1282. return (jack_transport_reposition(client, pos) == 0);
  1283. #else
  1284. if (bridge.transport_reposition_ptr != nullptr)
  1285. return (bridge.transport_reposition_ptr(client, pos) == 0);
  1286. #endif
  1287. return false;
  1288. }
  1289. void jackbridge_transport_start(jack_client_t* client)
  1290. {
  1291. #if defined(JACKBRIDGE_DUMMY)
  1292. #elif defined(JACKBRIDGE_DIRECT)
  1293. jack_transport_start(client);
  1294. #else
  1295. if (bridge.transport_start_ptr != nullptr)
  1296. bridge.transport_start_ptr(client);
  1297. #endif
  1298. }
  1299. void jackbridge_transport_stop(jack_client_t* client)
  1300. {
  1301. #if defined(JACKBRIDGE_DUMMY)
  1302. #elif defined(JACKBRIDGE_DIRECT)
  1303. jack_transport_stop(client);
  1304. #else
  1305. if (bridge.transport_stop_ptr != nullptr)
  1306. bridge.transport_stop_ptr(client);
  1307. #endif
  1308. }
  1309. // -----------------------------------------------------------------------------
  1310. bool jackbridge_set_property(jack_client_t* client, jack_uuid_t subject, const char* key, const char* value, const char* type)
  1311. {
  1312. #if defined(JACKBRIDGE_DUMMY)
  1313. #elif defined(JACKBRIDGE_DIRECT)
  1314. return (jack_set_property(client, subject, key, value, type) == 0);
  1315. #else
  1316. if (bridge.set_property_ptr != nullptr)
  1317. return (bridge.set_property_ptr(client, subject, key, value, type) == 0);
  1318. #endif
  1319. return false;
  1320. }
  1321. bool jackbridge_get_property(jack_uuid_t subject, const char* key, char** value, char** type)
  1322. {
  1323. #if defined(JACKBRIDGE_DUMMY)
  1324. #elif defined(JACKBRIDGE_DIRECT)
  1325. return (jack_get_property(subject, key, value, type) == 0);
  1326. #else
  1327. if (bridge.get_property_ptr != nullptr)
  1328. return (bridge.get_property_ptr(subject, key, value, type) == 0);
  1329. #endif
  1330. return false;
  1331. }
  1332. void jackbridge_free_description(jack_description_t* desc, bool free_description_itself)
  1333. {
  1334. #if defined(JACKBRIDGE_DUMMY)
  1335. #elif defined(JACKBRIDGE_DIRECT)
  1336. jack_free_description(desc, free_description_itself);
  1337. #else
  1338. if (bridge.free_description_ptr != nullptr)
  1339. bridge.free_description_ptr(desc, free_description_itself);
  1340. #endif
  1341. }
  1342. bool jackbridge_get_properties(jack_uuid_t subject, jack_description_t* desc)
  1343. {
  1344. #if defined(JACKBRIDGE_DUMMY)
  1345. #elif defined(JACKBRIDGE_DIRECT)
  1346. return (jack_get_properties(subject, desc) == 0);
  1347. #else
  1348. if (bridge.get_properties_ptr != nullptr)
  1349. return (bridge.get_properties_ptr(subject, desc) == 0);
  1350. #endif
  1351. return false;
  1352. }
  1353. bool jackbridge_get_all_properties(jack_description_t** descs)
  1354. {
  1355. #if defined(JACKBRIDGE_DUMMY)
  1356. #elif defined(JACKBRIDGE_DIRECT)
  1357. return (jack_get_all_properties(descs) == 0);
  1358. #else
  1359. if (bridge.get_all_properties_ptr != nullptr)
  1360. return (bridge.get_all_properties_ptr(descs) == 0);
  1361. #endif
  1362. return false;
  1363. }
  1364. bool jackbridge_remove_property(jack_client_t* client, jack_uuid_t subject, const char* key)
  1365. {
  1366. #if defined(JACKBRIDGE_DUMMY)
  1367. #elif defined(JACKBRIDGE_DIRECT)
  1368. return (jack_remove_property(client, subject, key) == 0);
  1369. #else
  1370. if (bridge.remove_property_ptr != nullptr)
  1371. return (bridge.remove_property_ptr(client, subject, key) == 0);
  1372. #endif
  1373. return false;
  1374. }
  1375. int jackbridge_remove_properties(jack_client_t* client, jack_uuid_t subject)
  1376. {
  1377. #if defined(JACKBRIDGE_DUMMY)
  1378. #elif defined(JACKBRIDGE_DIRECT)
  1379. return jack_remove_properties(client, subject);
  1380. #else
  1381. if (bridge.remove_properties_ptr != nullptr)
  1382. return bridge.remove_properties_ptr(client, subject);
  1383. #endif
  1384. return 0;
  1385. }
  1386. bool jackbridge_remove_all_properties(jack_client_t* client)
  1387. {
  1388. #if defined(JACKBRIDGE_DUMMY)
  1389. #elif defined(JACKBRIDGE_DIRECT)
  1390. return (jack_remove_all_properties(client) == 0);
  1391. #else
  1392. if (bridge.remove_all_properties_ptr != nullptr)
  1393. return (bridge.remove_all_properties_ptr(client) == 0);
  1394. #endif
  1395. return false;
  1396. }
  1397. bool jackbridge_set_property_change_callback(jack_client_t* client, JackPropertyChangeCallback callback, void* arg)
  1398. {
  1399. #if defined(JACKBRIDGE_DUMMY)
  1400. #elif defined(JACKBRIDGE_DIRECT)
  1401. return (jack_set_property_change_callback(client, callback, arg) == 0);
  1402. #else
  1403. if (bridge.set_property_change_callback_ptr != nullptr)
  1404. return (bridge.set_property_change_callback_ptr(client, callback, arg) == 0);
  1405. #endif
  1406. return false;
  1407. }
  1408. // -----------------------------------------------------------------------------