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.

1911 lines
61KB

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