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