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.

257 lines
17KB

  1. /*
  2. * JackBridge (Part 3, Export)
  3. * Copyright (C) 2013-2023 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. #pragma once
  17. #include "JackBridge.hpp"
  18. extern "C" {
  19. // -----------------------------------------------------------------------------
  20. typedef void (JACKBRIDGE_API *jackbridgesym_init)(void);
  21. typedef void (JACKBRIDGE_API *jackbridgesym_get_version)(int*, int*, int*, int*);
  22. typedef const char* (JACKBRIDGE_API *jackbridgesym_get_version_string)(void);
  23. typedef jack_client_t* (JACKBRIDGE_API *jackbridgesym_client_open)(const char*, uint32_t, jack_status_t*);
  24. typedef bool (JACKBRIDGE_API *jackbridgesym_client_close)(jack_client_t*);
  25. typedef int (JACKBRIDGE_API *jackbridgesym_client_name_size)(void);
  26. typedef char* (JACKBRIDGE_API *jackbridgesym_get_client_name)(jack_client_t*);
  27. typedef char* (JACKBRIDGE_API *jackbridgesym_client_get_uuid)(jack_client_t*);
  28. typedef char* (JACKBRIDGE_API *jackbridgesym_get_uuid_for_client_name)(jack_client_t*, const char*);
  29. typedef char* (JACKBRIDGE_API *jackbridgesym_get_client_name_by_uuid)(jack_client_t*, const char*);
  30. typedef bool (JACKBRIDGE_API *jackbridgesym_uuid_parse)(const char*, jack_uuid_t*);
  31. typedef void (JACKBRIDGE_API *jackbridgesym_uuid_unparse)(jack_uuid_t, char buf[JACK_UUID_STRING_SIZE]);
  32. typedef bool (JACKBRIDGE_API *jackbridgesym_activate)(jack_client_t*);
  33. typedef bool (JACKBRIDGE_API *jackbridgesym_deactivate)(jack_client_t*);
  34. typedef bool (JACKBRIDGE_API *jackbridgesym_is_realtime)(jack_client_t*);
  35. typedef bool (JACKBRIDGE_API *jackbridgesym_set_thread_init_callback)(jack_client_t*, JackThreadInitCallback, void*);
  36. typedef void (JACKBRIDGE_API *jackbridgesym_on_shutdown)(jack_client_t*, JackShutdownCallback, void*);
  37. typedef void (JACKBRIDGE_API *jackbridgesym_on_info_shutdown)(jack_client_t*, JackInfoShutdownCallback, void*);
  38. typedef bool (JACKBRIDGE_API *jackbridgesym_set_process_callback)(jack_client_t*, JackProcessCallback, void*);
  39. typedef bool (JACKBRIDGE_API *jackbridgesym_set_freewheel_callback)(jack_client_t*, JackFreewheelCallback, void*);
  40. typedef bool (JACKBRIDGE_API *jackbridgesym_set_buffer_size_callback)(jack_client_t*, JackBufferSizeCallback, void*);
  41. typedef bool (JACKBRIDGE_API *jackbridgesym_set_sample_rate_callback)(jack_client_t*, JackSampleRateCallback, void*);
  42. typedef bool (JACKBRIDGE_API *jackbridgesym_set_client_registration_callback)(jack_client_t*, JackClientRegistrationCallback, void*);
  43. typedef bool (JACKBRIDGE_API *jackbridgesym_set_port_registration_callback)(jack_client_t*, JackPortRegistrationCallback, void*);
  44. typedef bool (JACKBRIDGE_API *jackbridgesym_set_port_rename_callback)(jack_client_t*, JackPortRenameCallback, void*);
  45. typedef bool (JACKBRIDGE_API *jackbridgesym_set_port_connect_callback)(jack_client_t*, JackPortConnectCallback, void*);
  46. typedef bool (JACKBRIDGE_API *jackbridgesym_set_graph_order_callback)(jack_client_t*, JackGraphOrderCallback, void*);
  47. typedef bool (JACKBRIDGE_API *jackbridgesym_set_xrun_callback)(jack_client_t*, JackXRunCallback, void*);
  48. typedef bool (JACKBRIDGE_API *jackbridgesym_set_latency_callback)(jack_client_t*, JackLatencyCallback, void*);
  49. typedef bool (JACKBRIDGE_API *jackbridgesym_set_freewheel)(jack_client_t*, bool);
  50. typedef bool (JACKBRIDGE_API *jackbridgesym_set_buffer_size)(jack_client_t*, jack_nframes_t);
  51. typedef jack_nframes_t (JACKBRIDGE_API *jackbridgesym_get_sample_rate)(jack_client_t*);
  52. typedef jack_nframes_t (JACKBRIDGE_API *jackbridgesym_get_buffer_size)(jack_client_t*);
  53. typedef float (JACKBRIDGE_API *jackbridgesym_cpu_load)(jack_client_t*);
  54. typedef jack_port_t* (JACKBRIDGE_API *jackbridgesym_port_register)(jack_client_t*, const char*, const char*, uint64_t, uint64_t);
  55. typedef bool (JACKBRIDGE_API *jackbridgesym_port_unregister)(jack_client_t*, jack_port_t*);
  56. typedef void* (JACKBRIDGE_API *jackbridgesym_port_get_buffer)(jack_port_t*, jack_nframes_t);
  57. typedef const char* (JACKBRIDGE_API *jackbridgesym_port_name)(const jack_port_t*);
  58. typedef jack_uuid_t (JACKBRIDGE_API *jackbridgesym_port_uuid)(const jack_port_t*);
  59. typedef const char* (JACKBRIDGE_API *jackbridgesym_port_short_name)(const jack_port_t*);
  60. typedef int (JACKBRIDGE_API *jackbridgesym_port_flags)(const jack_port_t*);
  61. typedef const char* (JACKBRIDGE_API *jackbridgesym_port_type)(const jack_port_t*);
  62. typedef bool (JACKBRIDGE_API *jackbridgesym_port_is_mine)(const jack_client_t*, const jack_port_t*);
  63. typedef int (JACKBRIDGE_API *jackbridgesym_port_connected)(const jack_port_t*);
  64. typedef bool (JACKBRIDGE_API *jackbridgesym_port_connected_to)(const jack_port_t*, const char*);
  65. typedef const char** (JACKBRIDGE_API *jackbridgesym_port_get_connections)(const jack_port_t*);
  66. typedef const char** (JACKBRIDGE_API *jackbridgesym_port_get_all_connections)(const jack_client_t*, const jack_port_t*);
  67. typedef bool (JACKBRIDGE_API *jackbridgesym_port_rename)(jack_client_t*, jack_port_t*, const char*);
  68. typedef bool (JACKBRIDGE_API *jackbridgesym_port_set_alias)(jack_port_t*, const char*);
  69. typedef bool (JACKBRIDGE_API *jackbridgesym_port_unset_alias)(jack_port_t*, const char*);
  70. typedef int (JACKBRIDGE_API *jackbridgesym_port_get_aliases)(const jack_port_t*, char* const al[2]);
  71. typedef bool (JACKBRIDGE_API *jackbridgesym_port_request_monitor)(jack_port_t*, bool);
  72. typedef bool (JACKBRIDGE_API *jackbridgesym_port_request_monitor_by_name)(jack_client_t*, const char*, bool);
  73. typedef bool (JACKBRIDGE_API *jackbridgesym_port_ensure_monitor)(jack_port_t*, bool);
  74. typedef bool (JACKBRIDGE_API *jackbridgesym_port_monitoring_input)(jack_port_t*);
  75. typedef bool (JACKBRIDGE_API *jackbridgesym_connect)(jack_client_t*, const char*, const char*);
  76. typedef bool (JACKBRIDGE_API *jackbridgesym_disconnect)(jack_client_t*, const char*, const char*);
  77. typedef bool (JACKBRIDGE_API *jackbridgesym_port_disconnect)(jack_client_t*, jack_port_t*);
  78. typedef int (JACKBRIDGE_API *jackbridgesym_port_name_size)(void);
  79. typedef int (JACKBRIDGE_API *jackbridgesym_port_type_size)(void);
  80. typedef uint32_t (JACKBRIDGE_API *jackbridgesym_port_type_get_buffer_size)(jack_client_t*, const char*);
  81. typedef void (JACKBRIDGE_API *jackbridgesym_port_get_latency_range)(jack_port_t*, uint32_t, jack_latency_range_t*);
  82. typedef void (JACKBRIDGE_API *jackbridgesym_port_set_latency_range)(jack_port_t*, uint32_t, jack_latency_range_t*);
  83. typedef bool (JACKBRIDGE_API *jackbridgesym_recompute_total_latencies)(jack_client_t*);
  84. typedef const char** (JACKBRIDGE_API *jackbridgesym_get_ports)(jack_client_t*, const char*, const char*, uint64_t);
  85. typedef jack_port_t* (JACKBRIDGE_API *jackbridgesym_port_by_name)(jack_client_t*, const char*);
  86. typedef jack_port_t* (JACKBRIDGE_API *jackbridgesym_port_by_id)(jack_client_t*, jack_port_id_t);
  87. typedef void (JACKBRIDGE_API *jackbridgesym_free)(void*);
  88. typedef uint32_t (JACKBRIDGE_API *jackbridgesym_midi_get_event_count)(void*);
  89. typedef bool (JACKBRIDGE_API *jackbridgesym_midi_event_get)(jack_midi_event_t*, void*, uint32_t);
  90. typedef void (JACKBRIDGE_API *jackbridgesym_midi_clear_buffer)(void*);
  91. typedef bool (JACKBRIDGE_API *jackbridgesym_midi_event_write)(void*, jack_nframes_t, const jack_midi_data_t*, uint32_t);
  92. typedef jack_midi_data_t* (JACKBRIDGE_API *jackbridgesym_midi_event_reserve)(void*, jack_nframes_t, uint32_t);
  93. typedef bool (JACKBRIDGE_API *jackbridgesym_release_timebase)(jack_client_t*);
  94. typedef bool (JACKBRIDGE_API *jackbridgesym_set_sync_callback)(jack_client_t*, JackSyncCallback, void*);
  95. typedef bool (JACKBRIDGE_API *jackbridgesym_set_sync_timeout)(jack_client_t*, jack_time_t);
  96. typedef bool (JACKBRIDGE_API *jackbridgesym_set_timebase_callback)(jack_client_t*, bool, JackTimebaseCallback, void*);
  97. typedef bool (JACKBRIDGE_API *jackbridgesym_transport_locate)(jack_client_t*, jack_nframes_t);
  98. typedef uint32_t (JACKBRIDGE_API *jackbridgesym_transport_query)(const jack_client_t*, jack_position_t*);
  99. typedef jack_nframes_t (JACKBRIDGE_API *jackbridgesym_get_current_transport_frame)(const jack_client_t*);
  100. typedef bool (JACKBRIDGE_API *jackbridgesym_transport_reposition)(jack_client_t*, const jack_position_t*);
  101. typedef void (JACKBRIDGE_API *jackbridgesym_transport_start)(jack_client_t*);
  102. typedef void (JACKBRIDGE_API *jackbridgesym_transport_stop)(jack_client_t*);
  103. typedef bool (JACKBRIDGE_API *jackbridgesym_set_property)(jack_client_t*, jack_uuid_t, const char*, const char*, const char*);
  104. typedef bool (JACKBRIDGE_API *jackbridgesym_get_property)(jack_uuid_t, const char*, char**, char**);
  105. typedef void (JACKBRIDGE_API *jackbridgesym_free_description)(jack_description_t*, bool);
  106. typedef bool (JACKBRIDGE_API *jackbridgesym_get_properties)(jack_uuid_t, jack_description_t*);
  107. typedef bool (JACKBRIDGE_API *jackbridgesym_get_all_properties)(jack_description_t**);
  108. typedef bool (JACKBRIDGE_API *jackbridgesym_remove_property)(jack_client_t*, jack_uuid_t, const char*);
  109. typedef int (JACKBRIDGE_API *jackbridgesym_remove_properties)(jack_client_t*, jack_uuid_t);
  110. typedef bool (JACKBRIDGE_API *jackbridgesym_remove_all_properties)(jack_client_t*);
  111. typedef bool (JACKBRIDGE_API *jackbridgesym_set_property_change_callback)(jack_client_t*, JackPropertyChangeCallback, void*);
  112. typedef bool (JACKBRIDGE_API *jackbridgesym_sem_init)(void*);
  113. typedef void (JACKBRIDGE_API *jackbridgesym_sem_destroy)(void*);
  114. typedef bool (JACKBRIDGE_API *jackbridgesym_sem_connect)(void*);
  115. typedef void (JACKBRIDGE_API *jackbridgesym_sem_post)(void*, bool);
  116. typedef bool (JACKBRIDGE_API *jackbridgesym_sem_timedwait)(void*, uint, bool);
  117. typedef bool (JACKBRIDGE_API *jackbridgesym_shm_is_valid)(const void*);
  118. typedef void (JACKBRIDGE_API *jackbridgesym_shm_init)(void*);
  119. typedef void (JACKBRIDGE_API *jackbridgesym_shm_attach)(void*, const char*);
  120. typedef void (JACKBRIDGE_API *jackbridgesym_shm_close)(void*);
  121. typedef void* (JACKBRIDGE_API *jackbridgesym_shm_map)(void*, uint64_t);
  122. typedef void (JACKBRIDGE_API *jackbridgesym_shm_unmap)(void*, void*);
  123. typedef void* (JACKBRIDGE_API *jackbridgesym_discovery_pipe_create)(const char**);
  124. typedef void (JACKBRIDGE_API *jackbridgesym_discovery_pipe_message)(void*, const char*, const char*);
  125. typedef void (JACKBRIDGE_API *jackbridgesym_discovery_pipe_destroy)(void*);
  126. typedef void (JACKBRIDGE_API *jackbridgesym_parent_deathsig)(bool);
  127. // -----------------------------------------------------------------------------
  128. struct _JackBridgeExportedFunctions {
  129. ulong unique1;
  130. jackbridgesym_init init_ptr;
  131. jackbridgesym_get_version get_version_ptr;
  132. jackbridgesym_get_version_string get_version_string_ptr;
  133. jackbridgesym_client_open client_open_ptr;
  134. jackbridgesym_client_close client_close_ptr;
  135. jackbridgesym_client_name_size client_name_size_ptr;
  136. jackbridgesym_get_client_name get_client_name_ptr;
  137. jackbridgesym_client_get_uuid client_get_uuid_ptr;
  138. jackbridgesym_get_uuid_for_client_name get_uuid_for_client_name_ptr;
  139. jackbridgesym_get_client_name_by_uuid get_client_name_by_uuid_ptr;
  140. jackbridgesym_uuid_parse uuid_parse_ptr;
  141. jackbridgesym_uuid_unparse uuid_unparse_ptr;
  142. jackbridgesym_activate activate_ptr;
  143. jackbridgesym_deactivate deactivate_ptr;
  144. jackbridgesym_is_realtime is_realtime_ptr;
  145. jackbridgesym_set_thread_init_callback set_thread_init_callback_ptr;
  146. jackbridgesym_on_shutdown on_shutdown_ptr;
  147. jackbridgesym_on_info_shutdown on_info_shutdown_ptr;
  148. jackbridgesym_set_process_callback set_process_callback_ptr;
  149. jackbridgesym_set_freewheel_callback set_freewheel_callback_ptr;
  150. jackbridgesym_set_buffer_size_callback set_buffer_size_callback_ptr;
  151. jackbridgesym_set_sample_rate_callback set_sample_rate_callback_ptr;
  152. jackbridgesym_set_client_registration_callback set_client_registration_callback_ptr;
  153. jackbridgesym_set_port_registration_callback set_port_registration_callback_ptr;
  154. jackbridgesym_set_port_rename_callback set_port_rename_callback_ptr;
  155. jackbridgesym_set_port_connect_callback set_port_connect_callback_ptr;
  156. jackbridgesym_set_graph_order_callback set_graph_order_callback_ptr;
  157. jackbridgesym_set_xrun_callback set_xrun_callback_ptr;
  158. jackbridgesym_set_latency_callback set_latency_callback_ptr;
  159. jackbridgesym_set_freewheel set_freewheel_ptr;
  160. jackbridgesym_set_buffer_size set_buffer_size_ptr;
  161. jackbridgesym_get_sample_rate get_sample_rate_ptr;
  162. jackbridgesym_get_buffer_size get_buffer_size_ptr;
  163. jackbridgesym_cpu_load cpu_load_ptr;
  164. jackbridgesym_port_register port_register_ptr;
  165. jackbridgesym_port_unregister port_unregister_ptr;
  166. jackbridgesym_port_get_buffer port_get_buffer_ptr;
  167. jackbridgesym_port_name port_name_ptr;
  168. jackbridgesym_port_uuid port_uuid_ptr;
  169. jackbridgesym_port_short_name port_short_name_ptr;
  170. jackbridgesym_port_flags port_flags_ptr;
  171. jackbridgesym_port_type port_type_ptr;
  172. jackbridgesym_port_is_mine port_is_mine_ptr;
  173. jackbridgesym_port_connected port_connected_ptr;
  174. jackbridgesym_port_connected_to port_connected_to_ptr;
  175. jackbridgesym_port_get_connections port_get_connections_ptr;
  176. jackbridgesym_port_get_all_connections port_get_all_connections_ptr;
  177. jackbridgesym_port_rename port_rename_ptr;
  178. jackbridgesym_port_set_alias port_set_alias_ptr;
  179. jackbridgesym_port_unset_alias port_unset_alias_ptr;
  180. jackbridgesym_port_get_aliases port_get_aliases_ptr;
  181. jackbridgesym_port_request_monitor port_request_monitor_ptr;
  182. jackbridgesym_port_request_monitor_by_name port_request_monitor_by_name_ptr;
  183. jackbridgesym_port_ensure_monitor port_ensure_monitor_ptr;
  184. jackbridgesym_port_monitoring_input port_monitoring_input_ptr;
  185. ulong unique2;
  186. jackbridgesym_connect connect_ptr;
  187. jackbridgesym_disconnect disconnect_ptr;
  188. jackbridgesym_port_disconnect port_disconnect_ptr;
  189. jackbridgesym_port_name_size port_name_size_ptr;
  190. jackbridgesym_port_type_size port_type_size_ptr;
  191. jackbridgesym_port_type_get_buffer_size port_type_get_buffer_size_ptr;
  192. jackbridgesym_port_get_latency_range port_get_latency_range_ptr;
  193. jackbridgesym_port_set_latency_range port_set_latency_range_ptr;
  194. jackbridgesym_recompute_total_latencies recompute_total_latencies_ptr;
  195. jackbridgesym_get_ports get_ports_ptr;
  196. jackbridgesym_port_by_name port_by_name_ptr;
  197. jackbridgesym_port_by_id port_by_id_ptr;
  198. jackbridgesym_free free_ptr;
  199. jackbridgesym_midi_get_event_count midi_get_event_count_ptr;
  200. jackbridgesym_midi_event_get midi_event_get_ptr;
  201. jackbridgesym_midi_clear_buffer midi_clear_buffer_ptr;
  202. jackbridgesym_midi_event_write midi_event_write_ptr;
  203. jackbridgesym_midi_event_reserve midi_event_reserve_ptr;
  204. jackbridgesym_release_timebase release_timebase_ptr;
  205. jackbridgesym_set_sync_callback set_sync_callback_ptr;
  206. jackbridgesym_set_sync_timeout set_sync_timeout_ptr;
  207. jackbridgesym_set_timebase_callback set_timebase_callback_ptr;
  208. jackbridgesym_transport_locate transport_locate_ptr;
  209. jackbridgesym_transport_query transport_query_ptr;
  210. jackbridgesym_get_current_transport_frame get_current_transport_frame_ptr;
  211. jackbridgesym_transport_reposition transport_reposition_ptr;
  212. jackbridgesym_transport_start transport_start_ptr;
  213. jackbridgesym_transport_stop transport_stop_ptr;
  214. jackbridgesym_set_property set_property_ptr;
  215. jackbridgesym_get_property get_property_ptr;
  216. jackbridgesym_free_description free_description_ptr;
  217. jackbridgesym_get_properties get_properties_ptr;
  218. jackbridgesym_get_all_properties get_all_properties_ptr;
  219. jackbridgesym_remove_property remove_property_ptr;
  220. jackbridgesym_remove_properties remove_properties_ptr;
  221. jackbridgesym_remove_all_properties remove_all_properties_ptr;
  222. jackbridgesym_set_property_change_callback set_property_change_callback_ptr;
  223. jackbridgesym_sem_init sem_init_ptr;
  224. jackbridgesym_sem_destroy sem_destroy_ptr;
  225. jackbridgesym_sem_connect sem_connect_ptr;
  226. jackbridgesym_sem_post sem_post_ptr;
  227. jackbridgesym_sem_timedwait sem_timedwait_ptr;
  228. jackbridgesym_shm_is_valid shm_is_valid_ptr;
  229. jackbridgesym_shm_init shm_init_ptr;
  230. jackbridgesym_shm_attach shm_attach_ptr;
  231. jackbridgesym_shm_close shm_close_ptr;
  232. jackbridgesym_shm_map shm_map_ptr;
  233. jackbridgesym_shm_unmap shm_unmap_ptr;
  234. jackbridgesym_discovery_pipe_create discovery_pipe_create_ptr;
  235. jackbridgesym_discovery_pipe_message discovery_pipe_message_ptr;
  236. jackbridgesym_discovery_pipe_destroy discovery_pipe_destroy_ptr;
  237. jackbridgesym_parent_deathsig parent_deathsig_ptr;
  238. ulong unique3;
  239. };
  240. typedef struct _JackBridgeExportedFunctions JackBridgeExportedFunctions;
  241. // -----------------------------------------------------------------------------
  242. typedef const JackBridgeExportedFunctions* (JACKBRIDGE_API *jackbridge_exported_function_type)();
  243. // -----------------------------------------------------------------------------
  244. } // extern "C"