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.

JackBridge1.cpp 56KB

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