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 71KB

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