jack2 codebase
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.

1879 lines
60KB

  1. /*
  2. Copyright (C) 2001-2003 Paul Davis
  3. Copyright (C) 2004-2008 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. #if defined(HAVE_CONFIG_H)
  17. #include "config.h"
  18. #endif
  19. #include "JackClient.h"
  20. #include "JackError.h"
  21. #include "JackGraphManager.h"
  22. #include "JackEngineControl.h"
  23. #include "JackClientControl.h"
  24. #include "JackGlobals.h"
  25. #include "JackTime.h"
  26. #include "JackCompilerDeps.h"
  27. #include "JackPortType.h"
  28. #include "JackPlatformPlug.h"
  29. #include <math.h>
  30. #ifdef __CLIENTDEBUG__
  31. #include "JackLibGlobals.h"
  32. #endif
  33. using namespace Jack;
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #endif
  38. typedef void (*print_function)(const char *);
  39. typedef void *(*thread_routine)(void*);
  40. EXPORT
  41. void
  42. jack_get_version(
  43. int *major_ptr,
  44. int *minor_ptr,
  45. int *micro_ptr,
  46. int *proto_ptr);
  47. EXPORT
  48. const char *
  49. jack_get_version_string();
  50. EXPORT jack_client_t * jack_client_open_aux (const char *client_name,
  51. jack_options_t options,
  52. jack_status_t *status, va_list ap);
  53. EXPORT jack_client_t * jack_client_open (const char *client_name,
  54. jack_options_t options,
  55. jack_status_t *status, ...);
  56. EXPORT jack_client_t * jack_client_new (const char *client_name);
  57. EXPORT int jack_client_name_size (void);
  58. EXPORT char* jack_get_client_name (jack_client_t *client);
  59. EXPORT int jack_internal_client_new (const char *client_name,
  60. const char *load_name,
  61. const char *load_init);
  62. EXPORT void jack_internal_client_close (const char *client_name);
  63. EXPORT int jack_is_realtime (jack_client_t *client);
  64. EXPORT void jack_on_shutdown (jack_client_t *client,
  65. JackShutdownCallback shutdown_callback, void *arg);
  66. EXPORT int jack_set_process_callback (jack_client_t *client,
  67. JackProcessCallback process_callback,
  68. void *arg);
  69. EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status);
  70. // new
  71. EXPORT jack_nframes_t jack_cycle_wait (jack_client_t*);
  72. EXPORT void jack_cycle_signal (jack_client_t*, int status);
  73. EXPORT int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg);
  74. EXPORT int jack_set_thread_init_callback (jack_client_t *client,
  75. JackThreadInitCallback thread_init_callback,
  76. void *arg);
  77. EXPORT int jack_set_freewheel_callback (jack_client_t *client,
  78. JackFreewheelCallback freewheel_callback,
  79. void *arg);
  80. EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
  81. EXPORT int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
  82. EXPORT int jack_set_buffer_size_callback (jack_client_t *client,
  83. JackBufferSizeCallback bufsize_callback,
  84. void *arg);
  85. EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
  86. JackSampleRateCallback srate_callback,
  87. void *arg);
  88. EXPORT int jack_set_client_registration_callback (jack_client_t *,
  89. JackClientRegistrationCallback
  90. registration_callback, void *arg);
  91. EXPORT int jack_set_port_registration_callback (jack_client_t *,
  92. JackPortRegistrationCallback
  93. registration_callback, void *arg);
  94. EXPORT int jack_set_port_connect_callback (jack_client_t *,
  95. JackPortConnectCallback
  96. connect_callback, void *arg);
  97. EXPORT int jack_set_port_rename_callback (jack_client_t *,
  98. JackPortRenameCallback
  99. rename_callback, void *arg);
  100. EXPORT int jack_set_graph_order_callback (jack_client_t *,
  101. JackGraphOrderCallback graph_callback,
  102. void *);
  103. EXPORT int jack_set_xrun_callback (jack_client_t *,
  104. JackXRunCallback xrun_callback, void *arg);
  105. EXPORT int jack_activate (jack_client_t *client);
  106. EXPORT int jack_deactivate (jack_client_t *client);
  107. EXPORT jack_port_t * jack_port_register (jack_client_t *client,
  108. const char *port_name,
  109. const char *port_type,
  110. unsigned long flags,
  111. unsigned long buffer_size);
  112. EXPORT int jack_port_unregister (jack_client_t *, jack_port_t *);
  113. EXPORT void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
  114. EXPORT const char * jack_port_name (const jack_port_t *port);
  115. EXPORT const char * jack_port_short_name (const jack_port_t *port);
  116. EXPORT int jack_port_flags (const jack_port_t *port);
  117. EXPORT const char * jack_port_type (const jack_port_t *port);
  118. EXPORT jack_port_type_id_t jack_port_type_id (const jack_port_t *port);
  119. EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
  120. EXPORT int jack_port_connected (const jack_port_t *port);
  121. EXPORT int jack_port_connected_to (const jack_port_t *port,
  122. const char *port_name);
  123. EXPORT const char ** jack_port_get_connections (const jack_port_t *port);
  124. EXPORT const char ** jack_port_get_all_connections (const jack_client_t *client,
  125. const jack_port_t *port);
  126. EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst);
  127. EXPORT int jack_port_untie (jack_port_t *port);
  128. EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port);
  129. EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *,
  130. jack_port_t *port);
  131. EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t);
  132. EXPORT int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
  133. EXPORT int jack_recompute_total_latencies (jack_client_t*);
  134. EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name);
  135. EXPORT int jack_port_set_alias (jack_port_t *port, const char *alias);
  136. EXPORT int jack_port_unset_alias (jack_port_t *port, const char *alias);
  137. EXPORT int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
  138. EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff);
  139. EXPORT int jack_port_request_monitor_by_name (jack_client_t *client,
  140. const char *port_name, int onoff);
  141. EXPORT int jack_port_ensure_monitor (jack_port_t *port, int onoff);
  142. EXPORT int jack_port_monitoring_input (jack_port_t *port);
  143. EXPORT int jack_connect (jack_client_t *,
  144. const char *source_port,
  145. const char *destination_port);
  146. EXPORT int jack_disconnect (jack_client_t *,
  147. const char *source_port,
  148. const char *destination_port);
  149. EXPORT int jack_port_disconnect (jack_client_t *, jack_port_t *);
  150. EXPORT int jack_port_name_size(void);
  151. EXPORT int jack_port_type_size(void);
  152. EXPORT jack_nframes_t jack_get_sample_rate (jack_client_t *);
  153. EXPORT jack_nframes_t jack_get_buffer_size (jack_client_t *);
  154. EXPORT const char ** jack_get_ports (jack_client_t *,
  155. const char *port_name_pattern,
  156. const char *type_name_pattern,
  157. unsigned long flags);
  158. EXPORT jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
  159. EXPORT jack_port_t * jack_port_by_id (jack_client_t *client,
  160. jack_port_id_t port_id);
  161. EXPORT int jack_engine_takeover_timebase (jack_client_t *);
  162. EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
  163. EXPORT jack_time_t jack_get_time();
  164. EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t time);
  165. EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames);
  166. EXPORT jack_nframes_t jack_frame_time (const jack_client_t *);
  167. EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client);
  168. EXPORT float jack_cpu_load (jack_client_t *client);
  169. EXPORT pthread_t jack_client_thread_id (jack_client_t *);
  170. EXPORT void jack_set_error_function (print_function);
  171. EXPORT void jack_set_info_function (print_function);
  172. EXPORT float jack_get_max_delayed_usecs (jack_client_t *client);
  173. EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client);
  174. EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client);
  175. EXPORT int jack_release_timebase (jack_client_t *client);
  176. EXPORT int jack_set_sync_callback (jack_client_t *client,
  177. JackSyncCallback sync_callback,
  178. void *arg);
  179. EXPORT int jack_set_sync_timeout (jack_client_t *client,
  180. jack_time_t timeout);
  181. EXPORT int jack_set_timebase_callback (jack_client_t *client,
  182. int conditional,
  183. JackTimebaseCallback timebase_callback,
  184. void *arg);
  185. EXPORT int jack_transport_locate (jack_client_t *client,
  186. jack_nframes_t frame);
  187. EXPORT jack_transport_state_t jack_transport_query (const jack_client_t *client,
  188. jack_position_t *pos);
  189. EXPORT jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
  190. EXPORT int jack_transport_reposition (jack_client_t *client,
  191. jack_position_t *pos);
  192. EXPORT void jack_transport_start (jack_client_t *client);
  193. EXPORT void jack_transport_stop (jack_client_t *client);
  194. EXPORT void jack_get_transport_info (jack_client_t *client,
  195. jack_transport_info_t *tinfo);
  196. EXPORT void jack_set_transport_info (jack_client_t *client,
  197. jack_transport_info_t *tinfo);
  198. EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
  199. EXPORT int jack_client_create_thread (jack_client_t* client,
  200. pthread_t *thread,
  201. int priority,
  202. int realtime, // boolean
  203. thread_routine routine,
  204. void *arg);
  205. EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
  206. EXPORT int jack_client_stop_thread(jack_client_t* client, pthread_t thread);
  207. EXPORT int jack_client_kill_thread(jack_client_t* client, pthread_t thread);
  208. EXPORT char * jack_get_internal_client_name (jack_client_t *client,
  209. jack_intclient_t intclient);
  210. EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client,
  211. const char *client_name,
  212. jack_status_t *status);
  213. EXPORT jack_intclient_t jack_internal_client_load (jack_client_t *client,
  214. const char *client_name,
  215. jack_options_t options,
  216. jack_status_t *status, ...);
  217. EXPORT jack_intclient_t jack_internal_client_load_aux (jack_client_t *client,
  218. const char *client_name,
  219. jack_options_t options,
  220. jack_status_t *status, va_list ap);
  221. EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
  222. jack_intclient_t intclient);
  223. #ifdef __cplusplus
  224. }
  225. #endif
  226. static inline bool CheckPort(jack_port_id_t port_index)
  227. {
  228. return (port_index > 0 && port_index < PORT_NUM);
  229. }
  230. static inline bool CheckBufferSize(jack_nframes_t buffer_size)
  231. {
  232. return (buffer_size <= BUFFER_SIZE_MAX);
  233. }
  234. static inline void WaitGraphChange()
  235. {
  236. /*
  237. TLS key that is set only in RT thread, so never waits for pending
  238. graph change in RT context (just read the current graph state).
  239. */
  240. if (jack_tls_get(gRealTime) == NULL) {
  241. JackGraphManager* manager = GetGraphManager();
  242. JackEngineControl* control = GetEngineControl();
  243. assert(manager);
  244. assert(control);
  245. if (manager->IsPendingChange()) {
  246. jack_log("WaitGraphChange...");
  247. JackSleep(int(control->fPeriodUsecs * 1.1f));
  248. }
  249. }
  250. }
  251. EXPORT void jack_set_error_function (print_function func)
  252. {
  253. jack_error_callback = func;
  254. }
  255. EXPORT void jack_set_info_function (print_function func)
  256. {
  257. jack_info_callback = func;
  258. }
  259. EXPORT jack_client_t* jack_client_new(const char* client_name)
  260. {
  261. jack_error("jack_client_new: deprecated");
  262. int options = JackUseExactName;
  263. if (getenv("JACK_START_SERVER") == NULL)
  264. options |= JackNoStartServer;
  265. return jack_client_open_aux(client_name, (jack_options_t)options, NULL, NULL);
  266. }
  267. EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
  268. {
  269. #ifdef __CLIENTDEBUG__
  270. JackLibGlobals::CheckContext();
  271. #endif
  272. #if defined(__x86_64__) || defined(__ppc64__)
  273. uint64_t port_aux = (uint64_t)port;
  274. #else
  275. uint32_t port_aux = (uint32_t)port;
  276. #endif
  277. jack_port_id_t myport = (jack_port_id_t)port_aux;
  278. if (!CheckPort(myport)) {
  279. jack_error("jack_port_get_buffer called with an incorrect port %ld", myport);
  280. return NULL;
  281. } else {
  282. JackGraphManager* manager = GetGraphManager();
  283. return (manager ? manager->GetBuffer(myport, frames) : NULL);
  284. }
  285. }
  286. EXPORT const char* jack_port_name(const jack_port_t* port)
  287. {
  288. #ifdef __CLIENTDEBUG__
  289. JackLibGlobals::CheckContext();
  290. #endif
  291. #if defined(__x86_64__) || defined(__ppc64__)
  292. uint64_t port_aux = (uint64_t)port;
  293. #else
  294. uint32_t port_aux = (uint32_t)port;
  295. #endif
  296. jack_port_id_t myport = (jack_port_id_t)port_aux;
  297. if (!CheckPort(myport)) {
  298. jack_error("jack_port_name called with an incorrect port %ld", myport);
  299. return NULL;
  300. } else {
  301. JackGraphManager* manager = GetGraphManager();
  302. return (manager ? manager->GetPort(myport)->GetName() : NULL);
  303. }
  304. }
  305. EXPORT const char* jack_port_short_name(const jack_port_t* port)
  306. {
  307. #ifdef __CLIENTDEBUG__
  308. JackLibGlobals::CheckContext();
  309. #endif
  310. #if defined(__x86_64__) || defined(__ppc64__)
  311. uint64_t port_aux = (uint64_t)port;
  312. #else
  313. uint32_t port_aux = (uint32_t)port;
  314. #endif
  315. jack_port_id_t myport = (jack_port_id_t)port_aux;
  316. if (!CheckPort(myport)) {
  317. jack_error("jack_port_short_name called with an incorrect port %ld", myport);
  318. return NULL;
  319. } else {
  320. JackGraphManager* manager = GetGraphManager();
  321. return (manager ? manager->GetPort(myport)->GetShortName() : NULL);
  322. }
  323. }
  324. EXPORT int jack_port_flags(const jack_port_t* port)
  325. {
  326. #ifdef __CLIENTDEBUG__
  327. JackLibGlobals::CheckContext();
  328. #endif
  329. #if defined(__x86_64__) || defined(__ppc64__)
  330. uint64_t port_aux = (uint64_t)port;
  331. #else
  332. uint32_t port_aux = (uint32_t)port;
  333. #endif
  334. jack_port_id_t myport = (jack_port_id_t)port_aux;
  335. if (!CheckPort(myport)) {
  336. jack_error("jack_port_flags called with an incorrect port %ld", myport);
  337. return -1;
  338. } else {
  339. JackGraphManager* manager = GetGraphManager();
  340. return (manager ? manager->GetPort(myport)->GetFlags() : -1);
  341. }
  342. }
  343. EXPORT const char* jack_port_type(const jack_port_t* port)
  344. {
  345. #ifdef __CLIENTDEBUG__
  346. JackLibGlobals::CheckContext();
  347. #endif
  348. #if defined(__x86_64__) || defined(__ppc64__)
  349. uint64_t port_aux = (uint64_t)port;
  350. #else
  351. uint32_t port_aux = (uint32_t)port;
  352. #endif
  353. jack_port_id_t myport = (jack_port_id_t)port_aux;
  354. if (!CheckPort(myport)) {
  355. jack_error("jack_port_flags called an incorrect port %ld", myport);
  356. return NULL;
  357. } else {
  358. JackGraphManager* manager = GetGraphManager();
  359. return (manager ? manager->GetPort(myport)->GetType() : NULL);
  360. }
  361. }
  362. EXPORT jack_port_type_id_t jack_port_type_id (const jack_port_t *port)
  363. {
  364. #ifdef __CLIENTDEBUG__
  365. JackLibGlobals::CheckContext();
  366. #endif
  367. #if defined(__x86_64__) || defined(__ppc64__)
  368. uint64_t port_aux = (uint64_t)port;
  369. #else
  370. uint32_t port_aux = (uint32_t)port;
  371. #endif
  372. jack_port_id_t myport = (jack_port_id_t)port_aux;
  373. if (!CheckPort(myport)) {
  374. jack_error("jack_port_type_id called an incorrect port %ld", myport);
  375. return 0;
  376. } else {
  377. JackGraphManager* manager = GetGraphManager();
  378. return (manager ? GetPortTypeId(manager->GetPort(myport)->GetType()) : 0);
  379. }
  380. }
  381. EXPORT int jack_port_connected(const jack_port_t* port)
  382. {
  383. #ifdef __CLIENTDEBUG__
  384. JackLibGlobals::CheckContext();
  385. #endif
  386. #if defined(__x86_64__) || defined(__ppc64__)
  387. uint64_t port_aux = (uint64_t)port;
  388. #else
  389. uint32_t port_aux = (uint32_t)port;
  390. #endif
  391. jack_port_id_t myport = (jack_port_id_t)port_aux;
  392. if (!CheckPort(myport)) {
  393. jack_error("jack_port_connected called with an incorrect port %ld", myport);
  394. return -1;
  395. } else {
  396. WaitGraphChange();
  397. JackGraphManager* manager = GetGraphManager();
  398. return (manager ? manager->GetConnectionsNum(myport) : -1);
  399. }
  400. }
  401. EXPORT int jack_port_connected_to(const jack_port_t* port, const char* port_name)
  402. {
  403. #ifdef __CLIENTDEBUG__
  404. JackLibGlobals::CheckContext();
  405. #endif
  406. #if defined(__x86_64__) || defined(__ppc64__)
  407. uint64_t port_aux = (uint64_t)port;
  408. #else
  409. uint32_t port_aux = (uint32_t)port;
  410. #endif
  411. jack_port_id_t src = (jack_port_id_t)port_aux;
  412. if (!CheckPort(src)) {
  413. jack_error("jack_port_connected_to called with an incorrect port %ld", src);
  414. return -1;
  415. } else if (port_name == NULL) {
  416. jack_error("jack_port_connected_to called with a NULL port name");
  417. return -1;
  418. } else {
  419. WaitGraphChange();
  420. JackGraphManager* manager = GetGraphManager();
  421. jack_port_id_t dst = (manager ? manager->GetPort(port_name) : NO_PORT);
  422. if (dst == NO_PORT) {
  423. jack_error("Unknown destination port port_name = %s", port_name);
  424. return 0;
  425. } else {
  426. return manager->IsConnected(src, dst);
  427. }
  428. }
  429. }
  430. EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
  431. {
  432. #ifdef __CLIENTDEBUG__
  433. JackLibGlobals::CheckContext();
  434. #endif
  435. #if defined(__x86_64__) || defined(__ppc64__)
  436. uint64_t src_aux = (uint64_t)src;
  437. #else
  438. uint32_t src_aux = (uint32_t)src;
  439. #endif
  440. jack_port_id_t mysrc = (jack_port_id_t)src_aux;
  441. if (!CheckPort(mysrc)) {
  442. jack_error("jack_port_tie called with a NULL src port");
  443. return -1;
  444. }
  445. #if defined(__x86_64__) || defined(__ppc64__)
  446. uint64_t dst_aux = (uint64_t)dst;
  447. #else
  448. uint32_t dst_aux = (uint32_t)dst;
  449. #endif
  450. jack_port_id_t mydst = (jack_port_id_t)dst_aux;
  451. if (!CheckPort(mydst)) {
  452. jack_error("jack_port_tie called with a NULL dst port");
  453. return -1;
  454. }
  455. JackGraphManager* manager = GetGraphManager();
  456. if (manager && manager->GetPort(mysrc)->GetRefNum() != manager->GetPort(mydst)->GetRefNum()) {
  457. jack_error("jack_port_tie called with ports not belonging to the same client");
  458. return -1;
  459. } else {
  460. return manager->GetPort(mydst)->Tie(mysrc);
  461. }
  462. }
  463. EXPORT int jack_port_untie(jack_port_t* port)
  464. {
  465. #ifdef __CLIENTDEBUG__
  466. JackLibGlobals::CheckContext();
  467. #endif
  468. #if defined(__x86_64__) || defined(__ppc64__)
  469. uint64_t port_aux = (uint64_t)port;
  470. #else
  471. uint32_t port_aux = (uint32_t)port;
  472. #endif
  473. jack_port_id_t myport = (jack_port_id_t)port_aux;
  474. if (!CheckPort(myport)) {
  475. jack_error("jack_port_untie called with an incorrect port %ld", myport);
  476. return -1;
  477. } else {
  478. JackGraphManager* manager = GetGraphManager();
  479. return (manager ? manager->GetPort(myport)->UnTie() : -1);
  480. }
  481. }
  482. EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
  483. {
  484. #ifdef __CLIENTDEBUG__
  485. JackLibGlobals::CheckContext();
  486. #endif
  487. #if defined(__x86_64__) || defined(__ppc64__)
  488. uint64_t port_aux = (uint64_t)port;
  489. #else
  490. uint32_t port_aux = (uint32_t)port;
  491. #endif
  492. jack_port_id_t myport = (jack_port_id_t)port_aux;
  493. if (!CheckPort(myport)) {
  494. jack_error("jack_port_get_latency called with an incorrect port %ld", myport);
  495. return 0;
  496. } else {
  497. WaitGraphChange();
  498. JackGraphManager* manager = GetGraphManager();
  499. return (manager ? manager->GetPort(myport)->GetLatency() : 0);
  500. }
  501. }
  502. EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
  503. {
  504. #ifdef __CLIENTDEBUG__
  505. JackLibGlobals::CheckContext();
  506. #endif
  507. #if defined(__x86_64__) || defined(__ppc64__)
  508. uint64_t port_aux = (uint64_t)port;
  509. #else
  510. uint32_t port_aux = (uint32_t)port;
  511. #endif
  512. jack_port_id_t myport = (jack_port_id_t)port_aux;
  513. if (!CheckPort(myport)) {
  514. jack_error("jack_port_set_latency called with an incorrect port %ld", myport);
  515. } else {
  516. JackGraphManager* manager = GetGraphManager();
  517. if (manager)
  518. manager->GetPort(myport)->SetLatency(frames);
  519. }
  520. }
  521. EXPORT int jack_recompute_total_latency(jack_client_t* ext_client, jack_port_t* port)
  522. {
  523. #ifdef __CLIENTDEBUG__
  524. JackLibGlobals::CheckContext();
  525. #endif
  526. JackClient* client = (JackClient*)ext_client;
  527. #if defined(__x86_64__) || defined(__ppc64__)
  528. uint64_t port_aux = (uint64_t)port;
  529. #else
  530. uint32_t port_aux = (uint32_t)port;
  531. #endif
  532. jack_port_id_t myport = (jack_port_id_t)port_aux;
  533. if (client == NULL) {
  534. jack_error("jack_recompute_total_latencies called with a NULL client");
  535. return -1;
  536. } else if (!CheckPort(myport)) {
  537. jack_error("jack_recompute_total_latencies called with a NULL port");
  538. return -1;
  539. } else {
  540. WaitGraphChange();
  541. JackGraphManager* manager = GetGraphManager();
  542. return (manager ? manager->ComputeTotalLatency(myport) : -1);
  543. }
  544. }
  545. EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
  546. {
  547. #ifdef __CLIENTDEBUG__
  548. JackLibGlobals::CheckContext();
  549. #endif
  550. JackClient* client = (JackClient*)ext_client;
  551. if (client == NULL) {
  552. jack_error("jack_recompute_total_latencies called with a NULL client");
  553. return -1;
  554. } else {
  555. WaitGraphChange();
  556. JackGraphManager* manager = GetGraphManager();
  557. return (manager ? manager->ComputeTotalLatencies() : -1);
  558. }
  559. }
  560. /*
  561. This is unsafe if case of concurrent access, and should be "serialized" doing a server call.
  562. */
  563. EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
  564. {
  565. #ifdef __CLIENTDEBUG__
  566. JackLibGlobals::CheckContext();
  567. #endif
  568. #if defined(__x86_64__) || defined(__ppc64__)
  569. uint64_t port_aux = (uint64_t)port;
  570. #else
  571. uint32_t port_aux = (uint32_t)port;
  572. #endif
  573. jack_port_id_t myport = (jack_port_id_t)port_aux;
  574. if (!CheckPort(myport)) {
  575. jack_error("jack_port_set_name called with an incorrect port %ld", myport);
  576. return -1;
  577. } else if (name == NULL) {
  578. jack_error("jack_port_set_name called with a NULL port name");
  579. return -1;
  580. } else {
  581. JackGraphManager* manager = GetGraphManager();
  582. int refnum;
  583. if (manager && ((refnum = manager->GetPort(myport)->GetRefNum()) > 0)) {
  584. JackClient* client = JackClient::fClientTable[refnum];
  585. assert(client);
  586. return client->PortRename(myport, name);
  587. } else {
  588. return -1;
  589. }
  590. }
  591. }
  592. EXPORT int jack_port_set_alias(jack_port_t* port, const char* name)
  593. {
  594. #ifdef __CLIENTDEBUG__
  595. JackLibGlobals::CheckContext();
  596. #endif
  597. #if defined(__x86_64__) || defined(__ppc64__)
  598. uint64_t port_aux = (uint64_t)port;
  599. #else
  600. uint32_t port_aux = (uint32_t)port;
  601. #endif
  602. jack_port_id_t myport = (jack_port_id_t)port_aux;
  603. if (!CheckPort(myport)) {
  604. jack_error("jack_port_set_alias called with an incorrect port %ld", myport);
  605. return -1;
  606. } else if (name == NULL) {
  607. jack_error("jack_port_set_alias called with a NULL port name");
  608. return -1;
  609. } else {
  610. JackGraphManager* manager = GetGraphManager();
  611. return (manager ? manager->GetPort(myport)->SetAlias(name) : -1);
  612. }
  613. }
  614. EXPORT int jack_port_unset_alias(jack_port_t* port, const char* name)
  615. {
  616. #ifdef __CLIENTDEBUG__
  617. JackLibGlobals::CheckContext();
  618. #endif
  619. #if defined(__x86_64__) || defined(__ppc64__)
  620. uint64_t port_aux = (uint64_t)port;
  621. #else
  622. uint32_t port_aux = (uint32_t)port;
  623. #endif
  624. jack_port_id_t myport = (jack_port_id_t)port_aux;
  625. if (!CheckPort(myport)) {
  626. jack_error("jack_port_unset_alias called with an incorrect port %ld", myport);
  627. return -1;
  628. } else if (name == NULL) {
  629. jack_error("jack_port_unset_alias called with a NULL port name");
  630. return -1;
  631. } else {
  632. JackGraphManager* manager = GetGraphManager();
  633. return (manager ? manager->GetPort(myport)->UnsetAlias(name) : -1);
  634. }
  635. }
  636. EXPORT int jack_port_get_aliases(const jack_port_t* port, char* const aliases[2])
  637. {
  638. #ifdef __CLIENTDEBUG__
  639. JackLibGlobals::CheckContext();
  640. #endif
  641. #if defined(__x86_64__) || defined(__ppc64__)
  642. uint64_t port_aux = (uint64_t)port;
  643. #else
  644. uint32_t port_aux = (uint32_t)port;
  645. #endif
  646. jack_port_id_t myport = (jack_port_id_t)port_aux;
  647. if (!CheckPort(myport)) {
  648. jack_error("jack_port_get_aliases called with an incorrect port %ld", myport);
  649. return -1;
  650. } else {
  651. JackGraphManager* manager = GetGraphManager();
  652. return (manager ? manager->GetPort(myport)->GetAliases(aliases) : -1);
  653. }
  654. }
  655. EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
  656. {
  657. #ifdef __CLIENTDEBUG__
  658. JackLibGlobals::CheckContext();
  659. #endif
  660. #if defined(__x86_64__) || defined(__ppc64__)
  661. uint64_t port_aux = (uint64_t)port;
  662. #else
  663. uint32_t port_aux = (uint32_t)port;
  664. #endif
  665. jack_port_id_t myport = (jack_port_id_t)port_aux;
  666. if (!CheckPort(myport)) {
  667. jack_error("jack_port_request_monitor called with an incorrect port %ld", myport);
  668. return -1;
  669. } else {
  670. JackGraphManager* manager = GetGraphManager();
  671. return (manager ? manager->RequestMonitor(myport, onoff) : -1);
  672. }
  673. }
  674. EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
  675. {
  676. #ifdef __CLIENTDEBUG__
  677. JackLibGlobals::CheckContext();
  678. #endif
  679. JackClient* client = (JackClient*)ext_client;
  680. if (client == NULL) {
  681. jack_error("jack_port_request_monitor_by_name called with a NULL client");
  682. return -1;
  683. } else {
  684. JackGraphManager* manager = GetGraphManager();
  685. if (!manager)
  686. return -1;
  687. jack_port_id_t myport = manager->GetPort(port_name);
  688. if (!CheckPort(myport)) {
  689. jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
  690. return -1;
  691. } else {
  692. return manager->RequestMonitor(myport, onoff);
  693. }
  694. }
  695. }
  696. EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
  697. {
  698. #ifdef __CLIENTDEBUG__
  699. JackLibGlobals::CheckContext();
  700. #endif
  701. #if defined(__x86_64__) || defined(__ppc64__)
  702. uint64_t port_aux = (uint64_t)port;
  703. #else
  704. uint32_t port_aux = (uint32_t)port;
  705. #endif
  706. jack_port_id_t myport = (jack_port_id_t)port_aux;
  707. if (!CheckPort(myport)) {
  708. jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport);
  709. return -1;
  710. } else {
  711. JackGraphManager* manager = GetGraphManager();
  712. return (manager ? manager->GetPort(myport)->EnsureMonitor(onoff) : -1);
  713. }
  714. }
  715. EXPORT int jack_port_monitoring_input(jack_port_t* port)
  716. {
  717. #ifdef __CLIENTDEBUG__
  718. JackLibGlobals::CheckContext();
  719. #endif
  720. #if defined(__x86_64__) || defined(__ppc64__)
  721. uint64_t port_aux = (uint64_t)port;
  722. #else
  723. uint32_t port_aux = (uint32_t)port;
  724. #endif
  725. jack_port_id_t myport = (jack_port_id_t)port_aux;
  726. if (!CheckPort(myport)) {
  727. jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport);
  728. return -1;
  729. } else {
  730. JackGraphManager* manager = GetGraphManager();
  731. return (manager ? manager->GetPort(myport)->MonitoringInput() : -1);
  732. }
  733. }
  734. EXPORT int jack_is_realtime(jack_client_t* ext_client)
  735. {
  736. #ifdef __CLIENTDEBUG__
  737. JackLibGlobals::CheckContext();
  738. #endif
  739. JackClient* client = (JackClient*)ext_client;
  740. if (client == NULL) {
  741. jack_error("jack_is_realtime called with a NULL client");
  742. return -1;
  743. } else {
  744. JackEngineControl* control = GetEngineControl();
  745. return (control ? control->fRealTime : -1);
  746. }
  747. }
  748. EXPORT void jack_on_shutdown(jack_client_t* ext_client, JackShutdownCallback callback, void* arg)
  749. {
  750. #ifdef __CLIENTDEBUG__
  751. JackLibGlobals::CheckContext();
  752. #endif
  753. JackClient* client = (JackClient*)ext_client;
  754. if (client == NULL) {
  755. jack_error("jack_on_shutdown called with a NULL client");
  756. } else {
  757. client->OnShutdown(callback, arg);
  758. }
  759. }
  760. EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
  761. {
  762. #ifdef __CLIENTDEBUG__
  763. JackLibGlobals::CheckContext();
  764. #endif
  765. JackClient* client = (JackClient*)ext_client;
  766. if (client == NULL) {
  767. jack_error("jack_set_process_callback called with a NULL client");
  768. return -1;
  769. } else {
  770. return client->SetProcessCallback(callback, arg);
  771. }
  772. }
  773. EXPORT jack_nframes_t jack_thread_wait(jack_client_t* ext_client, int status)
  774. {
  775. #ifdef __CLIENTDEBUG__
  776. JackLibGlobals::CheckContext();
  777. #endif
  778. JackClient* client = (JackClient*)ext_client;
  779. if (client == NULL) {
  780. jack_error("jack_thread_wait called with a NULL client");
  781. return 0;
  782. } else {
  783. return client->Wait(status);
  784. }
  785. }
  786. EXPORT jack_nframes_t jack_cycle_wait(jack_client_t* ext_client)
  787. {
  788. #ifdef __CLIENTDEBUG__
  789. JackLibGlobals::CheckContext();
  790. #endif
  791. JackClient* client = (JackClient*)ext_client;
  792. if (client == NULL) {
  793. jack_error("jack_cycle_wait called with a NULL client");
  794. return 0;
  795. } else {
  796. return client->CycleWait();
  797. }
  798. }
  799. EXPORT void jack_cycle_signal(jack_client_t* ext_client, int status)
  800. {
  801. #ifdef __CLIENTDEBUG__
  802. JackLibGlobals::CheckContext();
  803. #endif
  804. JackClient* client = (JackClient*)ext_client;
  805. if (client == NULL) {
  806. jack_error("jack_cycle_signal called with a NULL client");
  807. } else {
  808. client->CycleSignal(status);
  809. }
  810. }
  811. EXPORT int jack_set_process_thread(jack_client_t* ext_client, JackThreadCallback fun, void *arg)
  812. {
  813. #ifdef __CLIENTDEBUG__
  814. JackLibGlobals::CheckContext();
  815. #endif
  816. JackClient* client = (JackClient*)ext_client;
  817. if (client == NULL) {
  818. jack_error("jack_set_process_thread called with a NULL client");
  819. return -1;
  820. } else {
  821. return client->SetProcessThread(fun, arg);
  822. }
  823. }
  824. EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
  825. {
  826. #ifdef __CLIENTDEBUG__
  827. JackLibGlobals::CheckContext();
  828. #endif
  829. JackClient* client = (JackClient*)ext_client;
  830. if (client == NULL) {
  831. jack_error("jack_set_freewheel_callback called with a NULL client");
  832. return -1;
  833. } else {
  834. return client->SetFreewheelCallback(freewheel_callback, arg);
  835. }
  836. }
  837. EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
  838. {
  839. #ifdef __CLIENTDEBUG__
  840. JackLibGlobals::CheckContext();
  841. #endif
  842. JackClient* client = (JackClient*)ext_client;
  843. if (client == NULL) {
  844. jack_error("jack_set_freewheel called with a NULL client");
  845. return -1;
  846. } else {
  847. return client->SetFreeWheel(onoff);
  848. }
  849. }
  850. EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
  851. {
  852. #ifdef __CLIENTDEBUG__
  853. JackLibGlobals::CheckContext();
  854. #endif
  855. JackClient* client = (JackClient*)ext_client;
  856. if (client == NULL) {
  857. jack_error("jack_set_buffer_size called with a NULL client");
  858. return -1;
  859. } else if (!CheckBufferSize(buffer_size)) {
  860. return -1;
  861. } else {
  862. return client->SetBufferSize(buffer_size);
  863. }
  864. }
  865. EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
  866. {
  867. #ifdef __CLIENTDEBUG__
  868. JackLibGlobals::CheckContext();
  869. #endif
  870. JackClient* client = (JackClient*)ext_client;
  871. if (client == NULL) {
  872. jack_error("jack_set_buffer_size_callback called with a NULL client");
  873. return -1;
  874. } else {
  875. return client->SetBufferSizeCallback(bufsize_callback, arg);
  876. }
  877. }
  878. EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
  879. {
  880. #ifdef __CLIENTDEBUG__
  881. JackLibGlobals::CheckContext();
  882. #endif
  883. JackClient* client = (JackClient*)ext_client;
  884. if (client == NULL) {
  885. jack_error("jack_set_sample_rate_callback called with a NULL client");
  886. return -1;
  887. } else {
  888. return client->SetSampleRateCallback(srate_callback, arg);
  889. }
  890. }
  891. EXPORT int jack_set_client_registration_callback(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg)
  892. {
  893. #ifdef __CLIENTDEBUG__
  894. JackLibGlobals::CheckContext();
  895. #endif
  896. JackClient* client = (JackClient*)ext_client;
  897. if (client == NULL) {
  898. jack_error("jack_set_client_registration_callback called with a NULL client");
  899. return -1;
  900. } else {
  901. return client->SetClientRegistrationCallback(registration_callback, arg);
  902. }
  903. }
  904. EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
  905. {
  906. #ifdef __CLIENTDEBUG__
  907. JackLibGlobals::CheckContext();
  908. #endif
  909. JackClient* client = (JackClient*)ext_client;
  910. if (client == NULL) {
  911. jack_error("jack_set_port_registration_callback called with a NULL client");
  912. return -1;
  913. } else {
  914. return client->SetPortRegistrationCallback(registration_callback, arg);
  915. }
  916. }
  917. EXPORT int jack_set_port_connect_callback(jack_client_t* ext_client, JackPortConnectCallback portconnect_callback, void* arg)
  918. {
  919. #ifdef __CLIENTDEBUG__
  920. JackLibGlobals::CheckContext();
  921. #endif
  922. JackClient* client = (JackClient*)ext_client;
  923. if (client == NULL) {
  924. jack_error("jack_set_port_connect_callback called with a NULL client");
  925. return -1;
  926. } else {
  927. return client->SetPortConnectCallback(portconnect_callback, arg);
  928. }
  929. }
  930. EXPORT int jack_set_port_rename_callback(jack_client_t* ext_client, JackPortRenameCallback rename_callback, void* arg)
  931. {
  932. #ifdef __CLIENTDEBUG__
  933. JackLibGlobals::CheckContext();
  934. #endif
  935. JackClient* client = (JackClient*)ext_client;
  936. if (client == NULL) {
  937. jack_error("jack_set_port_rename_callback called with a NULL client");
  938. return -1;
  939. } else {
  940. return client->SetPortRenameCallback(rename_callback, arg);
  941. }
  942. }
  943. EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
  944. {
  945. #ifdef __CLIENTDEBUG__
  946. JackLibGlobals::CheckContext();
  947. #endif
  948. JackClient* client = (JackClient*)ext_client;
  949. jack_log("jack_set_graph_order_callback ext_client %x client %x ", ext_client, client);
  950. if (client == NULL) {
  951. jack_error("jack_set_graph_order_callback called with a NULL client");
  952. return -1;
  953. } else {
  954. return client->SetGraphOrderCallback(graph_callback, arg);
  955. }
  956. }
  957. EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
  958. {
  959. #ifdef __CLIENTDEBUG__
  960. JackLibGlobals::CheckContext();
  961. #endif
  962. JackClient* client = (JackClient*)ext_client;
  963. if (client == NULL) {
  964. jack_error("jack_set_xrun_callback called with a NULL client");
  965. return -1;
  966. } else {
  967. return client->SetXRunCallback(xrun_callback, arg);
  968. }
  969. }
  970. EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
  971. {
  972. #ifdef __CLIENTDEBUG__
  973. JackLibGlobals::CheckContext();
  974. #endif
  975. JackClient* client = (JackClient*)ext_client;
  976. jack_log("jack_set_thread_init_callback ext_client %x client %x ", ext_client, client);
  977. if (client == NULL) {
  978. jack_error("jack_set_thread_init_callback called with a NULL client");
  979. return -1;
  980. } else {
  981. return client->SetInitCallback(init_callback, arg);
  982. }
  983. }
  984. EXPORT int jack_activate(jack_client_t* ext_client)
  985. {
  986. #ifdef __CLIENTDEBUG__
  987. JackLibGlobals::CheckContext();
  988. #endif
  989. JackClient* client = (JackClient*)ext_client;
  990. if (client == NULL) {
  991. jack_error("jack_activate called with a NULL client");
  992. return -1;
  993. } else {
  994. return client->Activate();
  995. }
  996. }
  997. EXPORT int jack_deactivate(jack_client_t* ext_client)
  998. {
  999. #ifdef __CLIENTDEBUG__
  1000. JackLibGlobals::CheckContext();
  1001. #endif
  1002. JackClient* client = (JackClient*)ext_client;
  1003. if (client == NULL) {
  1004. jack_error("jack_deactivate called with a NULL client");
  1005. return -1;
  1006. } else {
  1007. return client->Deactivate();
  1008. }
  1009. }
  1010. EXPORT jack_port_t* jack_port_register(jack_client_t* ext_client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size)
  1011. {
  1012. #ifdef __CLIENTDEBUG__
  1013. JackLibGlobals::CheckContext();
  1014. #endif
  1015. JackClient* client = (JackClient*)ext_client;
  1016. if (client == NULL) {
  1017. jack_error("jack_port_register called with a NULL client");
  1018. return NULL;
  1019. } else if ((port_name == NULL) || (port_type == NULL)) {
  1020. jack_error("jack_port_register called with a NULL port name or a NULL port_type");
  1021. return NULL;
  1022. } else {
  1023. return (jack_port_t *)client->PortRegister(port_name, port_type, flags, buffer_size);
  1024. }
  1025. }
  1026. EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port)
  1027. {
  1028. #ifdef __CLIENTDEBUG__
  1029. JackLibGlobals::CheckContext();
  1030. #endif
  1031. JackClient* client = (JackClient*)ext_client;
  1032. if (client == NULL) {
  1033. jack_error("jack_port_unregister called with a NULL client");
  1034. return -1;
  1035. }
  1036. #if defined(__x86_64__) || defined(__ppc64__)
  1037. uint64_t port_aux = (uint64_t)port;
  1038. #else
  1039. uint32_t port_aux = (uint32_t)port;
  1040. #endif
  1041. jack_port_id_t myport = (jack_port_id_t)port_aux;
  1042. if (!CheckPort(myport)) {
  1043. jack_error("jack_port_unregister called with an incorrect port %ld", myport);
  1044. return -1;
  1045. }
  1046. return client->PortUnRegister(myport);
  1047. }
  1048. EXPORT int jack_port_is_mine(const jack_client_t* ext_client, const jack_port_t* port)
  1049. {
  1050. #ifdef __CLIENTDEBUG__
  1051. JackLibGlobals::CheckContext();
  1052. #endif
  1053. JackClient* client = (JackClient*)ext_client;
  1054. if (client == NULL) {
  1055. jack_error("jack_port_is_mine called with a NULL client");
  1056. return -1;
  1057. }
  1058. #if defined(__x86_64__) || defined(__ppc64__)
  1059. uint64_t port_aux = (uint64_t)port;
  1060. #else
  1061. uint32_t port_aux = (uint32_t)port;
  1062. #endif
  1063. jack_port_id_t myport = (jack_port_id_t)port_aux;
  1064. if (!CheckPort(myport)) {
  1065. jack_error("jack_port_is_mine called with an incorrect port %ld", myport);
  1066. return -1;
  1067. }
  1068. return client->PortIsMine(myport);
  1069. }
  1070. EXPORT const char** jack_port_get_connections(const jack_port_t* port)
  1071. {
  1072. #ifdef __CLIENTDEBUG__
  1073. JackLibGlobals::CheckContext();
  1074. #endif
  1075. #if defined(__x86_64__) || defined(__ppc64__)
  1076. uint64_t port_aux = (uint64_t)port;
  1077. #else
  1078. uint32_t port_aux = (uint32_t)port;
  1079. #endif
  1080. jack_port_id_t myport = (jack_port_id_t)port_aux;
  1081. if (!CheckPort(myport)) {
  1082. jack_error("jack_port_get_connections called with an incorrect port %ld", myport);
  1083. return NULL;
  1084. } else {
  1085. WaitGraphChange();
  1086. JackGraphManager* manager = GetGraphManager();
  1087. return (manager ? manager->GetConnections(myport) : NULL);
  1088. }
  1089. }
  1090. // Calling client does not need to "own" the port
  1091. EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_client, const jack_port_t* port)
  1092. {
  1093. #ifdef __CLIENTDEBUG__
  1094. JackLibGlobals::CheckContext();
  1095. #endif
  1096. JackClient* client = (JackClient*)ext_client;
  1097. if (client == NULL) {
  1098. jack_error("jack_port_get_all_connections called with a NULL client");
  1099. return NULL;
  1100. }
  1101. #if defined(__x86_64__) || defined(__ppc64__)
  1102. uint64_t port_aux = (uint64_t)port;
  1103. #else
  1104. uint32_t port_aux = (uint32_t)port;
  1105. #endif
  1106. jack_port_id_t myport = (jack_port_id_t)port_aux;
  1107. if (!CheckPort(myport)) {
  1108. jack_error("jack_port_get_all_connections called with an incorrect port %ld", myport);
  1109. return NULL;
  1110. } else {
  1111. WaitGraphChange();
  1112. JackGraphManager* manager = GetGraphManager();
  1113. return (manager ? manager->GetConnections(myport) : NULL);
  1114. }
  1115. }
  1116. EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port)
  1117. {
  1118. #ifdef __CLIENTDEBUG__
  1119. JackLibGlobals::CheckContext();
  1120. #endif
  1121. JackClient* client = (JackClient*)ext_client;
  1122. if (client == NULL) {
  1123. jack_error("jack_port_get_total_latency called with a NULL client");
  1124. return 0;
  1125. }
  1126. #if defined(__x86_64__) || defined(__ppc64__)
  1127. uint64_t port_aux = (uint64_t)port;
  1128. #else
  1129. uint32_t port_aux = (uint32_t)port;
  1130. #endif
  1131. jack_port_id_t myport = (jack_port_id_t)port_aux;
  1132. if (!CheckPort(myport)) {
  1133. jack_error("jack_port_get_total_latency called with an incorrect port %ld", myport);
  1134. return 0;
  1135. } else {
  1136. WaitGraphChange();
  1137. JackGraphManager* manager = GetGraphManager();
  1138. if (manager) {
  1139. manager->ComputeTotalLatency(myport);
  1140. return manager->GetPort(myport)->GetTotalLatency();
  1141. } else {
  1142. return 0;
  1143. }
  1144. }
  1145. }
  1146. EXPORT int jack_connect(jack_client_t* ext_client, const char* src, const char* dst)
  1147. {
  1148. #ifdef __CLIENTDEBUG__
  1149. JackLibGlobals::CheckContext();
  1150. #endif
  1151. JackClient* client = (JackClient*)ext_client;
  1152. if (client == NULL) {
  1153. jack_error("jack_connect called with a NULL client");
  1154. return -1;
  1155. } else if ((src == NULL) || (dst == NULL)) {
  1156. jack_error("jack_connect called with a NULL port name");
  1157. return -1;
  1158. } else {
  1159. return client->PortConnect(src, dst);
  1160. }
  1161. }
  1162. EXPORT int jack_disconnect(jack_client_t* ext_client, const char* src, const char* dst)
  1163. {
  1164. #ifdef __CLIENTDEBUG__
  1165. JackLibGlobals::CheckContext();
  1166. #endif
  1167. JackClient* client = (JackClient*)ext_client;
  1168. if (client == NULL) {
  1169. jack_error("jack_disconnect called with a NULL client");
  1170. return -1;
  1171. } else if ((src == NULL) || (dst == NULL)) {
  1172. jack_error("jack_connect called with a NULL port name");
  1173. return -1;
  1174. } else {
  1175. return client->PortDisconnect(src, dst);
  1176. }
  1177. }
  1178. EXPORT int jack_port_disconnect(jack_client_t* ext_client, jack_port_t* src)
  1179. {
  1180. #ifdef __CLIENTDEBUG__
  1181. JackLibGlobals::CheckContext();
  1182. #endif
  1183. JackClient* client = (JackClient*)ext_client;
  1184. if (client == NULL) {
  1185. jack_error("jack_port_disconnect called with a NULL client");
  1186. return -1;
  1187. }
  1188. #if defined(__x86_64__) || defined(__ppc64__)
  1189. uint64_t port_aux = (uint64_t)src;
  1190. #else
  1191. uint32_t port_aux = (uint32_t)src;
  1192. #endif
  1193. jack_port_id_t myport = (jack_port_id_t)port_aux;
  1194. if (!CheckPort(myport)) {
  1195. jack_error("jack_port_disconnect called with an incorrect port %ld", myport);
  1196. return -1;
  1197. }
  1198. return client->PortDisconnect(myport);
  1199. }
  1200. EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t* ext_client)
  1201. {
  1202. #ifdef __CLIENTDEBUG__
  1203. JackLibGlobals::CheckContext();
  1204. #endif
  1205. JackClient* client = (JackClient*)ext_client;
  1206. if (client == NULL) {
  1207. jack_error("jack_get_sample_rate called with a NULL client");
  1208. return 0;
  1209. } else {
  1210. JackEngineControl* control = GetEngineControl();
  1211. return (control ? control->fSampleRate : 0);
  1212. }
  1213. }
  1214. EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client)
  1215. {
  1216. #ifdef __CLIENTDEBUG__
  1217. JackLibGlobals::CheckContext();
  1218. #endif
  1219. JackClient* client = (JackClient*)ext_client;
  1220. if (client == NULL) {
  1221. jack_error("jack_get_buffer_size called with a NULL client");
  1222. return 0;
  1223. } else {
  1224. JackEngineControl* control = GetEngineControl();
  1225. return (control ? control->fBufferSize : 0);
  1226. }
  1227. }
  1228. EXPORT const char** jack_get_ports(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
  1229. {
  1230. #ifdef __CLIENTDEBUG__
  1231. JackLibGlobals::CheckContext();
  1232. #endif
  1233. JackClient* client = (JackClient*)ext_client;
  1234. if (client == NULL) {
  1235. jack_error("jack_get_ports called with a NULL client");
  1236. return NULL;
  1237. }
  1238. JackGraphManager* manager = GetGraphManager();
  1239. return (manager ? manager->GetPorts(port_name_pattern, type_name_pattern, flags) : NULL);
  1240. }
  1241. EXPORT jack_port_t* jack_port_by_name(jack_client_t* ext_client, const char* portname)
  1242. {
  1243. #ifdef __CLIENTDEBUG__
  1244. JackLibGlobals::CheckContext();
  1245. #endif
  1246. JackClient* client = (JackClient*)ext_client;
  1247. if (client == NULL) {
  1248. jack_error("jack_get_ports called with a NULL client");
  1249. return 0;
  1250. }
  1251. if (portname == NULL) {
  1252. jack_error("jack_port_by_name called with a NULL port name");
  1253. return NULL;
  1254. } else {
  1255. JackGraphManager* manager = GetGraphManager();
  1256. if (!manager)
  1257. return NULL;
  1258. int res = manager->GetPort(portname); // returns a port index at least > 1
  1259. return (res == NO_PORT) ? NULL : (jack_port_t*)res;
  1260. }
  1261. }
  1262. EXPORT jack_port_t* jack_port_by_id(jack_client_t* ext_client, jack_port_id_t id)
  1263. {
  1264. #ifdef __CLIENTDEBUG__
  1265. JackLibGlobals::CheckContext();
  1266. #endif
  1267. /* jack_port_t* type is actually the port index */
  1268. return (jack_port_t*)id;
  1269. }
  1270. EXPORT int jack_engine_takeover_timebase(jack_client_t* ext_client)
  1271. {
  1272. #ifdef __CLIENTDEBUG__
  1273. JackLibGlobals::CheckContext();
  1274. #endif
  1275. JackClient* client = (JackClient*)ext_client;
  1276. if (client == NULL) {
  1277. jack_error("jack_engine_takeover_timebase called with a NULL client");
  1278. return -1;
  1279. } else {
  1280. jack_error("jack_engine_takeover_timebase: deprecated\n");
  1281. return 0;
  1282. }
  1283. }
  1284. EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t* ext_client)
  1285. {
  1286. #ifdef __CLIENTDEBUG__
  1287. JackLibGlobals::CheckContext();
  1288. #endif
  1289. JackTimer timer;
  1290. JackEngineControl* control = GetEngineControl();
  1291. if (control) {
  1292. control->ReadFrameTime(&timer);
  1293. return timer.FramesSinceCycleStart(GetMicroSeconds(), control->fSampleRate);
  1294. } else {
  1295. return 0;
  1296. }
  1297. }
  1298. EXPORT jack_time_t jack_get_time()
  1299. {
  1300. return GetMicroSeconds();
  1301. }
  1302. EXPORT jack_time_t jack_frames_to_time(const jack_client_t* ext_client, jack_nframes_t frames)
  1303. {
  1304. #ifdef __CLIENTDEBUG__
  1305. JackLibGlobals::CheckContext();
  1306. #endif
  1307. JackClient* client = (JackClient*)ext_client;
  1308. if (client == NULL) {
  1309. jack_error("jack_frames_to_time called with a NULL client");
  1310. return 0;
  1311. } else {
  1312. JackTimer timer;
  1313. JackEngineControl* control = GetEngineControl();
  1314. if (control) {
  1315. control->ReadFrameTime(&timer);
  1316. return timer.Frames2Time(frames, control->fBufferSize);
  1317. } else {
  1318. return 0;
  1319. }
  1320. }
  1321. }
  1322. EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t* ext_client, jack_time_t time)
  1323. {
  1324. #ifdef __CLIENTDEBUG__
  1325. JackLibGlobals::CheckContext();
  1326. #endif
  1327. JackClient* client = (JackClient*)ext_client;
  1328. if (client == NULL) {
  1329. jack_error("jack_time_to_frames called with a NULL client");
  1330. return 0;
  1331. } else {
  1332. JackTimer timer;
  1333. JackEngineControl* control = GetEngineControl();
  1334. if (control) {
  1335. control->ReadFrameTime(&timer);
  1336. return timer.Time2Frames(time, control->fBufferSize);
  1337. } else {
  1338. return 0;
  1339. }
  1340. }
  1341. }
  1342. EXPORT jack_nframes_t jack_frame_time(const jack_client_t* ext_client)
  1343. {
  1344. return jack_time_to_frames(ext_client, GetMicroSeconds());
  1345. }
  1346. EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
  1347. {
  1348. #ifdef __CLIENTDEBUG__
  1349. JackLibGlobals::CheckContext();
  1350. #endif
  1351. JackTimer timer;
  1352. JackEngineControl* control = GetEngineControl();
  1353. if (control) {
  1354. control->ReadFrameTime(&timer);
  1355. return timer.CurFrame();
  1356. } else {
  1357. return 0;
  1358. }
  1359. }
  1360. EXPORT float jack_cpu_load(jack_client_t* ext_client)
  1361. {
  1362. #ifdef __CLIENTDEBUG__
  1363. JackLibGlobals::CheckContext();
  1364. #endif
  1365. JackClient* client = (JackClient*)ext_client;
  1366. if (client == NULL) {
  1367. jack_error("jack_cpu_load called with a NULL client");
  1368. return 0.0f;
  1369. } else {
  1370. JackEngineControl* control = GetEngineControl();
  1371. return (control ? control->fCPULoad : 0.0f);
  1372. }
  1373. }
  1374. EXPORT pthread_t jack_client_thread_id(jack_client_t* ext_client)
  1375. {
  1376. #ifdef __CLIENTDEBUG__
  1377. JackLibGlobals::CheckContext();
  1378. #endif
  1379. JackClient* client = (JackClient*)ext_client;
  1380. if (client == NULL) {
  1381. jack_error("jack_client_thread_id called with a NULL client");
  1382. return (pthread_t)NULL;
  1383. } else {
  1384. return client->GetThreadID();
  1385. }
  1386. }
  1387. EXPORT char* jack_get_client_name(jack_client_t* ext_client)
  1388. {
  1389. #ifdef __CLIENTDEBUG__
  1390. JackLibGlobals::CheckContext();
  1391. #endif
  1392. JackClient* client = (JackClient*)ext_client;
  1393. if (client == NULL) {
  1394. jack_error("jack_get_client_name called with a NULL client");
  1395. return NULL;
  1396. } else {
  1397. return client->GetClientControl()->fName;
  1398. }
  1399. }
  1400. EXPORT int jack_client_name_size(void)
  1401. {
  1402. return JACK_CLIENT_NAME_SIZE;
  1403. }
  1404. EXPORT int jack_port_name_size(void)
  1405. {
  1406. return JACK_PORT_NAME_SIZE;
  1407. }
  1408. EXPORT int jack_port_type_size(void)
  1409. {
  1410. return JACK_PORT_TYPE_SIZE;
  1411. }
  1412. // transport.h
  1413. EXPORT int jack_release_timebase(jack_client_t* ext_client)
  1414. {
  1415. #ifdef __CLIENTDEBUG__
  1416. JackLibGlobals::CheckContext();
  1417. #endif
  1418. JackClient* client = (JackClient*)ext_client;
  1419. if (client == NULL) {
  1420. jack_error("jack_release_timebase called with a NULL client");
  1421. return -1;
  1422. } else {
  1423. return client->ReleaseTimebase();
  1424. }
  1425. }
  1426. EXPORT int jack_set_sync_callback(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg)
  1427. {
  1428. #ifdef __CLIENTDEBUG__
  1429. JackLibGlobals::CheckContext();
  1430. #endif
  1431. JackClient* client = (JackClient*)ext_client;
  1432. if (client == NULL) {
  1433. jack_error("jack_set_sync_callback called with a NULL client");
  1434. return -1;
  1435. } else {
  1436. return client->SetSyncCallback(sync_callback, arg);
  1437. }
  1438. }
  1439. EXPORT int jack_set_sync_timeout(jack_client_t* ext_client, jack_time_t timeout)
  1440. {
  1441. #ifdef __CLIENTDEBUG__
  1442. JackLibGlobals::CheckContext();
  1443. #endif
  1444. JackClient* client = (JackClient*)ext_client;
  1445. if (client == NULL) {
  1446. jack_error("jack_set_sync_timeout called with a NULL client");
  1447. return -1;
  1448. } else {
  1449. return client->SetSyncTimeout(timeout);
  1450. }
  1451. }
  1452. EXPORT int jack_set_timebase_callback(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg)
  1453. {
  1454. #ifdef __CLIENTDEBUG__
  1455. JackLibGlobals::CheckContext();
  1456. #endif
  1457. JackClient* client = (JackClient*)ext_client;
  1458. if (client == NULL) {
  1459. jack_error("jack_set_timebase_callback called with a NULL client");
  1460. return -1;
  1461. } else {
  1462. return client->SetTimebaseCallback(conditional, timebase_callback, arg);
  1463. }
  1464. }
  1465. EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame)
  1466. {
  1467. #ifdef __CLIENTDEBUG__
  1468. JackLibGlobals::CheckContext();
  1469. #endif
  1470. JackClient* client = (JackClient*)ext_client;
  1471. if (client == NULL) {
  1472. jack_error("jack_transport_locate called with a NULL client");
  1473. return -1;
  1474. } else {
  1475. client->TransportLocate(frame);
  1476. return 0;
  1477. }
  1478. }
  1479. EXPORT jack_transport_state_t jack_transport_query(const jack_client_t* ext_client, jack_position_t* pos)
  1480. {
  1481. #ifdef __CLIENTDEBUG__
  1482. JackLibGlobals::CheckContext();
  1483. #endif
  1484. JackClient* client = (JackClient*)ext_client;
  1485. if (client == NULL) {
  1486. jack_error("jack_transport_query called with a NULL client");
  1487. return JackTransportStopped;
  1488. } else {
  1489. return client->TransportQuery(pos);
  1490. }
  1491. }
  1492. EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t* ext_client)
  1493. {
  1494. #ifdef __CLIENTDEBUG__
  1495. JackLibGlobals::CheckContext();
  1496. #endif
  1497. JackClient* client = (JackClient*)ext_client;
  1498. if (client == NULL) {
  1499. jack_error("jack_get_current_transport_frame called with a NULL client");
  1500. return 0;
  1501. } else {
  1502. return client->GetCurrentTransportFrame();
  1503. }
  1504. }
  1505. EXPORT int jack_transport_reposition(jack_client_t* ext_client, jack_position_t* pos)
  1506. {
  1507. #ifdef __CLIENTDEBUG__
  1508. JackLibGlobals::CheckContext();
  1509. #endif
  1510. JackClient* client = (JackClient*)ext_client;
  1511. if (client == NULL) {
  1512. jack_error("jack_transport_reposition called with a NULL client");
  1513. return -1;
  1514. } else {
  1515. client->TransportReposition(pos);
  1516. return 0;
  1517. }
  1518. }
  1519. EXPORT void jack_transport_start(jack_client_t* ext_client)
  1520. {
  1521. #ifdef __CLIENTDEBUG__
  1522. JackLibGlobals::CheckContext();
  1523. #endif
  1524. JackClient* client = (JackClient*)ext_client;
  1525. if (client == NULL) {
  1526. jack_error("jack_transport_start called with a NULL client");
  1527. } else {
  1528. client->TransportStart();
  1529. }
  1530. }
  1531. EXPORT void jack_transport_stop(jack_client_t* ext_client)
  1532. {
  1533. #ifdef __CLIENTDEBUG__
  1534. JackLibGlobals::CheckContext();
  1535. #endif
  1536. JackClient* client = (JackClient*)ext_client;
  1537. if (client == NULL) {
  1538. jack_error("jack_transport_stop called with a NULL client");
  1539. } else {
  1540. client->TransportStop();
  1541. }
  1542. }
  1543. // deprecated
  1544. EXPORT void jack_get_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  1545. {
  1546. jack_error("jack_get_transport_info: deprecated");
  1547. if (tinfo)
  1548. memset(tinfo, 0, sizeof(jack_transport_info_t));
  1549. }
  1550. EXPORT void jack_set_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  1551. {
  1552. jack_error("jack_set_transport_info: deprecated");
  1553. if (tinfo)
  1554. memset(tinfo, 0, sizeof(jack_transport_info_t));
  1555. }
  1556. // statistics.h
  1557. EXPORT float jack_get_max_delayed_usecs(jack_client_t* ext_client)
  1558. {
  1559. #ifdef __CLIENTDEBUG__
  1560. JackLibGlobals::CheckContext();
  1561. #endif
  1562. JackClient* client = (JackClient*)ext_client;
  1563. if (client == NULL) {
  1564. jack_error("jack_get_max_delayed_usecs called with a NULL client");
  1565. return 0.f;
  1566. } else {
  1567. JackEngineControl* control = GetEngineControl();
  1568. return (control ? control->fMaxDelayedUsecs : 0.f);
  1569. }
  1570. }
  1571. EXPORT float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
  1572. {
  1573. #ifdef __CLIENTDEBUG__
  1574. JackLibGlobals::CheckContext();
  1575. #endif
  1576. JackClient* client = (JackClient*)ext_client;
  1577. if (client == NULL) {
  1578. jack_error("jack_get_xrun_delayed_usecs called with a NULL client");
  1579. return 0.f;
  1580. } else {
  1581. JackEngineControl* control = GetEngineControl();
  1582. return (control ? control->fXrunDelayedUsecs : 0.f);
  1583. }
  1584. }
  1585. EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
  1586. {
  1587. #ifdef __CLIENTDEBUG__
  1588. JackLibGlobals::CheckContext();
  1589. #endif
  1590. JackClient* client = (JackClient*)ext_client;
  1591. if (client == NULL) {
  1592. jack_error("jack_reset_max_delayed_usecs called with a NULL client");
  1593. } else {
  1594. JackEngineControl* control = GetEngineControl();
  1595. control->ResetXRun();
  1596. }
  1597. }
  1598. // thread.h
  1599. EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority)
  1600. {
  1601. JackEngineControl* control = GetEngineControl();
  1602. return (control ? JackThread::AcquireRealTimeImp(thread, priority, GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint) : -1);
  1603. }
  1604. EXPORT int jack_client_create_thread(jack_client_t* client,
  1605. pthread_t *thread,
  1606. int priority,
  1607. int realtime, /* boolean */
  1608. thread_routine routine,
  1609. void *arg)
  1610. {
  1611. return JackThread::StartImp(thread, priority, realtime, routine, arg);
  1612. }
  1613. EXPORT int jack_drop_real_time_scheduling(pthread_t thread)
  1614. {
  1615. return JackThread::DropRealTimeImp(thread);
  1616. }
  1617. EXPORT int jack_client_stop_thread(jack_client_t* client, pthread_t thread)
  1618. {
  1619. return JackThread::StopImp(thread);
  1620. }
  1621. EXPORT int jack_client_kill_thread(jack_client_t* client, pthread_t thread)
  1622. {
  1623. return JackThread::KillImp(thread);
  1624. }
  1625. // intclient.h
  1626. EXPORT int jack_internal_client_new (const char *client_name,
  1627. const char *load_name,
  1628. const char *load_init)
  1629. {
  1630. jack_error("jack_internal_client_new: deprecated");
  1631. return -1;
  1632. }
  1633. EXPORT void jack_internal_client_close (const char *client_name)
  1634. {
  1635. jack_error("jack_internal_client_close: deprecated");
  1636. }
  1637. EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
  1638. {
  1639. #ifdef __CLIENTDEBUG__
  1640. JackLibGlobals::CheckContext();
  1641. #endif
  1642. JackClient* client = (JackClient*)ext_client;
  1643. if (client == NULL) {
  1644. jack_error("jack_get_internal_client_name called with a NULL client");
  1645. return NULL;
  1646. } else if (intclient >= CLIENT_NUM) {
  1647. jack_error("jack_get_internal_client_name: incorrect client");
  1648. return NULL;
  1649. } else {
  1650. return client->GetInternalClientName(intclient);
  1651. }
  1652. }
  1653. EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, const char* client_name, jack_status_t* status)
  1654. {
  1655. #ifdef __CLIENTDEBUG__
  1656. JackLibGlobals::CheckContext();
  1657. #endif
  1658. JackClient* client = (JackClient*)ext_client;
  1659. if (client == NULL) {
  1660. jack_error("jack_internal_client_handle called with a NULL client");
  1661. return 0;
  1662. } else {
  1663. jack_status_t my_status;
  1664. if (status == NULL) /* no status from caller? */
  1665. status = &my_status; /* use local status word */
  1666. *status = (jack_status_t)0;
  1667. return client->InternalClientHandle(client_name, status);
  1668. }
  1669. }
  1670. EXPORT jack_intclient_t jack_internal_client_load_aux(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, va_list ap)
  1671. {
  1672. #ifdef __CLIENTDEBUG__
  1673. JackLibGlobals::CheckContext();
  1674. #endif
  1675. JackClient* client = (JackClient*)ext_client;
  1676. if (client == NULL) {
  1677. jack_error("jack_internal_client_load called with a NULL client");
  1678. return 0;
  1679. } else {
  1680. jack_varargs_t va;
  1681. jack_status_t my_status;
  1682. if (status == NULL) /* no status from caller? */
  1683. status = &my_status; /* use local status word */
  1684. *status = (jack_status_t)0;
  1685. /* validate parameters */
  1686. if ((options & ~JackLoadOptions)) {
  1687. int my_status1 = *status | (JackFailure | JackInvalidOption);
  1688. *status = (jack_status_t)my_status1;
  1689. return 0;
  1690. }
  1691. /* parse variable arguments */
  1692. jack_varargs_parse(options, ap, &va);
  1693. return client->InternalClientLoad(client_name, options, status, &va);
  1694. }
  1695. }
  1696. EXPORT jack_intclient_t jack_internal_client_load(jack_client_t *client, const char *client_name, jack_options_t options, jack_status_t *status, ...)
  1697. {
  1698. va_list ap;
  1699. va_start(ap, status);
  1700. jack_intclient_t res = jack_internal_client_load_aux(client, client_name, options, status, ap);
  1701. va_end(ap);
  1702. return res;
  1703. }
  1704. EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
  1705. {
  1706. #ifdef __CLIENTDEBUG__
  1707. JackLibGlobals::CheckContext();
  1708. #endif
  1709. JackClient* client = (JackClient*)ext_client;
  1710. if (client == NULL) {
  1711. jack_error("jack_internal_client_unload called with a NULL client");
  1712. return (jack_status_t)(JackNoSuchClient | JackFailure);
  1713. } else if (intclient >= CLIENT_NUM) {
  1714. jack_error("jack_internal_client_unload: incorrect client");
  1715. return (jack_status_t)(JackNoSuchClient | JackFailure);
  1716. } else {
  1717. jack_status_t my_status;
  1718. client->InternalClientUnload(intclient, &my_status);
  1719. return my_status;
  1720. }
  1721. }
  1722. EXPORT
  1723. void
  1724. jack_get_version(
  1725. int *major_ptr,
  1726. int *minor_ptr,
  1727. int *micro_ptr,
  1728. int *proto_ptr)
  1729. {
  1730. // FIXME: We need these comming from build system
  1731. *major_ptr = 0;
  1732. *minor_ptr = 0;
  1733. *micro_ptr = 0;
  1734. *proto_ptr = 0;
  1735. }
  1736. EXPORT
  1737. const char *
  1738. jack_get_version_string()
  1739. {
  1740. return VERSION;
  1741. }