AudioWeakJack.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* runtime/weak dynamic JACK linking
  2. *
  3. * (C) 2014 Robin Gareus <robin@gareus.org>
  4. *
  5. * The wrapped jack API itself is
  6. * (C) 2001 Paul Davis
  7. * (C) 2004 Jack O'Quin
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2, or (at your option)
  12. * any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef _WEAK_JACK_H
  24. #define _WEAK_JACK_H
  25. // LMMS uses LMMS_HAVE_WEAKJACK instead
  26. #ifndef USE_WEAK_JACK
  27. #define USE_WEAK_JACK
  28. #endif
  29. // LMMS doesn't use metadata.h
  30. #ifndef NO_JACK_METADATA
  31. #define NO_JACK_METADATA
  32. #endif
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. /** check if libjack is available
  38. *
  39. * return 0 if libjack is dynamically linked of was
  40. * successfully dl-opened. Otherwise:
  41. *
  42. * -1: library was not initialized
  43. * -2: libjack was not found
  44. * > 0 bitwise flags:
  45. * 1: a required function was not found in libjack
  46. * 2: jack_client_open was not found in libjack
  47. */
  48. int have_libjack(void);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #ifdef USE_WEAK_JACK
  53. /* <jack/jack.h> */
  54. #define jack_client_close WJACK_client_close
  55. #define jack_get_client_name WJACK_get_client_name
  56. #define jack_get_sample_rate WJACK_get_sample_rate
  57. #define jack_get_buffer_size WJACK_get_buffer_size
  58. #define jack_frames_since_cycle_start WJACK_frames_since_cycle_start
  59. #define jack_frame_time WJACK_frame_time
  60. #define jack_last_frame_time WJACK_last_frame_time
  61. #define jack_get_time WJACK_get_time
  62. #define jack_cpu_load WJACK_cpu_load
  63. #define jack_is_realtime WJACK_is_realtime
  64. #define jack_client_name_size WJACK_client_name_size
  65. #define jack_set_freewheel WJACK_set_freewheel
  66. #define jack_set_buffer_size WJACK_set_buffer_size
  67. #define jack_on_shutdown WJACK_on_shutdown
  68. #define jack_on_info_shutdown WJACK_on_info_shutdown
  69. #define jack_set_process_callback WJACK_set_process_callback
  70. #define jack_set_freewheel_callback WJACK_set_freewheel_callback
  71. #define jack_set_buffer_size_callback WJACK_set_buffer_size_callback
  72. #define jack_set_sample_rate_callback WJACK_set_sample_rate_callback
  73. #define jack_set_port_registration_callback WJACK_set_port_registration_callback
  74. #define jack_set_port_connect_callback WJACK_set_port_connect_callback
  75. #define jack_set_graph_order_callback WJACK_set_graph_order_callback
  76. #define jack_set_xrun_callback WJACK_set_xrun_callback
  77. #define jack_set_latency_callback WJACK_set_latency_callback
  78. #define jack_set_error_function WJACK_set_error_function
  79. #define jack_set_info_function WJACK_set_info_function
  80. #define jack_activate WJACK_activate
  81. #define jack_deactivate WJACK_deactivate
  82. #define jack_recompute_total_latencies WJACK_recompute_total_latencies
  83. #define jack_port_get_total_latency WJACK_port_get_total_latency
  84. #define jack_port_get_latency_range WJACK_port_get_latency_range
  85. #define jack_port_set_latency_range WJACK_port_set_latency_range
  86. #define jack_port_get_buffer WJACK_port_get_buffer
  87. #define jack_port_request_monitor WJACK_port_request_monitor
  88. #define jack_port_ensure_monitor WJACK_port_ensure_monitor
  89. #define jack_port_monitoring_input WJACK_port_monitoring_input
  90. #define jack_port_name WJACK_port_name
  91. #define jack_port_short_name WJACK_port_short_name
  92. #define jack_port_flags WJACK_port_flags
  93. #define jack_get_ports WJACK_get_ports
  94. #define jack_port_name_size WJACK_port_name_size
  95. #define jack_port_type_size WJACK_port_type_size
  96. #define jack_port_type_get_buffer_size WJACK_port_type_get_buffer_size
  97. #define jack_port_by_name WJACK_port_by_name
  98. #define jack_port_by_id WJACK_port_by_id
  99. #define jack_port_set_name WJACK_port_set_name
  100. #define jack_port_get_aliases WJACK_port_get_aliases
  101. #define jack_port_rename WJACK_port_rename
  102. #define jack_port_disconnect WJACK_port_disconnect
  103. #define jack_port_register WJACK_port_register
  104. #define jack_port_unregister WJACK_port_unregister
  105. #define jack_port_type WJACK_port_type
  106. #define jack_port_get_connections WJACK_port_get_connections
  107. #define jack_port_get_all_connections WJACK_port_get_all_connections
  108. #define jack_connect WJACK_connect
  109. #define jack_disconnect WJACK_disconnect
  110. #define jack_free WJACK_free
  111. #define jack_cycle_wait WJACK_cycle_wait
  112. #define jack_cycle_signal WJACK_cycle_signal
  113. #define jack_set_process_thread WJACK_set_process_thread
  114. #define jack_set_thread_init_callback WJACK_set_thread_init_callback
  115. /* <jack/transport.h> */
  116. #define jack_get_current_transport_frame WJACK_get_current_transport_frame
  117. #define jack_transport_locate WJACK_transport_locate
  118. #define jack_transport_start WJACK_transport_start
  119. #define jack_transport_stop WJACK_transport_stop
  120. #define jack_transport_query WJACK_transport_query
  121. #define jack_set_sync_callback WJACK_set_sync_callback
  122. #define jack_set_timebase_callback WJACK_set_timebase_callback
  123. #define jack_release_timebase WJACK_release_timebase
  124. /* <jack/midiport.h> */
  125. #define jack_midi_get_event_count WJACK_midi_get_event_count
  126. #define jack_midi_event_get WJACK_midi_event_get
  127. #define jack_midi_event_write WJACK_midi_event_write
  128. #define jack_midi_clear_buffer WJACK_midi_clear_buffer
  129. /* <jack/session.h> */
  130. #define jack_set_session_callback WJACK_set_session_callback
  131. #define jack_session_reply WJACK_session_reply
  132. #define jack_session_event_free WJACK_session_event_free
  133. /* <jack/ringbuffer.h> */
  134. #define jack_ringbuffer_create WJACK_ringbuffer_create
  135. #define jack_ringbuffer_free WJACK_ringbuffer_free
  136. #define jack_ringbuffer_reset WJACK_ringbuffer_reset
  137. #define jack_ringbuffer_read_advance WJACK_ringbuffer_read_advance
  138. #define jack_ringbuffer_write_advance WJACK_ringbuffer_write_advance
  139. #define jack_ringbuffer_read_space WJACK_ringbuffer_read_space
  140. #define jack_ringbuffer_write_space WJACK_ringbuffer_write_space
  141. #define jack_ringbuffer_read WJACK_ringbuffer_read
  142. #define jack_ringbuffer_write WJACK_ringbuffer_write
  143. #define jack_ringbuffer_mlock WJACK_ringbuffer_mlock
  144. #define jack_ringbuffer_get_read_vector WJACK_ringbuffer_get_read_vector
  145. #define jack_ringbuffer_get_write_vector WJACK_ringbuffer_get_write_vector
  146. #define jack_ringbuffer_peek WJACK_ringbuffer_peek
  147. /* <jack/thread.h> */
  148. #define jack_client_real_time_priority WJACK_client_real_time_priority
  149. #define jack_client_max_real_time_priority WJACK_client_max_real_time_priority
  150. #define jack_acquire_real_time_scheduling WJACK_acquire_real_time_scheduling
  151. #define jack_client_create_thread WJACK_client_create_thread
  152. #define jack_drop_real_time_scheduling WJACK_drop_real_time_scheduling
  153. #define jack_client_stop_thread WJACK_client_stop_thread
  154. #define jack_client_kill_thread WJACK_client_kill_thread
  155. #define jack_set_thread_creator WJACK_set_thread_creator
  156. #define jack_client_open WJACK_client_client_openXXX
  157. #ifndef NO_JACK_METADATA
  158. /* <jack/metadata.h> */
  159. #define jack_get_uuid_for_client_name WJACK_get_uuid_for_client_name
  160. #define jack_get_client_name_by_uuid WJACK_get_client_name_by_uuid
  161. #define jack_port_uuid WJACK_port_uuid
  162. #define jack_set_property WJACK_set_property
  163. #define jack_get_property WJACK_get_property
  164. #define jack_free_description WJACK_free_description
  165. #define jack_get_properties WJACK_get_properties
  166. #define jack_get_all_properties WJACK_get_all_properties
  167. #define jack_remove_property WJACK_remove_property
  168. #define jack_remove_properties WJACK_remove_properties
  169. #define jack_remove_all_properties WJACK_remove_all_properties
  170. #define jack_set_property_change_callback WJACK_set_property_change_callback
  171. #endif
  172. /* <jack/statistics.h> */
  173. #define jack_get_max_delayed_usecs WJACK_get_max_delayed_usecs
  174. #define jack_get_xrun_delayed_usecs WJACK_get_xrun_delayed_usecs
  175. #define jack_reset_max_delayed_usecs WJACK_reset_max_delayed_usecs
  176. #endif // end USE_WEAK_JACK
  177. #include <jack/jack.h>
  178. #include <jack/transport.h>
  179. #include <jack/ringbuffer.h>
  180. #include <jack/midiport.h>
  181. #include <jack/session.h>
  182. #include <jack/thread.h>
  183. #ifndef NO_JACK_METADATA
  184. #include <jack/metadata.h>
  185. #endif
  186. #ifdef USE_WEAK_JACK
  187. #undef jack_client_open
  188. /* var-args hack */
  189. #ifdef __cplusplus
  190. extern "C" {
  191. #endif
  192. void (* WJACK_get_client_open (void)) (void);
  193. jack_client_t * WJACK_no_client_open (const char *client_name, jack_options_t options, jack_status_t *status, ...);
  194. #ifdef __cplusplus
  195. }
  196. #endif
  197. #define jack_client_open(...) \
  198. ( \
  199. (WJACK_get_client_open() != NULL) \
  200. ? ((jack_client_t* (*)(const char *, jack_options_t, jack_status_t *, ...))(WJACK_get_client_open()))(__VA_ARGS__) \
  201. : WJACK_no_client_open(__VA_ARGS__) \
  202. )
  203. #endif // end USE_WEAK_JACK
  204. #endif // _WEAK_JACK_H