2 * JackBridge (Part 1, JACK functions)
3 * Copyright (C) 2013-2022 Filipe Coelho <falktx@falktx.com>
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.
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.
17 #include "JackBridge.hpp"
19 #if ! (defined(JACKBRIDGE_DIRECT) || defined(JACKBRIDGE_DUMMY))
26 #if defined(CARLA_OS_WIN) && ! defined(__WINE__)
27 # define JACKSYM_API __cdecl
33 #include "CarlaLibUtils.hpp"
35 // -----------------------------------------------------------------------------
39 typedef void (JACKSYM_API
*JackSymLatencyCallback
)(jack_latency_callback_mode_t
, void*);
40 typedef int (JACKSYM_API
*JackSymProcessCallback
)(jack_nframes_t
, void*);
41 typedef void (JACKSYM_API
*JackSymThreadInitCallback
)(void*);
42 typedef int (JACKSYM_API
*JackSymGraphOrderCallback
)(void*);
43 typedef int (JACKSYM_API
*JackSymXRunCallback
)(void*);
44 typedef int (JACKSYM_API
*JackSymBufferSizeCallback
)(jack_nframes_t
, void*);
45 typedef int (JACKSYM_API
*JackSymSampleRateCallback
)(jack_nframes_t
, void*);
46 typedef void (JACKSYM_API
*JackSymPortRegistrationCallback
)(jack_port_id_t
, int, void*);
47 typedef void (JACKSYM_API
*JackSymClientRegistrationCallback
)(const char*, int, void*);
48 typedef void (JACKSYM_API
*JackSymPortConnectCallback
)(jack_port_id_t
, jack_port_id_t
, int, void*);
49 typedef void (JACKSYM_API
*JackSymPortRenameCallback
)(jack_port_id_t
, const char*, const char*, void*);
50 typedef void (JACKSYM_API
*JackSymFreewheelCallback
)(int, void*);
51 typedef void (JACKSYM_API
*JackSymShutdownCallback
)(void*);
52 typedef void (JACKSYM_API
*JackSymInfoShutdownCallback
)(jack_status_t
, const char*, void*);
53 typedef int (JACKSYM_API
*JackSymSyncCallback
)(jack_transport_state_t
, jack_position_t
*, void*);
54 typedef void (JACKSYM_API
*JackSymTimebaseCallback
)(jack_transport_state_t
, jack_nframes_t
, jack_position_t
*, int, void*);
55 typedef void (JACKSYM_API
*JackSymSessionCallback
)(jack_session_event_t
*, void*);
56 typedef void (JACKSYM_API
*JackSymPropertyChangeCallback
)(jack_uuid_t
, const char*, jack_property_change_t
, void*);
58 typedef void (JACKSYM_API
*jacksym_get_version
)(int*, int*, int*, int*);
59 typedef const char* (JACKSYM_API
*jacksym_get_version_string
)(void);
61 typedef jack_client_t
* (JACKSYM_API
*jacksym_client_open
)(const char*, jack_options_t
, jack_status_t
*, ...);
62 typedef int (JACKSYM_API
*jacksym_client_close
)(jack_client_t
*);
64 typedef int (JACKSYM_API
*jacksym_client_name_size
)(void);
65 typedef char* (JACKSYM_API
*jacksym_get_client_name
)(jack_client_t
*);
67 typedef char* (JACKSYM_API
*jacksym_client_get_uuid
)(jack_client_t
*);
68 typedef char* (JACKSYM_API
*jacksym_get_uuid_for_client_name
)(jack_client_t
*, const char*);
69 typedef char* (JACKSYM_API
*jacksym_get_client_name_by_uuid
)(jack_client_t
*, const char*);
71 typedef int (JACKBRIDGE_API
*jacksym_uuid_parse
)(const char*, jack_uuid_t
*);
72 typedef void (JACKBRIDGE_API
*jacksym_uuid_unparse
)(jack_uuid_t
, char buf
[JACK_UUID_STRING_SIZE
]);
74 typedef int (JACKSYM_API
*jacksym_activate
)(jack_client_t
*);
75 typedef int (JACKSYM_API
*jacksym_deactivate
)(jack_client_t
*);
76 typedef int (JACKSYM_API
*jacksym_is_realtime
)(jack_client_t
*);
78 typedef int (JACKSYM_API
*jacksym_set_thread_init_callback
)(jack_client_t
*, JackSymThreadInitCallback
, void*);
79 typedef void (JACKSYM_API
*jacksym_on_shutdown
)(jack_client_t
*, JackSymShutdownCallback
, void*);
80 typedef void (JACKSYM_API
*jacksym_on_info_shutdown
)(jack_client_t
*, JackSymInfoShutdownCallback
, void*);
81 typedef int (JACKSYM_API
*jacksym_set_process_callback
)(jack_client_t
*, JackSymProcessCallback
, void*);
82 typedef int (JACKSYM_API
*jacksym_set_freewheel_callback
)(jack_client_t
*, JackSymFreewheelCallback
, void*);
83 typedef int (JACKSYM_API
*jacksym_set_buffer_size_callback
)(jack_client_t
*, JackSymBufferSizeCallback
, void*);
84 typedef int (JACKSYM_API
*jacksym_set_sample_rate_callback
)(jack_client_t
*, JackSymSampleRateCallback
, void*);
85 typedef int (JACKSYM_API
*jacksym_set_client_registration_callback
)(jack_client_t
*, JackSymClientRegistrationCallback
, void*);
86 typedef int (JACKSYM_API
*jacksym_set_port_registration_callback
)(jack_client_t
*, JackSymPortRegistrationCallback
, void*);
87 typedef int (JACKSYM_API
*jacksym_set_port_rename_callback
)(jack_client_t
*, JackSymPortRenameCallback
, void*);
88 typedef int (JACKSYM_API
*jacksym_set_port_connect_callback
)(jack_client_t
*, JackSymPortConnectCallback
, void*);
89 typedef int (JACKSYM_API
*jacksym_set_graph_order_callback
)(jack_client_t
*, JackSymGraphOrderCallback
, void*);
90 typedef int (JACKSYM_API
*jacksym_set_xrun_callback
)(jack_client_t
*, JackSymXRunCallback
, void*);
91 typedef int (JACKSYM_API
*jacksym_set_latency_callback
)(jack_client_t
*, JackSymLatencyCallback
, void*);
93 typedef int (JACKSYM_API
*jacksym_set_freewheel
)(jack_client_t
*, int);
94 typedef int (JACKSYM_API
*jacksym_set_buffer_size
)(jack_client_t
*, jack_nframes_t
);
96 typedef jack_nframes_t (JACKSYM_API
*jacksym_get_sample_rate
)(jack_client_t
*);
97 typedef jack_nframes_t (JACKSYM_API
*jacksym_get_buffer_size
)(jack_client_t
*);
98 typedef float (JACKSYM_API
*jacksym_cpu_load
)(jack_client_t
*);
100 typedef jack_port_t
* (JACKSYM_API
*jacksym_port_register
)(jack_client_t
*, const char*, const char*, ulong
, ulong
);
101 typedef int (JACKSYM_API
*jacksym_port_unregister
)(jack_client_t
*, jack_port_t
*);
102 typedef void* (JACKSYM_API
*jacksym_port_get_buffer
)(jack_port_t
*, jack_nframes_t
);
104 typedef const char* (JACKSYM_API
*jacksym_port_name
)(const jack_port_t
*);
105 typedef jack_uuid_t (JACKSYM_API
*jacksym_port_uuid
)(const jack_port_t
*);
106 typedef const char* (JACKSYM_API
*jacksym_port_short_name
)(const jack_port_t
*);
107 typedef int (JACKSYM_API
*jacksym_port_flags
)(const jack_port_t
*);
108 typedef const char* (JACKSYM_API
*jacksym_port_type
)(const jack_port_t
*);
109 typedef int (JACKSYM_API
*jacksym_port_is_mine
)(const jack_client_t
*, const jack_port_t
*);
110 typedef int (JACKSYM_API
*jacksym_port_connected
)(const jack_port_t
*);
111 typedef int (JACKSYM_API
*jacksym_port_connected_to
)(const jack_port_t
*, const char*);
112 typedef const char** (JACKSYM_API
*jacksym_port_get_connections
)(const jack_port_t
*);
113 typedef const char** (JACKSYM_API
*jacksym_port_get_all_connections
)(const jack_client_t
*, const jack_port_t
*);
115 typedef int (JACKSYM_API
*jacksym_port_rename
)(jack_client_t
*, jack_port_t
*, const char*);
116 typedef int (JACKSYM_API
*jacksym_port_set_name
)(jack_port_t
*, const char*);
117 typedef int (JACKSYM_API
*jacksym_port_set_alias
)(jack_port_t
*, const char*);
118 typedef int (JACKSYM_API
*jacksym_port_unset_alias
)(jack_port_t
*, const char*);
119 typedef int (JACKSYM_API
*jacksym_port_get_aliases
)(const jack_port_t
*, char* const aliases
[2]);
121 typedef int (JACKSYM_API
*jacksym_port_request_monitor
)(jack_port_t
*, int);
122 typedef int (JACKSYM_API
*jacksym_port_request_monitor_by_name
)(jack_client_t
*, const char*, int);
123 typedef int (JACKSYM_API
*jacksym_port_ensure_monitor
)(jack_port_t
*, int);
124 typedef int (JACKSYM_API
*jacksym_port_monitoring_input
)(jack_port_t
*);
126 typedef int (JACKSYM_API
*jacksym_connect
)(jack_client_t
*, const char*, const char*);
127 typedef int (JACKSYM_API
*jacksym_disconnect
)(jack_client_t
*, const char*, const char*);
128 typedef int (JACKSYM_API
*jacksym_port_disconnect
)(jack_client_t
*, jack_port_t
*);
130 typedef int (JACKSYM_API
*jacksym_port_name_size
)(void);
131 typedef int (JACKSYM_API
*jacksym_port_type_size
)(void);
132 typedef size_t (JACKSYM_API
*jacksym_port_type_get_buffer_size
)(jack_client_t
*, const char*);
134 typedef void (JACKSYM_API
*jacksym_port_get_latency_range
)(jack_port_t
*, jack_latency_callback_mode_t
, jack_latency_range_t
*);
135 typedef void (JACKSYM_API
*jacksym_port_set_latency_range
)(jack_port_t
*, jack_latency_callback_mode_t
, jack_latency_range_t
*);
136 typedef int (JACKSYM_API
*jacksym_recompute_total_latencies
)(jack_client_t
*);
138 typedef const char** (JACKSYM_API
*jacksym_get_ports
)(jack_client_t
*, const char*, const char*, ulong
);
139 typedef jack_port_t
* (JACKSYM_API
*jacksym_port_by_name
)(jack_client_t
*, const char*);
140 typedef jack_port_t
* (JACKSYM_API
*jacksym_port_by_id
)(jack_client_t
*, jack_port_id_t
);
142 typedef void (JACKSYM_API
*jacksym_free
)(void*);
144 typedef uint32_t (JACKSYM_API
*jacksym_midi_get_event_count
)(void*);
145 typedef int (JACKSYM_API
*jacksym_midi_event_get
)(jack_midi_event_t
*, void*, uint32_t);
146 typedef void (JACKSYM_API
*jacksym_midi_clear_buffer
)(void*);
147 typedef int (JACKSYM_API
*jacksym_midi_event_write
)(void*, jack_nframes_t
, const jack_midi_data_t
*, size_t);
148 typedef jack_midi_data_t
* (JACKSYM_API
*jacksym_midi_event_reserve
)(void*, jack_nframes_t
, size_t);
150 typedef int (JACKSYM_API
*jacksym_release_timebase
)(jack_client_t
*);
151 typedef int (JACKSYM_API
*jacksym_set_sync_callback
)(jack_client_t
*, JackSymSyncCallback
, void*);
152 typedef int (JACKSYM_API
*jacksym_set_sync_timeout
)(jack_client_t
*, jack_time_t
);
153 typedef int (JACKSYM_API
*jacksym_set_timebase_callback
)(jack_client_t
*, int, JackSymTimebaseCallback
, void*);
154 typedef int (JACKSYM_API
*jacksym_transport_locate
)(jack_client_t
*, jack_nframes_t
);
156 typedef jack_transport_state_t (JACKSYM_API
*jacksym_transport_query
)(const jack_client_t
*, jack_position_t
*);
157 typedef jack_nframes_t (JACKSYM_API
*jacksym_get_current_transport_frame
)(const jack_client_t
*);
159 typedef int (JACKSYM_API
*jacksym_transport_reposition
)(jack_client_t
*, const jack_position_t
*);
160 typedef void (JACKSYM_API
*jacksym_transport_start
)(jack_client_t
*);
161 typedef void (JACKSYM_API
*jacksym_transport_stop
)(jack_client_t
*);
163 typedef int (JACKSYM_API
*jacksym_set_property
)(jack_client_t
*, jack_uuid_t
, const char*, const char*, const char*);
164 typedef int (JACKSYM_API
*jacksym_get_property
)(jack_uuid_t
, const char*, char**, char**);
165 typedef void (JACKSYM_API
*jacksym_free_description
)(jack_description_t
*, int);
166 typedef int (JACKSYM_API
*jacksym_get_properties
)(jack_uuid_t
, jack_description_t
*);
167 typedef int (JACKSYM_API
*jacksym_get_all_properties
)(jack_description_t
**);
168 typedef int (JACKSYM_API
*jacksym_remove_property
)(jack_client_t
*, jack_uuid_t
, const char*);
169 typedef int (JACKSYM_API
*jacksym_remove_properties
)(jack_client_t
*, jack_uuid_t
);
170 typedef int (JACKSYM_API
*jacksym_remove_all_properties
)(jack_client_t
*);
171 typedef int (JACKSYM_API
*jacksym_set_property_change_callback
)(jack_client_t
*, JackSymPropertyChangeCallback
, void*);
174 typedef int (JACKSYM_API
*jacksym_thread_creator_t
)(pthread_t
*, const pthread_attr_t
*, void *(*)(void*), void*);
175 typedef void (JACKSYM_API
*jacksym_set_thread_creator
)(jacksym_thread_creator_t
);
180 // -----------------------------------------------------------------------------
185 jacksym_get_version get_version_ptr
;
186 jacksym_get_version_string get_version_string_ptr
;
188 jacksym_client_open client_open_ptr
;
189 jacksym_client_close client_close_ptr
;
191 jacksym_client_name_size client_name_size_ptr
;
192 jacksym_get_client_name get_client_name_ptr
;
194 jacksym_client_get_uuid client_get_uuid_ptr
;
195 jacksym_get_uuid_for_client_name get_uuid_for_client_name_ptr
;
196 jacksym_get_client_name_by_uuid get_client_name_by_uuid_ptr
;
198 jacksym_uuid_parse uuid_parse_ptr
;
199 jacksym_uuid_unparse uuid_unparse_ptr
;
201 jacksym_activate activate_ptr
;
202 jacksym_deactivate deactivate_ptr
;
203 jacksym_is_realtime is_realtime_ptr
;
205 jacksym_set_thread_init_callback set_thread_init_callback_ptr
;
206 jacksym_on_shutdown on_shutdown_ptr
;
207 jacksym_on_info_shutdown on_info_shutdown_ptr
;
208 jacksym_set_process_callback set_process_callback_ptr
;
209 jacksym_set_freewheel_callback set_freewheel_callback_ptr
;
210 jacksym_set_buffer_size_callback set_buffer_size_callback_ptr
;
211 jacksym_set_sample_rate_callback set_sample_rate_callback_ptr
;
212 jacksym_set_client_registration_callback set_client_registration_callback_ptr
;
213 jacksym_set_port_registration_callback set_port_registration_callback_ptr
;
214 jacksym_set_port_rename_callback set_port_rename_callback_ptr
;
215 jacksym_set_port_connect_callback set_port_connect_callback_ptr
;
216 jacksym_set_graph_order_callback set_graph_order_callback_ptr
;
217 jacksym_set_xrun_callback set_xrun_callback_ptr
;
218 jacksym_set_latency_callback set_latency_callback_ptr
;
220 jacksym_set_freewheel set_freewheel_ptr
;
221 jacksym_set_buffer_size set_buffer_size_ptr
;
223 jacksym_get_sample_rate get_sample_rate_ptr
;
224 jacksym_get_buffer_size get_buffer_size_ptr
;
225 jacksym_cpu_load cpu_load_ptr
;
227 jacksym_port_register port_register_ptr
;
228 jacksym_port_unregister port_unregister_ptr
;
229 jacksym_port_get_buffer port_get_buffer_ptr
;
231 jacksym_port_name port_name_ptr
;
232 jacksym_port_uuid port_uuid_ptr
;
233 jacksym_port_short_name port_short_name_ptr
;
234 jacksym_port_flags port_flags_ptr
;
235 jacksym_port_type port_type_ptr
;
236 jacksym_port_is_mine port_is_mine_ptr
;
237 jacksym_port_connected port_connected_ptr
;
238 jacksym_port_connected_to port_connected_to_ptr
;
239 jacksym_port_get_connections port_get_connections_ptr
;
240 jacksym_port_get_all_connections port_get_all_connections_ptr
;
242 jacksym_port_rename port_rename_ptr
;
243 jacksym_port_set_name port_set_name_ptr
;
244 jacksym_port_set_alias port_set_alias_ptr
;
245 jacksym_port_unset_alias port_unset_alias_ptr
;
246 jacksym_port_get_aliases port_get_aliases_ptr
;
248 jacksym_port_request_monitor port_request_monitor_ptr
;
249 jacksym_port_request_monitor_by_name port_request_monitor_by_name_ptr
;
250 jacksym_port_ensure_monitor port_ensure_monitor_ptr
;
251 jacksym_port_monitoring_input port_monitoring_input_ptr
;
253 jacksym_connect connect_ptr
;
254 jacksym_disconnect disconnect_ptr
;
255 jacksym_port_disconnect port_disconnect_ptr
;
257 jacksym_port_name_size port_name_size_ptr
;
258 jacksym_port_type_size port_type_size_ptr
;
259 jacksym_port_type_get_buffer_size port_type_get_buffer_size_ptr
;
261 jacksym_port_get_latency_range port_get_latency_range_ptr
;
262 jacksym_port_set_latency_range port_set_latency_range_ptr
;
263 jacksym_recompute_total_latencies recompute_total_latencies_ptr
;
265 jacksym_get_ports get_ports_ptr
;
266 jacksym_port_by_name port_by_name_ptr
;
267 jacksym_port_by_id port_by_id_ptr
;
269 jacksym_free free_ptr
;
271 jacksym_midi_get_event_count midi_get_event_count_ptr
;
272 jacksym_midi_event_get midi_event_get_ptr
;
273 jacksym_midi_clear_buffer midi_clear_buffer_ptr
;
274 jacksym_midi_event_write midi_event_write_ptr
;
275 jacksym_midi_event_reserve midi_event_reserve_ptr
;
277 jacksym_release_timebase release_timebase_ptr
;
278 jacksym_set_sync_callback set_sync_callback_ptr
;
279 jacksym_set_sync_timeout set_sync_timeout_ptr
;
280 jacksym_set_timebase_callback set_timebase_callback_ptr
;
281 jacksym_transport_locate transport_locate_ptr
;
283 jacksym_transport_query transport_query_ptr
;
284 jacksym_get_current_transport_frame get_current_transport_frame_ptr
;
286 jacksym_transport_reposition transport_reposition_ptr
;
287 jacksym_transport_start transport_start_ptr
;
288 jacksym_transport_stop transport_stop_ptr
;
290 jacksym_set_property set_property_ptr
;
291 jacksym_get_property get_property_ptr
;
292 jacksym_free_description free_description_ptr
;
293 jacksym_get_properties get_properties_ptr
;
294 jacksym_get_all_properties get_all_properties_ptr
;
295 jacksym_remove_property remove_property_ptr
;
296 jacksym_remove_properties remove_properties_ptr
;
297 jacksym_remove_all_properties remove_all_properties_ptr
;
298 jacksym_set_property_change_callback set_property_change_callback_ptr
;
301 jacksym_set_thread_creator set_thread_creator_ptr
;
306 get_version_ptr(nullptr),
307 get_version_string_ptr(nullptr),
308 client_open_ptr(nullptr),
309 client_close_ptr(nullptr),
310 client_name_size_ptr(nullptr),
311 get_client_name_ptr(nullptr),
312 client_get_uuid_ptr(nullptr),
313 get_uuid_for_client_name_ptr(nullptr),
314 get_client_name_by_uuid_ptr(nullptr),
315 uuid_parse_ptr(nullptr),
316 uuid_unparse_ptr(nullptr),
317 activate_ptr(nullptr),
318 deactivate_ptr(nullptr),
319 is_realtime_ptr(nullptr),
320 set_thread_init_callback_ptr(nullptr),
321 on_shutdown_ptr(nullptr),
322 on_info_shutdown_ptr(nullptr),
323 set_process_callback_ptr(nullptr),
324 set_freewheel_callback_ptr(nullptr),
325 set_buffer_size_callback_ptr(nullptr),
326 set_sample_rate_callback_ptr(nullptr),
327 set_client_registration_callback_ptr(nullptr),
328 set_port_registration_callback_ptr(nullptr),
329 set_port_rename_callback_ptr(nullptr),
330 set_port_connect_callback_ptr(nullptr),
331 set_graph_order_callback_ptr(nullptr),
332 set_xrun_callback_ptr(nullptr),
333 set_latency_callback_ptr(nullptr),
334 set_freewheel_ptr(nullptr),
335 set_buffer_size_ptr(nullptr),
336 get_sample_rate_ptr(nullptr),
337 get_buffer_size_ptr(nullptr),
338 cpu_load_ptr(nullptr),
339 port_register_ptr(nullptr),
340 port_unregister_ptr(nullptr),
341 port_get_buffer_ptr(nullptr),
342 port_name_ptr(nullptr),
343 port_uuid_ptr(nullptr),
344 port_short_name_ptr(nullptr),
345 port_flags_ptr(nullptr),
346 port_type_ptr(nullptr),
347 port_is_mine_ptr(nullptr),
348 port_connected_ptr(nullptr),
349 port_connected_to_ptr(nullptr),
350 port_get_connections_ptr(nullptr),
351 port_get_all_connections_ptr(nullptr),
352 port_rename_ptr(nullptr),
353 port_set_name_ptr(nullptr),
354 port_set_alias_ptr(nullptr),
355 port_unset_alias_ptr(nullptr),
356 port_get_aliases_ptr(nullptr),
357 port_request_monitor_ptr(nullptr),
358 port_request_monitor_by_name_ptr(nullptr),
359 port_ensure_monitor_ptr(nullptr),
360 port_monitoring_input_ptr(nullptr),
361 connect_ptr(nullptr),
362 disconnect_ptr(nullptr),
363 port_disconnect_ptr(nullptr),
364 port_name_size_ptr(nullptr),
365 port_type_size_ptr(nullptr),
366 port_type_get_buffer_size_ptr(nullptr),
367 port_get_latency_range_ptr(nullptr),
368 port_set_latency_range_ptr(nullptr),
369 recompute_total_latencies_ptr(nullptr),
370 get_ports_ptr(nullptr),
371 port_by_name_ptr(nullptr),
372 port_by_id_ptr(nullptr),
374 midi_get_event_count_ptr(nullptr),
375 midi_event_get_ptr(nullptr),
376 midi_clear_buffer_ptr(nullptr),
377 midi_event_write_ptr(nullptr),
378 midi_event_reserve_ptr(nullptr),
379 release_timebase_ptr(nullptr),
380 set_sync_callback_ptr(nullptr),
381 set_sync_timeout_ptr(nullptr),
382 set_timebase_callback_ptr(nullptr),
383 transport_locate_ptr(nullptr),
384 transport_query_ptr(nullptr),
385 get_current_transport_frame_ptr(nullptr),
386 transport_reposition_ptr(nullptr),
387 transport_start_ptr(nullptr),
388 transport_stop_ptr(nullptr),
389 set_property_ptr(nullptr),
390 get_property_ptr(nullptr),
391 free_description_ptr(nullptr),
392 get_properties_ptr(nullptr),
393 get_all_properties_ptr(nullptr),
394 remove_property_ptr(nullptr),
395 remove_properties_ptr(nullptr),
396 remove_all_properties_ptr(nullptr),
397 set_property_change_callback_ptr(nullptr)
399 , set_thread_creator_ptr(nullptr)
402 # if defined(CARLA_OS_MAC)
403 const char* const filename("libjack.dylib");
404 # elif defined(CARLA_OS_WIN64)
405 const char* const filename("libjack64.dll");
406 # elif defined(CARLA_OS_WIN)
407 const char* const filename("libjack.dll");
409 const char* const filename("libjack.so.0");
412 lib
= lib_open(filename
);
416 fprintf(stderr
, "Failed to load JACK DLL, reason:\n%s\n", lib_error(filename
));
421 fprintf(stdout
, "%s loaded successfully!\n", filename
);
424 #define JOIN(a, b) a ## b
425 #define LIB_SYMBOL(NAME) JOIN(NAME, _ptr) = lib_symbol<jacksym_##NAME>(lib, "jack_" #NAME);
427 LIB_SYMBOL(get_version
)
428 LIB_SYMBOL(get_version_string
)
430 LIB_SYMBOL(client_open
)
431 LIB_SYMBOL(client_close
)
433 LIB_SYMBOL(client_name_size
)
434 LIB_SYMBOL(get_client_name
)
436 LIB_SYMBOL(client_get_uuid
)
437 LIB_SYMBOL(get_uuid_for_client_name
)
438 LIB_SYMBOL(get_client_name_by_uuid
)
440 LIB_SYMBOL(uuid_parse
)
441 LIB_SYMBOL(uuid_unparse
)
444 LIB_SYMBOL(deactivate
)
445 LIB_SYMBOL(is_realtime
)
447 LIB_SYMBOL(set_thread_init_callback
)
448 LIB_SYMBOL(on_shutdown
)
449 LIB_SYMBOL(on_info_shutdown
)
450 LIB_SYMBOL(set_process_callback
)
451 LIB_SYMBOL(set_freewheel_callback
)
452 LIB_SYMBOL(set_buffer_size_callback
)
453 LIB_SYMBOL(set_sample_rate_callback
)
454 LIB_SYMBOL(set_client_registration_callback
)
455 LIB_SYMBOL(set_port_registration_callback
)
456 LIB_SYMBOL(set_port_rename_callback
)
457 LIB_SYMBOL(set_port_connect_callback
)
458 LIB_SYMBOL(set_graph_order_callback
)
459 LIB_SYMBOL(set_xrun_callback
)
460 LIB_SYMBOL(set_latency_callback
)
462 LIB_SYMBOL(set_freewheel
)
463 LIB_SYMBOL(set_buffer_size
)
465 LIB_SYMBOL(get_sample_rate
)
466 LIB_SYMBOL(get_buffer_size
)
469 LIB_SYMBOL(port_register
)
470 LIB_SYMBOL(port_unregister
)
471 LIB_SYMBOL(port_get_buffer
)
473 LIB_SYMBOL(port_name
)
474 LIB_SYMBOL(port_uuid
)
475 LIB_SYMBOL(port_short_name
)
476 LIB_SYMBOL(port_flags
)
477 LIB_SYMBOL(port_type
)
478 LIB_SYMBOL(port_is_mine
)
479 LIB_SYMBOL(port_connected
)
480 LIB_SYMBOL(port_connected_to
)
481 LIB_SYMBOL(port_get_connections
)
482 LIB_SYMBOL(port_get_all_connections
)
484 LIB_SYMBOL(port_rename
)
485 LIB_SYMBOL(port_set_name
)
486 LIB_SYMBOL(port_set_alias
)
487 LIB_SYMBOL(port_unset_alias
)
488 LIB_SYMBOL(port_get_aliases
)
490 LIB_SYMBOL(port_request_monitor
)
491 LIB_SYMBOL(port_request_monitor_by_name
)
492 LIB_SYMBOL(port_ensure_monitor
)
493 LIB_SYMBOL(port_monitoring_input
)
496 LIB_SYMBOL(disconnect
)
497 LIB_SYMBOL(port_disconnect
)
499 LIB_SYMBOL(port_name_size
)
500 LIB_SYMBOL(port_type_size
)
501 LIB_SYMBOL(port_type_get_buffer_size
)
503 LIB_SYMBOL(port_get_latency_range
)
504 LIB_SYMBOL(port_set_latency_range
)
505 LIB_SYMBOL(recompute_total_latencies
)
507 LIB_SYMBOL(get_ports
)
508 LIB_SYMBOL(port_by_name
)
509 LIB_SYMBOL(port_by_id
)
513 LIB_SYMBOL(midi_get_event_count
)
514 LIB_SYMBOL(midi_event_get
)
515 LIB_SYMBOL(midi_clear_buffer
)
516 LIB_SYMBOL(midi_event_write
)
517 LIB_SYMBOL(midi_event_reserve
)
519 LIB_SYMBOL(release_timebase
)
520 LIB_SYMBOL(set_sync_callback
)
521 LIB_SYMBOL(set_sync_timeout
)
522 LIB_SYMBOL(set_timebase_callback
)
523 LIB_SYMBOL(transport_locate
)
524 LIB_SYMBOL(transport_query
)
525 LIB_SYMBOL(get_current_transport_frame
)
526 LIB_SYMBOL(transport_reposition
)
527 LIB_SYMBOL(transport_start
)
528 LIB_SYMBOL(transport_stop
)
530 LIB_SYMBOL(set_property
)
531 LIB_SYMBOL(get_property
)
532 LIB_SYMBOL(free_description
)
533 LIB_SYMBOL(get_properties
)
534 LIB_SYMBOL(get_all_properties
)
535 LIB_SYMBOL(remove_property
)
536 LIB_SYMBOL(remove_properties
)
537 LIB_SYMBOL(remove_all_properties
)
538 LIB_SYMBOL(set_property_change_callback
)
541 LIB_SYMBOL(set_thread_creator
)
548 ~JackBridge() noexcept
557 CARLA_DECLARE_NON_COPYABLE(JackBridge
);
560 // -----------------------------------------------------------------------------
562 static const JackBridge
& getBridgeInstance() noexcept
564 static const JackBridge bridge
;
568 #endif // ! (defined(JACKBRIDGE_DIRECT) || defined(JACKBRIDGE_DUMMY))
570 // -----------------------------------------------------------------------------
572 #if defined(__WINE__) && ! defined(JACKBRIDGE_DIRECT)
576 JackLatencyCallback latency_cb
;
577 JackProcessCallback process_cb
;
578 JackThreadInitCallback thread_init_cb
;
579 JackGraphOrderCallback graph_order_cb
;
580 JackXRunCallback xrun_cb
;
581 JackBufferSizeCallback bufsize_cb
;
582 JackSampleRateCallback srate_cb
;
583 JackPortRegistrationCallback port_reg_cb
;
584 JackClientRegistrationCallback client_reg_cb
;
585 JackPortConnectCallback port_conn_cb
;
586 JackPortRenameCallback port_rename_cb
;
587 JackFreewheelCallback freewheel_cb
;
588 JackShutdownCallback shutdown_cb
;
589 JackInfoShutdownCallback info_shutdown_cb
;
590 JackSyncCallback sync_cb
;
591 JackTimebaseCallback timebase_cb
;
592 JackSessionCallback session_cb
;
593 JackPropertyChangeCallback prop_change_cb
;
595 void* (*creator_func
)(void*);
597 HANDLE creator_handle
;
598 pthread_t creator_pthread
;
600 WineBridge() noexcept
604 thread_init_cb(nullptr),
605 graph_order_cb(nullptr),
609 port_reg_cb(nullptr),
610 client_reg_cb(nullptr),
611 port_conn_cb(nullptr),
612 port_rename_cb(nullptr),
613 freewheel_cb(nullptr),
614 shutdown_cb(nullptr),
615 info_shutdown_cb(nullptr),
617 timebase_cb(nullptr),
619 prop_change_cb(nullptr),
620 creator_func(nullptr),
621 creator_arg(nullptr),
622 creator_handle(nullptr),
623 creator_pthread(0) {}
625 static WineBridge
& getInstance() noexcept
627 static WineBridge bridge
;
631 void set_latency (JackLatencyCallback cb
) noexcept
{ latency_cb
= cb
; }
632 void set_process (JackProcessCallback cb
) noexcept
{ process_cb
= cb
; }
633 void set_thread_init (JackThreadInitCallback cb
) noexcept
{ thread_init_cb
= cb
; }
634 void set_graph_order (JackGraphOrderCallback cb
) noexcept
{ graph_order_cb
= cb
; }
635 void set_xrun (JackXRunCallback cb
) noexcept
{ xrun_cb
= cb
; }
636 void set_bufsize (JackBufferSizeCallback cb
) noexcept
{ bufsize_cb
= cb
; }
637 void set_srate (JackSampleRateCallback cb
) noexcept
{ srate_cb
= cb
; }
638 void set_port_reg (JackPortRegistrationCallback cb
) noexcept
{ port_reg_cb
= cb
; }
639 void set_client_reg (JackClientRegistrationCallback cb
) noexcept
{ client_reg_cb
= cb
; }
640 void set_port_conn (JackPortConnectCallback cb
) noexcept
{ port_conn_cb
= cb
; }
641 void set_port_rename (JackPortRenameCallback cb
) noexcept
{ port_rename_cb
= cb
; }
642 void set_freewheel (JackFreewheelCallback cb
) noexcept
{ freewheel_cb
= cb
; }
643 void set_shutdown (JackShutdownCallback cb
) noexcept
{ shutdown_cb
= cb
; }
644 void set_info_shutdown(JackInfoShutdownCallback cb
) noexcept
{ info_shutdown_cb
= cb
; }
645 void set_sync (JackSyncCallback cb
) noexcept
{ sync_cb
= cb
; }
646 void set_timebase (JackTimebaseCallback cb
) noexcept
{ timebase_cb
= cb
; }
647 void set_session (JackSessionCallback cb
) noexcept
{ session_cb
= cb
; }
648 void set_prop_change (JackPropertyChangeCallback cb
) noexcept
{ prop_change_cb
= cb
; }
650 static DWORD WINAPI
thread_creator_helper(LPVOID
)
652 WineBridge
& inst(getInstance());
654 inst
.creator_pthread
= pthread_self();
655 SetEvent(inst
.creator_handle
);
656 inst
.creator_func(inst
.creator_arg
);
660 static int thread_creator(pthread_t
* thread_id
, const pthread_attr_t
*, void *(*function
)(void*), void* arg
)
662 WineBridge
& inst(getInstance());
664 inst
.creator_func
= function
;
665 inst
.creator_arg
= arg
;
666 inst
.creator_handle
= ::CreateEventW(nullptr, false, false, nullptr);
669 ::CreateThread(nullptr, 0, thread_creator_helper
, arg
, 0, nullptr);
671 HANDLE handle
= ::CreateThread(nullptr, 0, thread_creator_helper
, arg
, CREATE_SUSPENDED
, nullptr);
673 if (handle
== INVALID_HANDLE_VALUE
)
676 // TODO read attrs and decide this
677 ::SetThreadPriority(handle
, THREAD_PRIORITY_TIME_CRITICAL
);
678 ::ResumeThread(handle
);
681 ::WaitForSingleObject(inst
.creator_handle
, INFINITE
);
682 *thread_id
= inst
.creator_pthread
;
686 static void latency(jack_latency_callback_mode_t mode
, void* arg
)
688 return getInstance().latency_cb(mode
, arg
);
691 static int process(jack_nframes_t nframes
, void* arg
)
693 return getInstance().process_cb(nframes
, arg
);
696 static void thread_init(void* arg
)
698 return getInstance().thread_init_cb(arg
);
701 static int graph_order(void* arg
)
703 return getInstance().graph_order_cb(arg
);
706 static int xrun(void* arg
)
708 return getInstance().xrun_cb(arg
);
711 static int bufsize(jack_nframes_t nframes
, void* arg
)
713 return getInstance().bufsize_cb(nframes
, arg
);
716 static int srate(jack_nframes_t nframes
, void* arg
)
718 return getInstance().srate_cb(nframes
, arg
);
721 static void port_reg(jack_port_id_t port
, int register_
, void* arg
)
723 return getInstance().port_reg_cb(port
, register_
, arg
);
726 static void client_reg(const char* name
, int register_
, void* arg
)
728 return getInstance().client_reg_cb(name
, register_
, arg
);
731 static void port_conn(jack_port_id_t a
, jack_port_id_t b
, int connect
, void* arg
)
733 return getInstance().port_conn_cb(a
, b
, connect
, arg
);
736 static void port_rename(jack_port_id_t port
, const char* old_name
, const char* new_name
, void* arg
)
738 getInstance().port_rename_cb(port
, old_name
, new_name
, arg
);
741 static void freewheel(int starting
, void* arg
)
743 return getInstance().freewheel_cb(starting
, arg
);
746 static void shutdown(void* arg
)
748 return getInstance().shutdown_cb(arg
);
751 static void info_shutdown(jack_status_t code
, const char* reason
, void* arg
)
753 return getInstance().info_shutdown_cb(code
, reason
, arg
);
756 static int sync(jack_transport_state_t state
, jack_position_t
* pos
, void* arg
)
758 return getInstance().sync_cb(state
, pos
, arg
);
761 static void timebase(jack_transport_state_t state
, jack_nframes_t nframes
, jack_position_t
* pos
, int new_pos
, void* arg
)
763 return getInstance().timebase_cb(state
, nframes
, pos
, new_pos
, arg
);
766 static void session(jack_session_event_t
* event
, void* arg
)
768 return getInstance().session_cb(event
, arg
);
771 static void prop_change(jack_uuid_t subject
, const char* key
, jack_property_change_t change
, void* arg
)
773 return getInstance().prop_change_cb(subject
, key
, change
, arg
);
776 CARLA_DECLARE_NON_COPYABLE(WineBridge
);
779 #endif // __WINE__ && ! JACKBRIDGE_DIRECT
781 // -----------------------------------------------------------------------------
783 bool jackbridge_is_ok() noexcept
785 #if defined(JACKBRIDGE_DUMMY)
787 #elif defined(JACKBRIDGE_DIRECT)
790 return (getBridgeInstance().lib
!= nullptr);
794 void jackbridge_init()
796 #if defined(__WINE__) && ! defined(JACKBRIDGE_DIRECT)
797 if (getBridgeInstance().set_thread_creator_ptr
!= nullptr)
798 getBridgeInstance().set_thread_creator_ptr(WineBridge::thread_creator
);
802 // -----------------------------------------------------------------------------
804 void jackbridge_get_version(int* major_ptr
, int* minor_ptr
, int* micro_ptr
, int* proto_ptr
)
806 #if defined(JACKBRIDGE_DUMMY)
807 #elif defined(JACKBRIDGE_DIRECT)
808 return jack_get_version(major_ptr
, minor_ptr
, micro_ptr
, proto_ptr
);
810 if (getBridgeInstance().get_version_ptr
!= nullptr)
811 return getBridgeInstance().get_version_ptr(major_ptr
, minor_ptr
, micro_ptr
, proto_ptr
);
813 if (major_ptr
!= nullptr)
815 if (minor_ptr
!= nullptr)
817 if (micro_ptr
!= nullptr)
819 if (proto_ptr
!= nullptr)
823 const char* jackbridge_get_version_string()
825 #if defined(JACKBRIDGE_DUMMY)
826 #elif defined(JACKBRIDGE_DIRECT)
827 return jack_get_version_string();
829 if (getBridgeInstance().get_version_string_ptr
!= nullptr)
830 return getBridgeInstance().get_version_string_ptr();
835 // -----------------------------------------------------------------------------
837 jack_client_t
* jackbridge_client_open(const char* client_name
, uint32_t options
, jack_status_t
* status
)
839 #if defined(JACKBRIDGE_DUMMY)
840 #elif defined(JACKBRIDGE_DIRECT)
841 return jack_client_open(client_name
, static_cast<jack_options_t
>(options
), status
);
843 if (getBridgeInstance().client_open_ptr
!= nullptr)
844 return getBridgeInstance().client_open_ptr(client_name
, static_cast<jack_options_t
>(options
), status
);
846 if (status
!= nullptr)
847 *status
= JackServerError
;
851 bool jackbridge_client_close(jack_client_t
* client
)
853 #if defined(JACKBRIDGE_DUMMY)
854 #elif defined(JACKBRIDGE_DIRECT)
855 return (jack_client_close(client
) == 0);
857 if (getBridgeInstance().client_close_ptr
!= nullptr)
858 return (getBridgeInstance().client_close_ptr(client
) == 0);
863 // -----------------------------------------------------------------------------
865 int jackbridge_client_name_size()
867 #if defined(JACKBRIDGE_DUMMY)
868 #elif defined(JACKBRIDGE_DIRECT)
869 return jack_client_name_size();
871 if (getBridgeInstance().client_name_size_ptr
!= nullptr)
872 return getBridgeInstance().client_name_size_ptr();
877 char* jackbridge_get_client_name(jack_client_t
* client
)
879 #if defined(JACKBRIDGE_DUMMY)
880 #elif defined(JACKBRIDGE_DIRECT)
881 return jack_get_client_name(client
);
883 if (getBridgeInstance().get_client_name_ptr
!= nullptr)
884 return getBridgeInstance().get_client_name_ptr(client
);
889 // -----------------------------------------------------------------------------
891 char* jackbridge_client_get_uuid(jack_client_t
* client
)
893 #if defined(JACKBRIDGE_DUMMY)
894 #elif defined(JACKBRIDGE_DIRECT)
895 return jack_client_get_uuid(client
);
897 if (const jacksym_client_get_uuid func
= getBridgeInstance().client_get_uuid_ptr
)
903 char* jackbridge_get_uuid_for_client_name(jack_client_t
* client
, const char* name
)
905 #if defined(JACKBRIDGE_DUMMY)
906 #elif defined(JACKBRIDGE_DIRECT)
907 return jack_get_uuid_for_client_name(client
, name
);
909 if (getBridgeInstance().get_uuid_for_client_name_ptr
!= nullptr)
910 return getBridgeInstance().get_uuid_for_client_name_ptr(client
, name
);
915 char* jackbridge_get_client_name_by_uuid(jack_client_t
* client
, const char* uuid
)
917 #if defined(JACKBRIDGE_DUMMY)
918 #elif defined(JACKBRIDGE_DIRECT)
919 return jack_get_client_name_by_uuid(client
, uuid
);
921 if (getBridgeInstance().get_client_name_by_uuid_ptr
!= nullptr)
922 return getBridgeInstance().get_client_name_by_uuid_ptr(client
, uuid
);
927 // -----------------------------------------------------------------------------
929 bool jackbridge_uuid_parse(const char* buf
, jack_uuid_t
* uuid
)
931 #if defined(JACKBRIDGE_DUMMY)
932 #elif defined(JACKBRIDGE_DIRECT)
933 return (jack_uuid_parse(buf
, uuid
) == 0);
935 if (const jacksym_uuid_parse func
= getBridgeInstance().uuid_parse_ptr
)
936 return (func(buf
, uuid
) == 0);
941 void jackbridge_uuid_unparse(jack_uuid_t uuid
, char buf
[JACK_UUID_STRING_SIZE
])
943 #if defined(JACKBRIDGE_DUMMY)
944 #elif defined(JACKBRIDGE_DIRECT)
945 jack_uuid_unparse(uuid
, buf
);
947 if (const jacksym_uuid_unparse func
= getBridgeInstance().uuid_unparse_ptr
)
948 return func(uuid
, buf
);
952 // -----------------------------------------------------------------------------
954 bool jackbridge_activate(jack_client_t
* client
)
956 #if defined(JACKBRIDGE_DUMMY)
957 #elif defined(JACKBRIDGE_DIRECT)
958 return (jack_activate(client
) == 0);
960 if (getBridgeInstance().activate_ptr
!= nullptr)
961 return (getBridgeInstance().activate_ptr(client
) == 0);
966 bool jackbridge_deactivate(jack_client_t
* client
)
968 #if defined(JACKBRIDGE_DUMMY)
969 #elif defined(JACKBRIDGE_DIRECT)
970 return (jack_deactivate(client
) == 0);
972 if (getBridgeInstance().deactivate_ptr
!= nullptr)
973 return (getBridgeInstance().deactivate_ptr(client
) == 0);
978 bool jackbridge_is_realtime(jack_client_t
* client
)
980 #if defined(JACKBRIDGE_DUMMY)
981 #elif defined(JACKBRIDGE_DIRECT)
982 return jack_is_realtime(client
);
984 if (getBridgeInstance().is_realtime_ptr
!= nullptr)
985 return getBridgeInstance().is_realtime_ptr(client
);
990 // -----------------------------------------------------------------------------
992 bool jackbridge_set_thread_init_callback(jack_client_t
* client
, JackThreadInitCallback thread_init_callback
, void* arg
)
994 #if defined(JACKBRIDGE_DUMMY)
995 #elif defined(JACKBRIDGE_DIRECT)
996 return (jack_set_thread_init_callback(client
, thread_init_callback
, arg
) == 0);
998 if (getBridgeInstance().set_thread_init_callback_ptr
!= nullptr)
1001 WineBridge::getInstance().set_thread_init(thread_init_callback
);
1002 return (getBridgeInstance().set_thread_init_callback_ptr(client
, WineBridge::thread_init
, arg
) == 0);
1004 return (getBridgeInstance().set_thread_init_callback_ptr(client
, thread_init_callback
, arg
) == 0);
1011 void jackbridge_on_shutdown(jack_client_t
* client
, JackShutdownCallback shutdown_callback
, void* arg
)
1013 #if defined(JACKBRIDGE_DUMMY)
1014 #elif defined(JACKBRIDGE_DIRECT)
1015 jack_on_shutdown(client
, shutdown_callback
, arg
);
1017 if (getBridgeInstance().on_shutdown_ptr
!= nullptr)
1020 WineBridge::getInstance().set_shutdown(shutdown_callback
);
1021 getBridgeInstance().on_shutdown_ptr(client
, WineBridge::shutdown
, arg
);
1023 getBridgeInstance().on_shutdown_ptr(client
, shutdown_callback
, arg
);
1029 void jackbridge_on_info_shutdown(jack_client_t
* client
, JackInfoShutdownCallback shutdown_callback
, void* arg
)
1031 #if defined(JACKBRIDGE_DUMMY)
1032 #elif defined(JACKBRIDGE_DIRECT)
1033 jack_on_info_shutdown(client
, shutdown_callback
, arg
);
1035 if (getBridgeInstance().on_info_shutdown_ptr
!= nullptr)
1038 WineBridge::getInstance().set_info_shutdown(shutdown_callback
);
1039 getBridgeInstance().on_info_shutdown_ptr(client
, WineBridge::info_shutdown
, arg
);
1041 getBridgeInstance().on_info_shutdown_ptr(client
, shutdown_callback
, arg
);
1047 bool jackbridge_set_process_callback(jack_client_t
* client
, JackProcessCallback process_callback
, void* arg
)
1049 #if defined(JACKBRIDGE_DUMMY)
1050 #elif defined(JACKBRIDGE_DIRECT)
1051 return (jack_set_process_callback(client
, process_callback
, arg
) == 0);
1053 if (getBridgeInstance().set_process_callback_ptr
!= nullptr)
1056 WineBridge::getInstance().set_process(process_callback
);
1057 return (getBridgeInstance().set_process_callback_ptr(client
, WineBridge::process
, arg
) == 0);
1059 return (getBridgeInstance().set_process_callback_ptr(client
, process_callback
, arg
) == 0);
1066 bool jackbridge_set_freewheel_callback(jack_client_t
* client
, JackFreewheelCallback freewheel_callback
, void* arg
)
1068 #if defined(JACKBRIDGE_DUMMY)
1069 #elif defined(JACKBRIDGE_DIRECT)
1070 return (jack_set_freewheel_callback(client
, freewheel_callback
, arg
) == 0);
1072 if (getBridgeInstance().set_freewheel_callback_ptr
!= nullptr)
1075 WineBridge::getInstance().set_freewheel(freewheel_callback
);
1076 return (getBridgeInstance().set_freewheel_callback_ptr(client
, WineBridge::freewheel
, arg
) == 0);
1078 return (getBridgeInstance().set_freewheel_callback_ptr(client
, freewheel_callback
, arg
) == 0);
1085 bool jackbridge_set_buffer_size_callback(jack_client_t
* client
, JackBufferSizeCallback bufsize_callback
, void* arg
)
1087 #if defined(JACKBRIDGE_DUMMY)
1088 #elif defined(JACKBRIDGE_DIRECT)
1089 return (jack_set_buffer_size_callback(client
, bufsize_callback
, arg
) == 0);
1091 if (getBridgeInstance().set_buffer_size_callback_ptr
!= nullptr)
1094 WineBridge::getInstance().set_bufsize(bufsize_callback
);
1095 return (getBridgeInstance().set_buffer_size_callback_ptr(client
, WineBridge::bufsize
, arg
) == 0);
1097 return (getBridgeInstance().set_buffer_size_callback_ptr(client
, bufsize_callback
, arg
) == 0);
1104 bool jackbridge_set_sample_rate_callback(jack_client_t
* client
, JackSampleRateCallback srate_callback
, void* arg
)
1106 #if defined(JACKBRIDGE_DUMMY)
1107 #elif defined(JACKBRIDGE_DIRECT)
1108 return (jack_set_sample_rate_callback(client
, srate_callback
, arg
) == 0);
1110 if (getBridgeInstance().set_sample_rate_callback_ptr
!= nullptr)
1113 WineBridge::getInstance().set_srate(srate_callback
);
1114 return (getBridgeInstance().set_sample_rate_callback_ptr(client
, WineBridge::srate
, arg
) == 0);
1116 return (getBridgeInstance().set_sample_rate_callback_ptr(client
, srate_callback
, arg
) == 0);
1123 bool jackbridge_set_client_registration_callback(jack_client_t
* client
, JackClientRegistrationCallback registration_callback
, void* arg
)
1125 #if defined(JACKBRIDGE_DUMMY)
1126 #elif defined(JACKBRIDGE_DIRECT)
1127 return (jack_set_client_registration_callback(client
, registration_callback
, arg
) == 0);
1129 if (getBridgeInstance().set_client_registration_callback_ptr
!= nullptr)
1132 WineBridge::getInstance().set_client_reg(registration_callback
);
1133 return (getBridgeInstance().set_client_registration_callback_ptr(client
, WineBridge::client_reg
, arg
) == 0);
1135 return (getBridgeInstance().set_client_registration_callback_ptr(client
, registration_callback
, arg
) == 0);
1142 bool jackbridge_set_port_registration_callback(jack_client_t
* client
, JackPortRegistrationCallback registration_callback
, void *arg
)
1144 #if defined(JACKBRIDGE_DUMMY)
1145 #elif defined(JACKBRIDGE_DIRECT)
1146 return (jack_set_port_registration_callback(client
, registration_callback
, arg
) == 0);
1148 if (getBridgeInstance().set_port_registration_callback_ptr
!= nullptr)
1151 WineBridge::getInstance().set_port_reg(registration_callback
);
1152 return (getBridgeInstance().set_port_registration_callback_ptr(client
, WineBridge::port_reg
, arg
) == 0);
1154 return (getBridgeInstance().set_port_registration_callback_ptr(client
, registration_callback
, arg
) == 0);
1161 bool jackbridge_set_port_rename_callback(jack_client_t
* client
, JackPortRenameCallback rename_callback
, void* arg
)
1163 #if defined(JACKBRIDGE_DUMMY)
1164 #elif defined(JACKBRIDGE_DIRECT)
1165 return (jack_set_port_rename_callback(client
, rename_callback
, arg
) == 0);
1167 if (getBridgeInstance().set_port_rename_callback_ptr
!= nullptr)
1170 WineBridge::getInstance().set_port_rename(rename_callback
);
1171 return (getBridgeInstance().set_port_rename_callback_ptr(client
, WineBridge::port_rename
, arg
) == 0);
1173 return (getBridgeInstance().set_port_rename_callback_ptr(client
, rename_callback
, arg
) == 0);
1180 bool jackbridge_set_port_connect_callback(jack_client_t
* client
, JackPortConnectCallback connect_callback
, void* arg
)
1182 #if defined(JACKBRIDGE_DUMMY)
1183 #elif defined(JACKBRIDGE_DIRECT)
1184 return (jack_set_port_connect_callback(client
, connect_callback
, arg
) == 0);
1186 if (getBridgeInstance().set_port_connect_callback_ptr
!= nullptr)
1189 WineBridge::getInstance().set_port_conn(connect_callback
);
1190 return (getBridgeInstance().set_port_connect_callback_ptr(client
, WineBridge::port_conn
, arg
) == 0);
1192 return (getBridgeInstance().set_port_connect_callback_ptr(client
, connect_callback
, arg
) == 0);
1199 bool jackbridge_set_graph_order_callback(jack_client_t
* client
, JackGraphOrderCallback graph_callback
, void* arg
)
1201 #if defined(JACKBRIDGE_DUMMY)
1202 #elif defined(JACKBRIDGE_DIRECT)
1203 return (jack_set_graph_order_callback(client
, graph_callback
, arg
) == 0);
1205 if (getBridgeInstance().set_graph_order_callback_ptr
!= nullptr)
1208 WineBridge::getInstance().set_graph_order(graph_callback
);
1209 return (getBridgeInstance().set_graph_order_callback_ptr(client
, WineBridge::graph_order
, arg
) == 0);
1211 return (getBridgeInstance().set_graph_order_callback_ptr(client
, graph_callback
, arg
) == 0);
1218 bool jackbridge_set_xrun_callback(jack_client_t
* client
, JackXRunCallback xrun_callback
, void* arg
)
1220 #if defined(JACKBRIDGE_DUMMY)
1221 #elif defined(JACKBRIDGE_DIRECT)
1222 return (jack_set_xrun_callback(client
, xrun_callback
, arg
) == 0);
1224 if (getBridgeInstance().set_xrun_callback_ptr
!= nullptr)
1227 WineBridge::getInstance().set_xrun(xrun_callback
);
1228 return (getBridgeInstance().set_xrun_callback_ptr(client
, WineBridge::xrun
, arg
) == 0);
1230 return (getBridgeInstance().set_xrun_callback_ptr(client
, xrun_callback
, arg
) == 0);
1237 bool jackbridge_set_latency_callback(jack_client_t
* client
, JackLatencyCallback latency_callback
, void* arg
)
1239 #if defined(JACKBRIDGE_DUMMY)
1240 #elif defined(JACKBRIDGE_DIRECT)
1241 return (jack_set_latency_callback(client
, latency_callback
, arg
) == 0);
1243 if (getBridgeInstance().set_latency_callback_ptr
!= nullptr)
1246 WineBridge::getInstance().set_latency(latency_callback
);
1247 return (getBridgeInstance().set_latency_callback_ptr(client
, WineBridge::latency
, arg
) == 0);
1249 return (getBridgeInstance().set_latency_callback_ptr(client
, latency_callback
, arg
) == 0);
1256 // -----------------------------------------------------------------------------
1258 bool jackbridge_set_freewheel(jack_client_t
* client
, bool onoff
)
1260 #if defined(JACKBRIDGE_DUMMY)
1261 #elif defined(JACKBRIDGE_DIRECT)
1262 return jack_set_freewheel(client
, onoff
);
1264 if (getBridgeInstance().set_freewheel_ptr
!= nullptr)
1265 return getBridgeInstance().set_freewheel_ptr(client
, onoff
);
1270 bool jackbridge_set_buffer_size(jack_client_t
* client
, jack_nframes_t nframes
)
1272 #if defined(JACKBRIDGE_DUMMY)
1273 #elif defined(JACKBRIDGE_DIRECT)
1274 return jack_set_buffer_size(client
, nframes
);
1276 if (getBridgeInstance().set_buffer_size_ptr
!= nullptr)
1277 return getBridgeInstance().set_buffer_size_ptr(client
, nframes
);
1282 // -----------------------------------------------------------------------------
1284 jack_nframes_t
jackbridge_get_sample_rate(jack_client_t
* client
)
1286 #if defined(JACKBRIDGE_DUMMY)
1287 #elif defined(JACKBRIDGE_DIRECT)
1288 return jack_get_sample_rate(client
);
1290 if (getBridgeInstance().get_sample_rate_ptr
!= nullptr)
1291 return getBridgeInstance().get_sample_rate_ptr(client
);
1296 jack_nframes_t
jackbridge_get_buffer_size(jack_client_t
* client
)
1298 #if defined(JACKBRIDGE_DUMMY)
1299 #elif defined(JACKBRIDGE_DIRECT)
1300 return jack_get_buffer_size(client
);
1302 if (getBridgeInstance().get_buffer_size_ptr
!= nullptr)
1303 return getBridgeInstance().get_buffer_size_ptr(client
);
1308 float jackbridge_cpu_load(jack_client_t
* client
)
1310 #if defined(JACKBRIDGE_DUMMY)
1311 #elif defined(JACKBRIDGE_DIRECT)
1312 return jack_cpu_load(client
);
1314 if (getBridgeInstance().cpu_load_ptr
!= nullptr)
1315 return getBridgeInstance().cpu_load_ptr(client
);
1320 // -----------------------------------------------------------------------------
1322 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
)
1324 #if defined(JACKBRIDGE_DUMMY)
1325 #elif defined(JACKBRIDGE_DIRECT)
1326 return jack_port_register(client
, port_name
, port_type
, flags
, buffer_size
);
1328 if (getBridgeInstance().port_register_ptr
!= nullptr)
1329 return getBridgeInstance().port_register_ptr(client
, port_name
, port_type
,
1330 static_cast<ulong
>(flags
),
1331 static_cast<ulong
>(buffer_size
));
1336 bool jackbridge_port_unregister(jack_client_t
* client
, jack_port_t
* port
)
1338 #if defined(JACKBRIDGE_DUMMY)
1339 #elif defined(JACKBRIDGE_DIRECT)
1340 return (jack_port_unregister(client
, port
) == 0);
1342 if (getBridgeInstance().port_unregister_ptr
!= nullptr)
1343 return (getBridgeInstance().port_unregister_ptr(client
, port
) == 0);
1348 void* jackbridge_port_get_buffer(jack_port_t
* port
, jack_nframes_t nframes
)
1350 #if defined(JACKBRIDGE_DUMMY)
1351 #elif defined(JACKBRIDGE_DIRECT)
1352 return jack_port_get_buffer(port
, nframes
);
1354 if (getBridgeInstance().port_get_buffer_ptr
!= nullptr)
1355 return getBridgeInstance().port_get_buffer_ptr(port
, nframes
);
1360 // -----------------------------------------------------------------------------
1362 const char* jackbridge_port_name(const jack_port_t
* port
)
1364 #if defined(JACKBRIDGE_DUMMY)
1365 #elif defined(JACKBRIDGE_DIRECT)
1366 return jack_port_name(port
);
1368 if (getBridgeInstance().port_name_ptr
!= nullptr)
1369 return getBridgeInstance().port_name_ptr(port
);
1374 jack_uuid_t
jackbridge_port_uuid(const jack_port_t
* port
)
1376 #if defined(JACKBRIDGE_DUMMY)
1377 #elif defined(JACKBRIDGE_DIRECT)
1378 return jack_port_uuid(port
);
1380 if (getBridgeInstance().port_uuid_ptr
!= nullptr)
1381 return getBridgeInstance().port_uuid_ptr(port
);
1386 const char* jackbridge_port_short_name(const jack_port_t
* port
)
1388 #if defined(JACKBRIDGE_DUMMY)
1389 #elif defined(JACKBRIDGE_DIRECT)
1390 return jack_port_short_name(port
);
1392 if (getBridgeInstance().port_short_name_ptr
!= nullptr)
1393 return getBridgeInstance().port_short_name_ptr(port
);
1398 int jackbridge_port_flags(const jack_port_t
* port
)
1400 #if defined(JACKBRIDGE_DUMMY)
1401 #elif defined(JACKBRIDGE_DIRECT)
1402 return jack_port_flags(port
);
1404 if (getBridgeInstance().port_flags_ptr
!= nullptr)
1405 return getBridgeInstance().port_flags_ptr(port
);
1410 const char* jackbridge_port_type(const jack_port_t
* port
)
1412 #if defined(JACKBRIDGE_DUMMY)
1413 #elif defined(JACKBRIDGE_DIRECT)
1414 return jack_port_type(port
);
1416 if (getBridgeInstance().port_type_ptr
!= nullptr)
1417 return getBridgeInstance().port_type_ptr(port
);
1422 bool jackbridge_port_is_mine(const jack_client_t
* client
, const jack_port_t
* port
)
1424 #if defined(JACKBRIDGE_DUMMY)
1425 #elif defined(JACKBRIDGE_DIRECT)
1426 return jack_port_is_mine(client
, port
);
1428 if (getBridgeInstance().port_is_mine_ptr
!= nullptr)
1429 return getBridgeInstance().port_is_mine_ptr(client
, port
);
1434 int jackbridge_port_connected(const jack_port_t
* port
)
1436 #if defined(JACKBRIDGE_DUMMY)
1437 #elif defined(JACKBRIDGE_DIRECT)
1438 return jack_port_connected(port
);
1440 if (getBridgeInstance().port_connected_ptr
!= nullptr)
1441 return getBridgeInstance().port_connected_ptr(port
);
1446 bool jackbridge_port_connected_to(const jack_port_t
* port
, const char* port_name
)
1448 #if defined(JACKBRIDGE_DUMMY)
1449 #elif defined(JACKBRIDGE_DIRECT)
1450 return jack_port_connected_to(port
, port_name
);
1452 if (getBridgeInstance().port_connected_to_ptr
!= nullptr)
1453 return getBridgeInstance().port_connected_to_ptr(port
, port_name
);
1458 const char** jackbridge_port_get_connections(const jack_port_t
* port
)
1460 #if defined(JACKBRIDGE_DUMMY)
1461 #elif defined(JACKBRIDGE_DIRECT)
1462 return jack_port_get_connections(port
);
1464 if (getBridgeInstance().port_get_connections_ptr
!= nullptr)
1465 return getBridgeInstance().port_get_connections_ptr(port
);
1470 const char** jackbridge_port_get_all_connections(const jack_client_t
* client
, const jack_port_t
* port
)
1472 #if defined(JACKBRIDGE_DUMMY)
1473 #elif defined(JACKBRIDGE_DIRECT)
1474 return jack_port_get_all_connections(client
, port
);
1476 if (getBridgeInstance().port_get_all_connections_ptr
!= nullptr)
1477 return getBridgeInstance().port_get_all_connections_ptr(client
, port
);
1482 // -----------------------------------------------------------------------------
1484 bool jackbridge_port_rename(jack_client_t
* client
, jack_port_t
* port
, const char* port_name
)
1486 #if defined(JACKBRIDGE_DUMMY)
1487 #elif defined(JACKBRIDGE_DIRECT)
1488 return (jack_port_rename(client
, port
, port_name
) == 0);
1490 // Try new API first
1491 if (getBridgeInstance().port_rename_ptr
!= nullptr)
1492 return (getBridgeInstance().port_rename_ptr(client
, port
, port_name
) == 0);
1493 // Try old API if using JACK2
1494 if (getBridgeInstance().get_version_string_ptr
!= nullptr && getBridgeInstance().port_set_name_ptr
!= nullptr)
1495 return (getBridgeInstance().port_set_name_ptr(port
, port_name
) == 0);
1500 bool jackbridge_port_set_alias(jack_port_t
* port
, const char* alias
)
1502 #if defined(JACKBRIDGE_DUMMY)
1503 #elif defined(JACKBRIDGE_DIRECT)
1504 return (jack_port_set_alias(port
, alias
) == 0);
1506 if (getBridgeInstance().port_set_alias_ptr
!= nullptr)
1507 return (getBridgeInstance().port_set_alias_ptr(port
, alias
) == 0);
1512 bool jackbridge_port_unset_alias(jack_port_t
* port
, const char* alias
)
1514 #if defined(JACKBRIDGE_DUMMY)
1515 #elif defined(JACKBRIDGE_DIRECT)
1516 return (jack_port_unset_alias(port
, alias
) == 0);
1518 if (getBridgeInstance().port_unset_alias_ptr
!= nullptr)
1519 return (getBridgeInstance().port_unset_alias_ptr(port
, alias
) == 0);
1524 int jackbridge_port_get_aliases(const jack_port_t
* port
, char* const aliases
[2])
1526 #if defined(JACKBRIDGE_DUMMY)
1527 #elif defined(JACKBRIDGE_DIRECT)
1528 return (jack_port_get_aliases(port
, aliases
) == 0);
1530 if (getBridgeInstance().port_get_aliases_ptr
!= nullptr)
1531 return getBridgeInstance().port_get_aliases_ptr(port
, aliases
);
1536 // -----------------------------------------------------------------------------
1538 bool jackbridge_port_request_monitor(jack_port_t
* port
, bool onoff
)
1540 #if defined(JACKBRIDGE_DUMMY)
1541 #elif defined(JACKBRIDGE_DIRECT)
1542 return (jack_port_request_monitor(port
, onoff
) == 0);
1544 if (getBridgeInstance().port_request_monitor_ptr
!= nullptr)
1545 return (getBridgeInstance().port_request_monitor_ptr(port
, onoff
) == 0);
1550 bool jackbridge_port_request_monitor_by_name(jack_client_t
* client
, const char* port_name
, bool onoff
)
1552 #if defined(JACKBRIDGE_DUMMY)
1553 #elif defined(JACKBRIDGE_DIRECT)
1554 return (jack_port_request_monitor_by_name(client
, port_name
, onoff
) == 0);
1556 if (getBridgeInstance().port_request_monitor_by_name_ptr
!= nullptr)
1557 return (getBridgeInstance().port_request_monitor_by_name_ptr(client
, port_name
, onoff
) == 0);
1562 bool jackbridge_port_ensure_monitor(jack_port_t
* port
, bool onoff
)
1564 #if defined(JACKBRIDGE_DUMMY)
1565 #elif defined(JACKBRIDGE_DIRECT)
1566 return (jack_port_ensure_monitor(port
, onoff
) == 0);
1568 if (getBridgeInstance().port_ensure_monitor_ptr
!= nullptr)
1569 return (getBridgeInstance().port_ensure_monitor_ptr(port
, onoff
) == 0);
1574 bool jackbridge_port_monitoring_input(jack_port_t
* port
)
1576 #if defined(JACKBRIDGE_DUMMY)
1577 #elif defined(JACKBRIDGE_DIRECT)
1578 return jack_port_monitoring_input(port
);
1580 if (getBridgeInstance().port_monitoring_input_ptr
!= nullptr)
1581 return getBridgeInstance().port_monitoring_input_ptr(port
);
1586 // -----------------------------------------------------------------------------
1588 bool jackbridge_connect(jack_client_t
* client
, const char* source_port
, const char* destination_port
)
1590 #if defined(JACKBRIDGE_DUMMY)
1591 #elif defined(JACKBRIDGE_DIRECT)
1592 return (jack_connect(client
, source_port
, destination_port
) == 0);
1594 if (getBridgeInstance().connect_ptr
!= nullptr)
1596 const int ret
= getBridgeInstance().connect_ptr(client
, source_port
, destination_port
);
1597 return ret
== 0 || ret
== EEXIST
;
1603 bool jackbridge_disconnect(jack_client_t
* client
, const char* source_port
, const char* destination_port
)
1605 #if defined(JACKBRIDGE_DUMMY)
1606 #elif defined(JACKBRIDGE_DIRECT)
1607 return (jack_disconnect(client
, source_port
, destination_port
) == 0);
1609 if (getBridgeInstance().disconnect_ptr
!= nullptr)
1610 return (getBridgeInstance().disconnect_ptr(client
, source_port
, destination_port
) == 0);
1615 bool jackbridge_port_disconnect(jack_client_t
* client
, jack_port_t
* port
)
1617 #if defined(JACKBRIDGE_DUMMY)
1618 #elif defined(JACKBRIDGE_DIRECT)
1619 return (jack_port_disconnect(client
, port
) == 0);
1621 if (getBridgeInstance().port_disconnect_ptr
!= nullptr)
1622 return (getBridgeInstance().port_disconnect_ptr(client
, port
) == 0);
1627 // -----------------------------------------------------------------------------
1629 int jackbridge_port_name_size()
1631 #if defined(JACKBRIDGE_DUMMY)
1632 #elif defined(JACKBRIDGE_DIRECT)
1633 return jack_port_name_size();
1635 if (getBridgeInstance().port_name_size_ptr
!= nullptr)
1636 return getBridgeInstance().port_name_size_ptr();
1641 int jackbridge_port_type_size()
1643 #if defined(JACKBRIDGE_DUMMY)
1644 #elif defined(JACKBRIDGE_DIRECT)
1645 return jack_port_type_size();
1647 if (getBridgeInstance().port_type_size_ptr
!= nullptr)
1648 return getBridgeInstance().port_type_size_ptr();
1653 uint32_t jackbridge_port_type_get_buffer_size(jack_client_t
* client
, const char* port_type
)
1655 #if defined(JACKBRIDGE_DUMMY)
1656 #elif defined(JACKBRIDGE_DIRECT)
1657 return static_cast<uint32_t>(jack_port_type_get_buffer_size(client
, port_type
));
1659 if (getBridgeInstance().port_type_get_buffer_size_ptr
!= nullptr)
1660 return static_cast<uint32_t>(getBridgeInstance().port_type_get_buffer_size_ptr(client
, port_type
));
1665 // -----------------------------------------------------------------------------
1667 void jackbridge_port_get_latency_range(jack_port_t
* port
, uint32_t mode
, jack_latency_range_t
* range
)
1669 #if defined(JACKBRIDGE_DUMMY)
1670 #elif defined(JACKBRIDGE_DIRECT)
1671 return jack_port_get_latency_range(port
, static_cast<jack_latency_callback_mode_t
>(mode
), range
);
1673 if (getBridgeInstance().port_get_latency_range_ptr
!= nullptr)
1674 return getBridgeInstance().port_get_latency_range_ptr(port
,
1675 static_cast<jack_latency_callback_mode_t
>(mode
),
1682 void jackbridge_port_set_latency_range(jack_port_t
* port
, uint32_t mode
, jack_latency_range_t
* range
)
1684 #if defined(JACKBRIDGE_DUMMY)
1685 #elif defined(JACKBRIDGE_DIRECT)
1686 jack_port_set_latency_range(port
, static_cast<jack_latency_callback_mode_t
>(mode
), range
);
1688 if (getBridgeInstance().port_set_latency_range_ptr
!= nullptr)
1689 getBridgeInstance().port_set_latency_range_ptr(port
,
1690 static_cast<jack_latency_callback_mode_t
>(mode
),
1695 bool jackbridge_recompute_total_latencies(jack_client_t
* client
)
1697 #if defined(JACKBRIDGE_DUMMY)
1698 #elif defined(JACKBRIDGE_DIRECT)
1699 return (jack_recompute_total_latencies(client
) == 0);
1701 if (getBridgeInstance().recompute_total_latencies_ptr
!= nullptr)
1702 return (getBridgeInstance().recompute_total_latencies_ptr(client
) == 0);
1707 // -----------------------------------------------------------------------------
1709 const char** jackbridge_get_ports(jack_client_t
* client
, const char* port_name_pattern
, const char* type_name_pattern
, uint64_t flags
)
1711 #if defined(JACKBRIDGE_DUMMY)
1712 #elif defined(JACKBRIDGE_DIRECT)
1713 return jack_get_ports(client
, port_name_pattern
, type_name_pattern
, flags
);
1715 if (getBridgeInstance().get_ports_ptr
!= nullptr)
1716 return getBridgeInstance().get_ports_ptr(client
, port_name_pattern
, type_name_pattern
,
1717 static_cast<ulong
>(flags
));
1722 jack_port_t
* jackbridge_port_by_name(jack_client_t
* client
, const char* port_name
)
1724 #if defined(JACKBRIDGE_DUMMY)
1725 #elif defined(JACKBRIDGE_DIRECT)
1726 return jack_port_by_name(client
, port_name
);
1728 if (getBridgeInstance().port_by_name_ptr
!= nullptr)
1729 return getBridgeInstance().port_by_name_ptr(client
, port_name
);
1734 jack_port_t
* jackbridge_port_by_id(jack_client_t
* client
, jack_port_id_t port_id
)
1736 #if defined(JACKBRIDGE_DUMMY)
1737 #elif defined(JACKBRIDGE_DIRECT)
1738 return jack_port_by_id(client
, port_id
);
1740 if (getBridgeInstance().port_by_id_ptr
!= nullptr)
1741 return getBridgeInstance().port_by_id_ptr(client
, port_id
);
1746 // -----------------------------------------------------------------------------
1748 void jackbridge_free(void* ptr
)
1750 #if defined(JACKBRIDGE_DUMMY)
1751 #elif defined(JACKBRIDGE_DIRECT)
1752 return jack_free(ptr
);
1754 if (getBridgeInstance().free_ptr
!= nullptr)
1755 return getBridgeInstance().free_ptr(ptr
);
1762 // -----------------------------------------------------------------------------
1764 uint32_t jackbridge_midi_get_event_count(void* port_buffer
)
1766 #if defined(JACKBRIDGE_DUMMY)
1767 #elif defined(JACKBRIDGE_DIRECT)
1768 return jack_midi_get_event_count(port_buffer
);
1770 if (getBridgeInstance().midi_get_event_count_ptr
!= nullptr)
1771 return getBridgeInstance().midi_get_event_count_ptr(port_buffer
);
1776 bool jackbridge_midi_event_get(jack_midi_event_t
* event
, void* port_buffer
, uint32_t event_index
)
1778 #if defined(JACKBRIDGE_DUMMY)
1779 #elif defined(JACKBRIDGE_DIRECT)
1780 return (jack_midi_event_get(event
, port_buffer
, event_index
) == 0);
1782 if (getBridgeInstance().midi_event_get_ptr
!= nullptr)
1783 return (getBridgeInstance().midi_event_get_ptr(event
, port_buffer
, event_index
) == 0);
1788 void jackbridge_midi_clear_buffer(void* port_buffer
)
1790 #if defined(JACKBRIDGE_DUMMY)
1791 #elif defined(JACKBRIDGE_DIRECT)
1792 jack_midi_clear_buffer(port_buffer
);
1794 if (getBridgeInstance().midi_clear_buffer_ptr
!= nullptr)
1795 getBridgeInstance().midi_clear_buffer_ptr(port_buffer
);
1799 bool jackbridge_midi_event_write(void* port_buffer
, jack_nframes_t time
, const jack_midi_data_t
* data
, uint32_t data_size
)
1801 #if defined(JACKBRIDGE_DUMMY)
1802 #elif defined(JACKBRIDGE_DIRECT)
1803 return (jack_midi_event_write(port_buffer
, time
, data
, data_size
) == 0);
1805 if (getBridgeInstance().midi_event_write_ptr
!= nullptr)
1806 return (getBridgeInstance().midi_event_write_ptr(port_buffer
, time
, data
, data_size
) == 0);
1811 jack_midi_data_t
* jackbridge_midi_event_reserve(void* port_buffer
, jack_nframes_t time
, uint32_t data_size
)
1813 #if defined(JACKBRIDGE_DUMMY)
1814 #elif defined(JACKBRIDGE_DIRECT)
1815 return jack_midi_event_reserve(port_buffer
, time
, data_size
);
1817 if (getBridgeInstance().midi_event_reserve_ptr
!= nullptr)
1818 return getBridgeInstance().midi_event_reserve_ptr(port_buffer
, time
, data_size
);
1823 // -----------------------------------------------------------------------------
1825 bool jackbridge_release_timebase(jack_client_t
* client
)
1827 #if defined(JACKBRIDGE_DUMMY)
1828 #elif defined(JACKBRIDGE_DIRECT)
1829 return (jack_release_timebase(client
) == 0);
1831 if (getBridgeInstance().release_timebase_ptr
!= nullptr)
1832 return (getBridgeInstance().release_timebase_ptr(client
) == 0);
1837 bool jackbridge_set_sync_callback(jack_client_t
* client
, JackSyncCallback sync_callback
, void* arg
)
1839 #if defined(JACKBRIDGE_DUMMY)
1840 #elif defined(JACKBRIDGE_DIRECT)
1841 return (jack_set_sync_callback(client
, sync_callback
, arg
) == 0);
1843 if (getBridgeInstance().set_sync_callback_ptr
!= nullptr)
1846 WineBridge::getInstance().set_sync(sync_callback
);
1847 return (getBridgeInstance().set_sync_callback_ptr(client
, WineBridge::sync
, arg
) == 0);
1849 return (getBridgeInstance().set_sync_callback_ptr(client
, sync_callback
, arg
) == 0);
1856 bool jackbridge_set_sync_timeout(jack_client_t
* client
, jack_time_t timeout
)
1858 #if defined(JACKBRIDGE_DUMMY)
1859 #elif defined(JACKBRIDGE_DIRECT)
1860 return (jack_set_sync_timeout(client
, timeout
) == 0);
1862 if (getBridgeInstance().set_sync_timeout_ptr
!= nullptr)
1863 return (getBridgeInstance().set_sync_timeout_ptr(client
, timeout
) == 0);
1868 bool jackbridge_set_timebase_callback(jack_client_t
* client
, bool conditional
, JackTimebaseCallback timebase_callback
, void* arg
)
1870 #if defined(JACKBRIDGE_DUMMY)
1871 #elif defined(JACKBRIDGE_DIRECT)
1872 return (jack_set_timebase_callback(client
, conditional
, timebase_callback
, arg
) == 0);
1874 if (getBridgeInstance().set_timebase_callback_ptr
!= nullptr)
1877 WineBridge::getInstance().set_timebase(timebase_callback
);
1878 return (getBridgeInstance().set_timebase_callback_ptr(client
, conditional
, WineBridge::timebase
, arg
) == 0);
1880 return (getBridgeInstance().set_timebase_callback_ptr(client
, conditional
, timebase_callback
, arg
) == 0);
1887 bool jackbridge_transport_locate(jack_client_t
* client
, jack_nframes_t frame
)
1889 #if defined(JACKBRIDGE_DUMMY)
1890 #elif defined(JACKBRIDGE_DIRECT)
1891 return (jack_transport_locate(client
, frame
) == 0);
1893 if (getBridgeInstance().transport_locate_ptr
!= nullptr)
1894 return (getBridgeInstance().transport_locate_ptr(client
, frame
) == 0);
1899 uint32_t jackbridge_transport_query(const jack_client_t
* client
, jack_position_t
* pos
)
1901 #if defined(JACKBRIDGE_DUMMY)
1902 #elif defined(JACKBRIDGE_DIRECT)
1903 return jack_transport_query(client
, pos
);
1905 if (getBridgeInstance().transport_query_ptr
!= nullptr)
1906 return getBridgeInstance().transport_query_ptr(client
, pos
);
1914 return JackTransportStopped
;
1917 jack_nframes_t
jackbridge_get_current_transport_frame(const jack_client_t
* client
)
1919 #if defined(JACKBRIDGE_DUMMY)
1920 #elif defined(JACKBRIDGE_DIRECT)
1921 return jack_get_current_transport_frame(client
);
1923 if (getBridgeInstance().get_current_transport_frame_ptr
!= nullptr)
1924 return getBridgeInstance().get_current_transport_frame_ptr(client
);
1929 bool jackbridge_transport_reposition(jack_client_t
* client
, const jack_position_t
* pos
)
1931 #if defined(JACKBRIDGE_DUMMY)
1932 #elif defined(JACKBRIDGE_DIRECT)
1933 return (jack_transport_reposition(client
, pos
) == 0);
1935 if (getBridgeInstance().transport_reposition_ptr
!= nullptr)
1936 return (getBridgeInstance().transport_reposition_ptr(client
, pos
) == 0);
1941 void jackbridge_transport_start(jack_client_t
* client
)
1943 #if defined(JACKBRIDGE_DUMMY)
1944 #elif defined(JACKBRIDGE_DIRECT)
1945 jack_transport_start(client
);
1947 if (getBridgeInstance().transport_start_ptr
!= nullptr)
1948 getBridgeInstance().transport_start_ptr(client
);
1952 void jackbridge_transport_stop(jack_client_t
* client
)
1954 #if defined(JACKBRIDGE_DUMMY)
1955 #elif defined(JACKBRIDGE_DIRECT)
1956 jack_transport_stop(client
);
1958 if (getBridgeInstance().transport_stop_ptr
!= nullptr)
1959 getBridgeInstance().transport_stop_ptr(client
);
1963 // -----------------------------------------------------------------------------
1965 bool jackbridge_set_property(jack_client_t
* client
, jack_uuid_t subject
, const char* key
, const char* value
, const char* type
)
1967 #if defined(JACKBRIDGE_DUMMY)
1968 #elif defined(JACKBRIDGE_DIRECT)
1969 return (jack_set_property(client
, subject
, key
, value
, type
) == 0);
1971 if (getBridgeInstance().set_property_ptr
!= nullptr)
1972 return (getBridgeInstance().set_property_ptr(client
, subject
, key
, value
, type
) == 0);
1977 bool jackbridge_get_property(jack_uuid_t subject
, const char* key
, char** value
, char** type
)
1979 #if defined(JACKBRIDGE_DUMMY)
1980 #elif defined(JACKBRIDGE_DIRECT)
1981 return (jack_get_property(subject
, key
, value
, type
) == 0);
1983 if (getBridgeInstance().get_property_ptr
!= nullptr)
1984 return (getBridgeInstance().get_property_ptr(subject
, key
, value
, type
) == 0);
1989 void jackbridge_free_description(jack_description_t
* desc
, bool free_description_itself
)
1991 #if defined(JACKBRIDGE_DUMMY)
1992 #elif defined(JACKBRIDGE_DIRECT)
1993 jack_free_description(desc
, free_description_itself
);
1995 if (getBridgeInstance().free_description_ptr
!= nullptr)
1996 getBridgeInstance().free_description_ptr(desc
, free_description_itself
);
2000 bool jackbridge_get_properties(jack_uuid_t subject
, jack_description_t
* desc
)
2002 #if defined(JACKBRIDGE_DUMMY)
2003 #elif defined(JACKBRIDGE_DIRECT)
2004 return (jack_get_properties(subject
, desc
) == 0);
2006 if (getBridgeInstance().get_properties_ptr
!= nullptr)
2007 return (getBridgeInstance().get_properties_ptr(subject
, desc
) == 0);
2012 bool jackbridge_get_all_properties(jack_description_t
** descs
)
2014 #if defined(JACKBRIDGE_DUMMY)
2015 #elif defined(JACKBRIDGE_DIRECT)
2016 return (jack_get_all_properties(descs
) == 0);
2018 if (getBridgeInstance().get_all_properties_ptr
!= nullptr)
2019 return (getBridgeInstance().get_all_properties_ptr(descs
) == 0);
2024 bool jackbridge_remove_property(jack_client_t
* client
, jack_uuid_t subject
, const char* key
)
2026 #if defined(JACKBRIDGE_DUMMY)
2027 #elif defined(JACKBRIDGE_DIRECT)
2028 return (jack_remove_property(client
, subject
, key
) == 0);
2030 if (getBridgeInstance().remove_property_ptr
!= nullptr)
2031 return (getBridgeInstance().remove_property_ptr(client
, subject
, key
) == 0);
2036 int jackbridge_remove_properties(jack_client_t
* client
, jack_uuid_t subject
)
2038 #if defined(JACKBRIDGE_DUMMY)
2039 #elif defined(JACKBRIDGE_DIRECT)
2040 return jack_remove_properties(client
, subject
);
2042 if (getBridgeInstance().remove_properties_ptr
!= nullptr)
2043 return getBridgeInstance().remove_properties_ptr(client
, subject
);
2048 bool jackbridge_remove_all_properties(jack_client_t
* client
)
2050 #if defined(JACKBRIDGE_DUMMY)
2051 #elif defined(JACKBRIDGE_DIRECT)
2052 return (jack_remove_all_properties(client
) == 0);
2054 if (getBridgeInstance().remove_all_properties_ptr
!= nullptr)
2055 return (getBridgeInstance().remove_all_properties_ptr(client
) == 0);
2060 bool jackbridge_set_property_change_callback(jack_client_t
* client
, JackPropertyChangeCallback callback
, void* arg
)
2062 #if defined(JACKBRIDGE_DUMMY)
2063 #elif defined(JACKBRIDGE_DIRECT)
2064 return (jack_set_property_change_callback(client
, callback
, arg
) == 0);
2066 if (getBridgeInstance().set_property_change_callback_ptr
!= nullptr)
2069 WineBridge::getInstance().set_prop_change(callback
);
2070 return (getBridgeInstance().set_property_change_callback_ptr(client
, WineBridge::prop_change
, arg
) == 0);
2072 return (getBridgeInstance().set_property_change_callback_ptr(client
, callback
, arg
) == 0);
2079 // -----------------------------------------------------------------------------