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.

1349 lines
43KB

  1. /*
  2. Copyright (C) 2001-2003 Paul Davis
  3. Copyright (C) 2004-2006 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 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 General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 "JackExports.h"
  24. #ifdef __APPLE__
  25. #include "JackMachThread.h"
  26. #elif WIN32
  27. #include "JackWinThread.h"
  28. #else
  29. #include "JackPosixThread.h"
  30. #endif
  31. #include <math.h>
  32. #ifdef __CLIENTDEBUG__
  33. #include "JackLibGlobals.h"
  34. #endif
  35. using namespace Jack;
  36. #ifdef __cplusplus
  37. extern "C"
  38. {
  39. #endif
  40. EXPORT int jack_client_name_size (void);
  41. EXPORT char* jack_get_client_name (jack_client_t *client);
  42. EXPORT int jack_internal_client_new (const char *client_name,
  43. const char *load_name,
  44. const char *load_init);
  45. EXPORT jack_client_t* my_jack_internal_client_new(const char* client_name);
  46. EXPORT void jack_internal_client_close (const char *client_name);
  47. EXPORT void my_jack_internal_client_close (jack_client_t* client);
  48. EXPORT int jack_is_realtime (jack_client_t *client);
  49. EXPORT void jack_on_shutdown (jack_client_t *client,
  50. void (*function)(void *arg), void *arg);
  51. EXPORT int jack_set_process_callback (jack_client_t *client,
  52. JackProcessCallback process_callback,
  53. void *arg);
  54. EXPORT int jack_set_thread_init_callback (jack_client_t *client,
  55. JackThreadInitCallback thread_init_callback,
  56. void *arg);
  57. EXPORT int jack_set_freewheel_callback (jack_client_t *client,
  58. JackFreewheelCallback freewheel_callback,
  59. void *arg);
  60. EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
  61. EXPORT int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
  62. EXPORT int jack_set_buffer_size_callback (jack_client_t *client,
  63. JackBufferSizeCallback bufsize_callback,
  64. void *arg);
  65. EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
  66. JackSampleRateCallback srate_callback,
  67. void *arg);
  68. EXPORT int jack_set_port_registration_callback (jack_client_t *,
  69. JackPortRegistrationCallback
  70. registration_callback, void *arg);
  71. EXPORT int jack_set_graph_order_callback (jack_client_t *,
  72. JackGraphOrderCallback graph_callback,
  73. void *);
  74. EXPORT int jack_set_xrun_callback (jack_client_t *,
  75. JackXRunCallback xrun_callback, void *arg);
  76. EXPORT int jack_activate (jack_client_t *client);
  77. EXPORT int jack_deactivate (jack_client_t *client);
  78. EXPORT jack_port_t * jack_port_register (jack_client_t *client,
  79. const char *port_name,
  80. const char *port_type,
  81. unsigned long flags,
  82. unsigned long buffer_size);
  83. EXPORT int jack_port_unregister (jack_client_t *, jack_port_t *);
  84. EXPORT void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
  85. EXPORT const char * jack_port_name (const jack_port_t *port);
  86. EXPORT const char * jack_port_short_name (const jack_port_t *port);
  87. EXPORT int jack_port_flags (const jack_port_t *port);
  88. EXPORT const char * jack_port_type (const jack_port_t *port);
  89. EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
  90. EXPORT int jack_port_connected (const jack_port_t *port);
  91. EXPORT int jack_port_connected_to (const jack_port_t *port,
  92. const char *port_name);
  93. EXPORT const char ** jack_port_get_connections (const jack_port_t *port);
  94. EXPORT const char ** jack_port_get_all_connections (const jack_client_t *client,
  95. const jack_port_t *port);
  96. EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst);
  97. EXPORT int jack_port_untie (jack_port_t *port);
  98. EXPORT int jack_port_lock (jack_client_t *, jack_port_t *);
  99. EXPORT int jack_port_unlock (jack_client_t *, jack_port_t *);
  100. EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port);
  101. EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *,
  102. jack_port_t *port);
  103. EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t);
  104. EXPORT int jack_recompute_total_latencies (jack_client_t*);
  105. EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name);
  106. EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff);
  107. EXPORT int jack_port_request_monitor_by_name (jack_client_t *client,
  108. const char *port_name, int onoff);
  109. EXPORT int jack_port_ensure_monitor (jack_port_t *port, int onoff);
  110. EXPORT int jack_port_monitoring_input (jack_port_t *port);
  111. EXPORT int jack_connect (jack_client_t *,
  112. const char *source_port,
  113. const char *destination_port);
  114. EXPORT int jack_disconnect (jack_client_t *,
  115. const char *source_port,
  116. const char *destination_port);
  117. EXPORT int jack_port_disconnect (jack_client_t *, jack_port_t *);
  118. EXPORT int jack_port_name_size(void);
  119. EXPORT int jack_port_type_size(void);
  120. EXPORT jack_nframes_t jack_get_sample_rate (jack_client_t *);
  121. EXPORT jack_nframes_t jack_get_buffer_size (jack_client_t *);
  122. EXPORT const char ** jack_get_ports (jack_client_t *,
  123. const char *port_name_pattern,
  124. const char *type_name_pattern,
  125. unsigned long flags);
  126. EXPORT jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
  127. EXPORT jack_port_t * jack_port_by_id (jack_client_t *client,
  128. jack_port_id_t port_id);
  129. EXPORT int jack_engine_takeover_timebase (jack_client_t *);
  130. EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
  131. EXPORT jack_nframes_t jack_frame_time (const jack_client_t *);
  132. EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client);
  133. EXPORT float jack_cpu_load (jack_client_t *client);
  134. EXPORT pthread_t jack_client_thread_id (jack_client_t *);
  135. EXPORT void jack_set_error_function (void (*func)(const char *));
  136. EXPORT float jack_get_max_delayed_usecs (jack_client_t *client);
  137. EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client);
  138. EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client);
  139. EXPORT int jack_release_timebase (jack_client_t *client);
  140. EXPORT int jack_set_sync_callback (jack_client_t *client,
  141. JackSyncCallback sync_callback,
  142. void *arg);
  143. EXPORT int jack_set_sync_timeout (jack_client_t *client,
  144. jack_time_t timeout);
  145. EXPORT int jack_set_timebase_callback (jack_client_t *client,
  146. int conditional,
  147. JackTimebaseCallback timebase_callback,
  148. void *arg);
  149. EXPORT int jack_transport_locate (jack_client_t *client,
  150. jack_nframes_t frame);
  151. EXPORT jack_transport_state_t jack_transport_query (const jack_client_t *client,
  152. jack_position_t *pos);
  153. EXPORT jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
  154. EXPORT int jack_transport_reposition (jack_client_t *client,
  155. jack_position_t *pos);
  156. EXPORT void jack_transport_start (jack_client_t *client);
  157. EXPORT void jack_transport_stop (jack_client_t *client);
  158. EXPORT void jack_get_transport_info (jack_client_t *client,
  159. jack_transport_info_t *tinfo);
  160. EXPORT void jack_set_transport_info (jack_client_t *client,
  161. jack_transport_info_t *tinfo);
  162. EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
  163. EXPORT int jack_client_create_thread (jack_client_t* client,
  164. pthread_t *thread,
  165. int priority,
  166. int realtime, // boolean
  167. void *(*start_routine)(void*),
  168. void *arg);
  169. EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
  170. EXPORT char * jack_get_internal_client_name (jack_client_t *client,
  171. jack_intclient_t intclient);
  172. EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client,
  173. const char *client_name,
  174. jack_status_t *status);
  175. EXPORT jack_intclient_t jack_internal_client_load (jack_client_t *client,
  176. const char *client_name,
  177. jack_options_t options,
  178. jack_status_t *status, ...);
  179. EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
  180. jack_intclient_t intclient);
  181. #ifdef __cplusplus
  182. }
  183. #endif
  184. #ifdef WIN32
  185. /* missing on Windows : see http://bugs.mysql.com/bug.php?id=15936 */
  186. inline double rint(double nr)
  187. {
  188. double f = floor(nr);
  189. double c = ceil(nr);
  190. return (((c -nr) >= (nr - f)) ? f : c);
  191. }
  192. #endif
  193. static inline bool CheckPort(jack_port_id_t port_index)
  194. {
  195. return (port_index < PORT_NUM);
  196. }
  197. static inline bool CheckBufferSize(jack_nframes_t buffer_size)
  198. {
  199. return (buffer_size <= BUFFER_SIZE_MAX);
  200. }
  201. static inline void WaitGraphChange()
  202. {
  203. if (GetGraphManager()->IsPendingChange()) {
  204. JackLog("WaitGraphChange...\n");
  205. JackSleep(GetEngineControl()->fPeriodUsecs * 2);
  206. }
  207. }
  208. static void default_jack_error_callback(const char *desc)
  209. {
  210. fprintf(stderr, "%s\n", desc);
  211. }
  212. void (*jack_error_callback)(const char *desc) = &default_jack_error_callback;
  213. EXPORT void jack_set_error_function (void (*func)(const char *))
  214. {
  215. jack_error_callback = func;
  216. }
  217. EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
  218. {
  219. #ifdef __CLIENTDEBUG__
  220. JackLibGlobals::CheckContext();
  221. #endif
  222. jack_port_id_t myport = (jack_port_id_t)port;
  223. if (!CheckPort(myport)) {
  224. jack_error("jack_port_get_buffer called with an incorrect port %ld", myport);
  225. return NULL;
  226. } else {
  227. return GetGraphManager()->GetBuffer(myport, frames);
  228. }
  229. }
  230. EXPORT const char* jack_port_name(const jack_port_t* port)
  231. {
  232. #ifdef __CLIENTDEBUG__
  233. JackLibGlobals::CheckContext();
  234. #endif
  235. jack_port_id_t myport = (jack_port_id_t)port;
  236. if (!CheckPort(myport)) {
  237. jack_error("jack_port_name called with an incorrect port %ld", myport);
  238. return NULL;
  239. } else {
  240. return GetGraphManager()->GetPort(myport)->GetName();
  241. }
  242. }
  243. EXPORT const char* jack_port_short_name(const jack_port_t* port)
  244. {
  245. #ifdef __CLIENTDEBUG__
  246. JackLibGlobals::CheckContext();
  247. #endif
  248. jack_port_id_t myport = (jack_port_id_t)port;
  249. if (!CheckPort(myport)) {
  250. jack_error("jack_port_short_name called with an incorrect port %ld", myport);
  251. return NULL;
  252. } else {
  253. return GetGraphManager()->GetPort(myport)->GetShortName();
  254. }
  255. }
  256. EXPORT int jack_port_flags(const jack_port_t* port)
  257. {
  258. #ifdef __CLIENTDEBUG__
  259. JackLibGlobals::CheckContext();
  260. #endif
  261. jack_port_id_t myport = (jack_port_id_t)port;
  262. if (!CheckPort(myport)) {
  263. jack_error("jack_port_flags called with an incorrect port %ld", myport);
  264. return -1;
  265. } else {
  266. return GetGraphManager()->GetPort(myport)->Flags();
  267. }
  268. }
  269. EXPORT const char* jack_port_type(const jack_port_t* port)
  270. {
  271. #ifdef __CLIENTDEBUG__
  272. JackLibGlobals::CheckContext();
  273. #endif
  274. jack_port_id_t myport = (jack_port_id_t)port;
  275. if (!CheckPort(myport)) {
  276. jack_error("jack_port_flags called an incorrect port %ld", myport);
  277. return NULL;
  278. } else {
  279. return GetGraphManager()->GetPort(myport)->Type();
  280. }
  281. }
  282. EXPORT int jack_port_connected(const jack_port_t* port)
  283. {
  284. #ifdef __CLIENTDEBUG__
  285. JackLibGlobals::CheckContext();
  286. #endif
  287. jack_port_id_t myport = (jack_port_id_t)port;
  288. if (!CheckPort(myport)) {
  289. jack_error("jack_port_connected called with an incorrect port %ld", myport);
  290. return -1;
  291. } else {
  292. WaitGraphChange();
  293. return GetGraphManager()->GetConnectionsNum(myport);
  294. }
  295. }
  296. EXPORT int jack_port_connected_to(const jack_port_t* port, const char* portname)
  297. {
  298. #ifdef __CLIENTDEBUG__
  299. JackLibGlobals::CheckContext();
  300. #endif
  301. jack_port_id_t myport = (jack_port_id_t)port;
  302. if (!CheckPort(myport)) {
  303. jack_error("jack_port_connected_to called with an incorrect port %ld", myport);
  304. return -1;
  305. } else if (portname == NULL) {
  306. jack_error("jack_port_connected_to called with a NULL port name");
  307. return -1;
  308. } else {
  309. WaitGraphChange();
  310. return GetGraphManager()->ConnectedTo(myport, portname);
  311. }
  312. }
  313. EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
  314. {
  315. #ifdef __CLIENTDEBUG__
  316. JackLibGlobals::CheckContext();
  317. #endif
  318. jack_port_id_t mysrc = (jack_port_id_t)src;
  319. if (!CheckPort(mysrc)) {
  320. jack_error("jack_port_tie called with a NULL src port");
  321. return -1;
  322. }
  323. jack_port_id_t mydst = (jack_port_id_t)dst;
  324. if (!CheckPort(mydst)) {
  325. jack_error("jack_port_tie called with a NULL dst port");
  326. return -1;
  327. }
  328. if (GetGraphManager()->GetPort(mysrc)->GetRefNum() != GetGraphManager()->GetPort(mydst)->GetRefNum()) {
  329. jack_error("jack_port_tie called with ports not belonging to the same client");
  330. return -1;
  331. }
  332. return GetGraphManager()->GetPort(mydst)->Tie(mysrc);
  333. }
  334. EXPORT int jack_port_untie(jack_port_t* port)
  335. {
  336. #ifdef __CLIENTDEBUG__
  337. JackLibGlobals::CheckContext();
  338. #endif
  339. jack_port_id_t myport = (jack_port_id_t)port;
  340. if (!CheckPort(myport)) {
  341. jack_error("jack_port_untie called with an incorrect port %ld", myport);
  342. return -1;
  343. } else {
  344. return GetGraphManager()->GetPort(myport)->UnTie();
  345. }
  346. }
  347. EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
  348. {
  349. #ifdef __CLIENTDEBUG__
  350. JackLibGlobals::CheckContext();
  351. #endif
  352. jack_port_id_t myport = (jack_port_id_t)port;
  353. if (!CheckPort(myport)) {
  354. jack_error("jack_port_get_latency called with an incorrect port %ld", myport);
  355. return 0;
  356. } else {
  357. WaitGraphChange();
  358. return GetGraphManager()->GetPort(myport)->GetLatency();
  359. }
  360. }
  361. EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
  362. {
  363. #ifdef __CLIENTDEBUG__
  364. JackLibGlobals::CheckContext();
  365. #endif
  366. jack_port_id_t myport = (jack_port_id_t)port;
  367. if (!CheckPort(myport)) {
  368. jack_error("jack_port_set_latency called with an incorrect port %ld", myport);
  369. } else {
  370. GetGraphManager()->GetPort(myport)->SetLatency(frames);
  371. }
  372. }
  373. EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
  374. {
  375. // The latency computation is done each time jack_port_get_total_latency is called
  376. return 0;
  377. }
  378. EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
  379. {
  380. #ifdef __CLIENTDEBUG__
  381. JackLibGlobals::CheckContext();
  382. #endif
  383. jack_port_id_t myport = (jack_port_id_t)port;
  384. if (!CheckPort(myport)) {
  385. jack_error("jack_port_set_name called with an incorrect port %ld", myport);
  386. return -1;
  387. } else if (name == NULL) {
  388. jack_error("jack_port_set_name called with a NULL port name");
  389. return -1;
  390. } else {
  391. return GetGraphManager()->GetPort(myport)->SetName(name);
  392. }
  393. }
  394. EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
  395. {
  396. #ifdef __CLIENTDEBUG__
  397. JackLibGlobals::CheckContext();
  398. #endif
  399. jack_port_id_t myport = (jack_port_id_t)port;
  400. if (!CheckPort(myport)) {
  401. jack_error("jack_port_request_monitor called with an incorrect port %ld", myport);
  402. return -1;
  403. } else {
  404. return GetGraphManager()->RequestMonitor(myport, onoff);
  405. }
  406. }
  407. EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
  408. {
  409. #ifdef __CLIENTDEBUG__
  410. JackLibGlobals::CheckContext();
  411. #endif
  412. JackClient* client = (JackClient*)ext_client;
  413. if (client == NULL) {
  414. jack_error("jack_port_request_monitor_by_name called with a NULL client");
  415. return -1;
  416. } else {
  417. jack_port_id_t myport = GetGraphManager()->GetPort(port_name);
  418. if (!CheckPort(myport)) {
  419. jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
  420. return -1;
  421. } else {
  422. return GetGraphManager()->RequestMonitor(myport, onoff);
  423. }
  424. }
  425. }
  426. EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
  427. {
  428. #ifdef __CLIENTDEBUG__
  429. JackLibGlobals::CheckContext();
  430. #endif
  431. jack_port_id_t myport = (jack_port_id_t)port;
  432. if (!CheckPort(myport)) {
  433. jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport);
  434. return -1;
  435. } else {
  436. return GetGraphManager()->GetPort(myport)->EnsureMonitor(onoff);
  437. }
  438. }
  439. EXPORT int jack_port_monitoring_input(jack_port_t* port)
  440. {
  441. #ifdef __CLIENTDEBUG__
  442. JackLibGlobals::CheckContext();
  443. #endif
  444. jack_port_id_t myport = (jack_port_id_t)port;
  445. if (!CheckPort(myport)) {
  446. jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport);
  447. return -1;
  448. } else {
  449. return GetGraphManager()->GetPort(myport)->MonitoringInput();
  450. }
  451. }
  452. EXPORT int jack_is_realtime(jack_client_t* ext_client)
  453. {
  454. #ifdef __CLIENTDEBUG__
  455. JackLibGlobals::CheckContext();
  456. #endif
  457. JackClient* client = (JackClient*)ext_client;
  458. if (client == NULL) {
  459. jack_error("jack_is_realtime called with a NULL client");
  460. return -1;
  461. } else {
  462. return GetEngineControl()->fRealTime;
  463. }
  464. }
  465. EXPORT void jack_on_shutdown(jack_client_t* ext_client, void (*function)(void* arg), void* arg)
  466. {
  467. #ifdef __CLIENTDEBUG__
  468. JackLibGlobals::CheckContext();
  469. #endif
  470. JackClient* client = (JackClient*)ext_client;
  471. if (client == NULL) {
  472. jack_error("jack_on_shutdown called with a NULL client");
  473. } else {
  474. client->OnShutdown(function, arg);
  475. }
  476. }
  477. EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
  478. {
  479. #ifdef __CLIENTDEBUG__
  480. JackLibGlobals::CheckContext();
  481. #endif
  482. JackClient* client = (JackClient*)ext_client;
  483. if (client == NULL) {
  484. jack_error("jack_set_process_callback called with a NULL client");
  485. return -1;
  486. } else {
  487. return client->SetProcessCallback(callback, arg);
  488. }
  489. }
  490. EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
  491. {
  492. #ifdef __CLIENTDEBUG__
  493. JackLibGlobals::CheckContext();
  494. #endif
  495. JackClient* client = (JackClient*)ext_client;
  496. if (client == NULL) {
  497. jack_error("jack_set_freewheel_callback called with a NULL client");
  498. return -1;
  499. } else {
  500. return client->SetFreewheelCallback(freewheel_callback, arg);
  501. }
  502. }
  503. EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
  504. {
  505. #ifdef __CLIENTDEBUG__
  506. JackLibGlobals::CheckContext();
  507. #endif
  508. JackClient* client = (JackClient*)ext_client;
  509. if (client == NULL) {
  510. jack_error("jack_set_freewheel called with a NULL client");
  511. return -1;
  512. } else {
  513. return client->SetFreeWheel(onoff);
  514. }
  515. }
  516. EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
  517. {
  518. #ifdef __CLIENTDEBUG__
  519. JackLibGlobals::CheckContext();
  520. #endif
  521. JackClient* client = (JackClient*)ext_client;
  522. if (client == NULL) {
  523. jack_error("jack_set_buffer_size called with a NULL client");
  524. return -1;
  525. } else if (!CheckBufferSize(buffer_size)) {
  526. return -1;
  527. } else {
  528. return client->SetBufferSize(buffer_size);
  529. }
  530. }
  531. EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
  532. {
  533. #ifdef __CLIENTDEBUG__
  534. JackLibGlobals::CheckContext();
  535. #endif
  536. JackClient* client = (JackClient*)ext_client;
  537. if (client == NULL) {
  538. jack_error("jack_set_buffer_size_callback called with a NULL client");
  539. return -1;
  540. } else {
  541. return client->SetBufferSizeCallback(bufsize_callback, arg);
  542. }
  543. }
  544. EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
  545. {
  546. #ifdef __CLIENTDEBUG__
  547. JackLibGlobals::CheckContext();
  548. #endif
  549. JackClient* client = (JackClient*)ext_client;
  550. JackLog("jack_set_sample_rate_callback ext_client %x client %x \n", ext_client, client);
  551. if (client == NULL) {
  552. jack_error("jack_set_sample_rate_callback called with a NULL client");
  553. return -1;
  554. } else {
  555. JackLog("jack_set_sample_rate_callback: deprecated\n");
  556. return -1;
  557. }
  558. }
  559. EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
  560. {
  561. #ifdef __CLIENTDEBUG__
  562. JackLibGlobals::CheckContext();
  563. #endif
  564. JackClient* client = (JackClient*)ext_client;
  565. if (client == NULL) {
  566. jack_error("jack_set_port_registration_callback called with a NULL client");
  567. return -1;
  568. } else {
  569. return client->SetPortRegistrationCallback(registration_callback, arg);
  570. }
  571. }
  572. EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
  573. {
  574. #ifdef __CLIENTDEBUG__
  575. JackLibGlobals::CheckContext();
  576. #endif
  577. JackClient* client = (JackClient*)ext_client;
  578. JackLog("jack_set_graph_order_callback ext_client %x client %x \n", ext_client, client);
  579. if (client == NULL) {
  580. jack_error("jack_set_graph_order_callback called with a NULL client");
  581. return -1;
  582. } else {
  583. return client->SetGraphOrderCallback(graph_callback, arg);
  584. }
  585. }
  586. EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
  587. {
  588. #ifdef __CLIENTDEBUG__
  589. JackLibGlobals::CheckContext();
  590. #endif
  591. JackClient* client = (JackClient*)ext_client;
  592. if (client == NULL) {
  593. jack_error("jack_set_xrun_callback called with a NULL client");
  594. return -1;
  595. } else {
  596. return client->SetXRunCallback(xrun_callback, arg);
  597. }
  598. }
  599. EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
  600. {
  601. #ifdef __CLIENTDEBUG__
  602. JackLibGlobals::CheckContext();
  603. #endif
  604. JackClient* client = (JackClient*)ext_client;
  605. JackLog("jack_set_thread_init_callback ext_client %x client %x \n", ext_client, client);
  606. if (client == NULL) {
  607. jack_error("jack_set_thread_init_callback called with a NULL client");
  608. return -1;
  609. } else {
  610. return client->SetInitCallback(init_callback, arg);
  611. }
  612. }
  613. EXPORT int jack_activate(jack_client_t* ext_client)
  614. {
  615. #ifdef __CLIENTDEBUG__
  616. JackLibGlobals::CheckContext();
  617. #endif
  618. JackClient* client = (JackClient*)ext_client;
  619. if (client == NULL) {
  620. jack_error("jack_activate called with a NULL client");
  621. return -1;
  622. } else {
  623. return client->Activate();
  624. }
  625. }
  626. EXPORT int jack_deactivate(jack_client_t* ext_client)
  627. {
  628. #ifdef __CLIENTDEBUG__
  629. JackLibGlobals::CheckContext();
  630. #endif
  631. JackClient* client = (JackClient*)ext_client;
  632. if (client == NULL) {
  633. jack_error("jack_deactivate called with a NULL client");
  634. return -1;
  635. } else {
  636. return client->Deactivate();
  637. }
  638. }
  639. 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)
  640. {
  641. #ifdef __CLIENTDEBUG__
  642. JackLibGlobals::CheckContext();
  643. #endif
  644. JackClient* client = (JackClient*)ext_client;
  645. if (client == NULL) {
  646. jack_error("jack_port_register called with a NULL client");
  647. return NULL;
  648. } else if ((port_name == NULL) || (port_type == NULL)) {
  649. jack_error("jack_port_register called with a NULL port name or a NULL port_type");
  650. return NULL;
  651. } else {
  652. return (jack_port_t *)client->PortRegister(port_name, port_type, flags, buffer_size);
  653. }
  654. }
  655. EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port)
  656. {
  657. #ifdef __CLIENTDEBUG__
  658. JackLibGlobals::CheckContext();
  659. #endif
  660. JackClient* client = (JackClient*)ext_client;
  661. if (client == NULL) {
  662. jack_error("jack_port_unregister called with a NULL client");
  663. return -1;
  664. }
  665. jack_port_id_t myport = (jack_port_id_t)port;
  666. if (!CheckPort(myport)) {
  667. jack_error("jack_port_unregister called with an incorrect port %ld", myport);
  668. return -1;
  669. }
  670. return client->PortUnRegister(myport);
  671. }
  672. EXPORT int jack_port_is_mine(const jack_client_t* ext_client, const jack_port_t* port)
  673. {
  674. #ifdef __CLIENTDEBUG__
  675. JackLibGlobals::CheckContext();
  676. #endif
  677. JackClient* client = (JackClient*)ext_client;
  678. if (client == NULL) {
  679. jack_error("jack_port_is_mine called with a NULL client");
  680. return -1;
  681. }
  682. jack_port_id_t myport = (jack_port_id_t)port;
  683. if (!CheckPort(myport)) {
  684. jack_error("jack_port_is_mine called with an incorrect port %ld", myport);
  685. return -1;
  686. }
  687. return client->PortIsMine(myport);
  688. }
  689. EXPORT const char** jack_port_get_connections(const jack_port_t* port)
  690. {
  691. #ifdef __CLIENTDEBUG__
  692. JackLibGlobals::CheckContext();
  693. #endif
  694. jack_port_id_t myport = (jack_port_id_t)port;
  695. if (!CheckPort(myport)) {
  696. jack_error("jack_port_get_connections called with an incorrect port %ld", myport);
  697. return NULL;
  698. } else {
  699. WaitGraphChange();
  700. return GetGraphManager()->GetConnections(myport);
  701. }
  702. }
  703. // Calling client does not need to "own" the port
  704. EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_client, const jack_port_t* port)
  705. {
  706. #ifdef __CLIENTDEBUG__
  707. JackLibGlobals::CheckContext();
  708. #endif
  709. JackClient* client = (JackClient*)ext_client;
  710. if (client == NULL) {
  711. jack_error("jack_port_get_all_connections called with a NULL client");
  712. return NULL;
  713. }
  714. jack_port_id_t myport = (jack_port_id_t)port;
  715. if (!CheckPort(myport)) {
  716. jack_error("jack_port_get_all_connections called with an incorrect port %ld", myport);
  717. return NULL;
  718. } else {
  719. WaitGraphChange();
  720. return GetGraphManager()->GetConnections(myport);
  721. }
  722. }
  723. // Does not use the client parameter
  724. EXPORT int jack_port_lock(jack_client_t* ext_client, jack_port_t* port)
  725. {
  726. #ifdef __CLIENTDEBUG__
  727. JackLibGlobals::CheckContext();
  728. #endif
  729. JackClient* client = (JackClient*)ext_client;
  730. if (client == NULL) {
  731. jack_error("jack_port_lock called with a NULL client");
  732. return -1;
  733. }
  734. jack_port_id_t myport = (jack_port_id_t)port;
  735. if (!CheckPort(myport)) {
  736. jack_error("jack_port_lock called with an incorrect port %ld", myport);
  737. return -1;
  738. } else {
  739. return (myport && client->PortIsMine(myport)) ? GetGraphManager()->GetPort(myport)->Lock() : -1;
  740. }
  741. }
  742. // Does not use the client parameter
  743. EXPORT int jack_port_unlock(jack_client_t* ext_client, jack_port_t* port)
  744. {
  745. #ifdef __CLIENTDEBUG__
  746. JackLibGlobals::CheckContext();
  747. #endif
  748. JackClient* client = (JackClient*)ext_client;
  749. if (client == NULL) {
  750. jack_error("jack_port_unlock called with a NULL client");
  751. return -1;
  752. }
  753. jack_port_id_t myport = (jack_port_id_t)port;
  754. if (!CheckPort(myport)) {
  755. jack_error("jack_port_unlock called with an incorrect port %ld", myport);
  756. return -1;
  757. } else {
  758. return (myport && client->PortIsMine(myport)) ? GetGraphManager()->GetPort(myport)->Unlock() : -1;
  759. }
  760. }
  761. EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port)
  762. {
  763. #ifdef __CLIENTDEBUG__
  764. JackLibGlobals::CheckContext();
  765. #endif
  766. JackClient* client = (JackClient*)ext_client;
  767. if (client == NULL) {
  768. jack_error("jack_port_get_total_latency called with a NULL client");
  769. return 0;
  770. }
  771. jack_port_id_t myport = (jack_port_id_t)port;
  772. if (!CheckPort(myport)) {
  773. jack_error("jack_port_get_total_latency called with an incorrect port %ld", myport);
  774. return 0;
  775. } else {
  776. // The latency computation is done each time
  777. WaitGraphChange();
  778. return GetGraphManager()->GetTotalLatency(myport);
  779. }
  780. }
  781. EXPORT int jack_connect(jack_client_t* ext_client, const char* src, const char* dst)
  782. {
  783. #ifdef __CLIENTDEBUG__
  784. JackLibGlobals::CheckContext();
  785. #endif
  786. JackClient* client = (JackClient*)ext_client;
  787. if (client == NULL) {
  788. jack_error("jack_connect called with a NULL client");
  789. return -1;
  790. } else if ((src == NULL) || (dst == NULL)) {
  791. jack_error("jack_connect called with a NULL port name");
  792. return -1;
  793. } else {
  794. return client->PortConnect(src, dst);
  795. }
  796. }
  797. EXPORT int jack_disconnect(jack_client_t* ext_client, const char* src, const char* dst)
  798. {
  799. #ifdef __CLIENTDEBUG__
  800. JackLibGlobals::CheckContext();
  801. #endif
  802. JackClient* client = (JackClient*)ext_client;
  803. if (client == NULL) {
  804. jack_error("jack_disconnect called with a NULL client");
  805. return -1;
  806. } else if ((src == NULL) || (dst == NULL)) {
  807. jack_error("jack_connect called with a NULL port name");
  808. return -1;
  809. } else {
  810. return client->PortDisconnect(src, dst);
  811. }
  812. }
  813. EXPORT int jack_port_connect(jack_client_t* ext_client, jack_port_t* src, jack_port_t* dst)
  814. {
  815. #ifdef __CLIENTDEBUG__
  816. JackLibGlobals::CheckContext();
  817. #endif
  818. JackClient* client = (JackClient*)ext_client;
  819. if (client == NULL) {
  820. jack_error("jack_port_connect called with a NULL client");
  821. return -1;
  822. }
  823. jack_port_id_t mysrc = (jack_port_id_t)src;
  824. if (!CheckPort(mysrc)) {
  825. jack_error("jack_port_connect called with a NULL src port");
  826. return -1;
  827. }
  828. jack_port_id_t mydst = (jack_port_id_t)dst;
  829. if (!CheckPort(mydst)) {
  830. jack_error("jack_port_connect called with a NULL dst port");
  831. return -1;
  832. }
  833. return client->PortConnect(mysrc, mydst);
  834. }
  835. EXPORT int jack_port_disconnect(jack_client_t* ext_client, jack_port_t* src)
  836. {
  837. #ifdef __CLIENTDEBUG__
  838. JackLibGlobals::CheckContext();
  839. #endif
  840. JackClient* client = (JackClient*)ext_client;
  841. if (client == NULL) {
  842. jack_error("jack_port_disconnect called with a NULL client");
  843. return -1;
  844. }
  845. jack_port_id_t myport = (jack_port_id_t)src;
  846. if (!CheckPort(myport)) {
  847. jack_error("jack_port_disconnect called with an incorrect port %ld", myport);
  848. return -1;
  849. }
  850. return client->PortDisconnect(myport);
  851. }
  852. EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t* ext_client)
  853. {
  854. #ifdef __CLIENTDEBUG__
  855. JackLibGlobals::CheckContext();
  856. #endif
  857. JackClient* client = (JackClient*)ext_client;
  858. if (client == NULL) {
  859. jack_error("jack_get_sample_rate called with a NULL client");
  860. return 0;
  861. } else {
  862. return GetEngineControl()->fSampleRate;
  863. }
  864. }
  865. EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client)
  866. {
  867. #ifdef __CLIENTDEBUG__
  868. JackLibGlobals::CheckContext();
  869. #endif
  870. JackClient* client = (JackClient*)ext_client;
  871. if (client == NULL) {
  872. jack_error("jack_get_buffer_size called with a NULL client");
  873. return 0;
  874. } else {
  875. return GetEngineControl()->fBufferSize;
  876. }
  877. }
  878. EXPORT const char** jack_get_ports(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
  879. {
  880. #ifdef __CLIENTDEBUG__
  881. JackLibGlobals::CheckContext();
  882. #endif
  883. JackClient* client = (JackClient*)ext_client;
  884. if (client == NULL) {
  885. jack_error("jack_get_ports called with a NULL client");
  886. return NULL;
  887. }
  888. return GetGraphManager()->GetPorts(port_name_pattern, type_name_pattern, flags);
  889. }
  890. EXPORT jack_port_t* jack_port_by_name(jack_client_t* ext_client, const char* portname)
  891. {
  892. #ifdef __CLIENTDEBUG__
  893. JackLibGlobals::CheckContext();
  894. #endif
  895. JackClient* client = (JackClient*)ext_client;
  896. if (client == NULL) {
  897. jack_error("jack_get_ports called with a NULL client");
  898. return 0;
  899. }
  900. if (portname == NULL) {
  901. jack_error("jack_port_by_name called with a NULL port name");
  902. return NULL;
  903. } else {
  904. int res = GetGraphManager()->GetPort(portname); // returns a port index at least > 1
  905. return (res == NO_PORT) ? NULL : (jack_port_t*)res;
  906. }
  907. }
  908. EXPORT jack_port_t* jack_port_by_id(const jack_client_t* ext_client, jack_port_id_t id)
  909. {
  910. #ifdef __CLIENTDEBUG__
  911. JackLibGlobals::CheckContext();
  912. #endif
  913. /* jack_port_t* type is actually the port index */
  914. return (jack_port_t*)id;
  915. }
  916. EXPORT int jack_engine_takeover_timebase(jack_client_t* ext_client)
  917. {
  918. #ifdef __CLIENTDEBUG__
  919. JackLibGlobals::CheckContext();
  920. #endif
  921. JackClient* client = (JackClient*)ext_client;
  922. if (client == NULL) {
  923. jack_error("jack_engine_takeover_timebase called with a NULL client");
  924. return -1;
  925. } else {
  926. jack_error("jack_engine_takeover_timebase : not yet implemented\n");
  927. return 0;
  928. }
  929. }
  930. EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t* ext_client)
  931. {
  932. #ifdef __CLIENTDEBUG__
  933. JackLibGlobals::CheckContext();
  934. #endif
  935. JackTimer timer;
  936. GetEngineControl()->ReadFrameTime(&timer);
  937. return (jack_nframes_t) floor((((float)GetEngineControl()->fSampleRate) / 1000000.0f) * (GetMicroSeconds() - timer.fCurrentCallback));
  938. }
  939. EXPORT jack_nframes_t jack_frame_time(const jack_client_t* ext_client)
  940. {
  941. #ifdef __CLIENTDEBUG__
  942. JackLibGlobals::CheckContext();
  943. #endif
  944. JackClient* client = (JackClient*)ext_client;
  945. if (client == NULL) {
  946. jack_error("jack_frame_time called with a NULL client");
  947. return 0;
  948. } else {
  949. JackTimer timer;
  950. GetEngineControl()->ReadFrameTime(&timer);
  951. if (timer.fInitialized) {
  952. return timer.fFrames +
  953. (long) rint(((double) ((jack_time_t)(GetMicroSeconds() - timer.fCurrentWakeup)) /
  954. ((jack_time_t)(timer.fNextWakeUp - timer.fCurrentWakeup))) * GetEngineControl()->fBufferSize);
  955. } else {
  956. return 0;
  957. }
  958. }
  959. }
  960. EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
  961. {
  962. #ifdef __CLIENTDEBUG__
  963. JackLibGlobals::CheckContext();
  964. #endif
  965. JackTimer timer;
  966. GetEngineControl()->ReadFrameTime(&timer);
  967. return timer.fFrames;
  968. }
  969. EXPORT float jack_cpu_load(jack_client_t* ext_client)
  970. {
  971. #ifdef __CLIENTDEBUG__
  972. JackLibGlobals::CheckContext();
  973. #endif
  974. JackClient* client = (JackClient*)ext_client;
  975. if (client == NULL) {
  976. jack_error("jack_cpu_load called with a NULL client");
  977. return 0.0f;
  978. } else {
  979. return GetEngineControl()->fCPULoad;
  980. }
  981. }
  982. EXPORT pthread_t jack_client_thread_id(jack_client_t* ext_client)
  983. {
  984. #ifdef __CLIENTDEBUG__
  985. JackLibGlobals::CheckContext();
  986. #endif
  987. JackClient* client = (JackClient*)ext_client;
  988. if (client == NULL) {
  989. jack_error("jack_client_thread_id called with a NULL client");
  990. return (pthread_t)NULL;
  991. } else {
  992. return client->GetThreadID();
  993. }
  994. }
  995. EXPORT char* jack_get_client_name (jack_client_t* ext_client)
  996. {
  997. #ifdef __CLIENTDEBUG__
  998. JackLibGlobals::CheckContext();
  999. #endif
  1000. JackClient* client = (JackClient*)ext_client;
  1001. if (client == NULL) {
  1002. jack_error("jack_get_client_name called with a NULL client");
  1003. return NULL;
  1004. } else {
  1005. return client->GetClientControl()->fName;
  1006. }
  1007. }
  1008. EXPORT int jack_client_name_size(void)
  1009. {
  1010. return JACK_CLIENT_NAME_SIZE;
  1011. }
  1012. EXPORT int jack_port_name_size(void)
  1013. {
  1014. return JACK_PORT_NAME_SIZE;
  1015. }
  1016. // transport.h
  1017. EXPORT int jack_release_timebase(jack_client_t* ext_client)
  1018. {
  1019. #ifdef __CLIENTDEBUG__
  1020. JackLibGlobals::CheckContext();
  1021. #endif
  1022. JackClient* client = (JackClient*)ext_client;
  1023. if (client == NULL) {
  1024. jack_error("jack_release_timebase called with a NULL client");
  1025. return -1;
  1026. } else {
  1027. return client->ReleaseTimebase();
  1028. }
  1029. }
  1030. EXPORT int jack_set_sync_callback(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg)
  1031. {
  1032. #ifdef __CLIENTDEBUG__
  1033. JackLibGlobals::CheckContext();
  1034. #endif
  1035. JackClient* client = (JackClient*)ext_client;
  1036. if (client == NULL) {
  1037. jack_error("jack_set_sync_callback called with a NULL client");
  1038. return -1;
  1039. } else {
  1040. return client->SetSyncCallback(sync_callback, arg);
  1041. }
  1042. }
  1043. EXPORT int jack_set_sync_timeout(jack_client_t* ext_client, jack_time_t timeout)
  1044. {
  1045. #ifdef __CLIENTDEBUG__
  1046. JackLibGlobals::CheckContext();
  1047. #endif
  1048. JackClient* client = (JackClient*)ext_client;
  1049. if (client == NULL) {
  1050. jack_error("jack_set_sync_timeout called with a NULL client");
  1051. return -1;
  1052. } else {
  1053. return client->SetSyncTimeout(timeout);
  1054. }
  1055. }
  1056. EXPORT int jack_set_timebase_callback(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg)
  1057. {
  1058. #ifdef __CLIENTDEBUG__
  1059. JackLibGlobals::CheckContext();
  1060. #endif
  1061. JackClient* client = (JackClient*)ext_client;
  1062. if (client == NULL) {
  1063. jack_error("jack_set_timebase_callback called with a NULL client");
  1064. return -1;
  1065. } else {
  1066. return client->SetTimebaseCallback(conditional, timebase_callback, arg);
  1067. }
  1068. }
  1069. EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame)
  1070. {
  1071. #ifdef __CLIENTDEBUG__
  1072. JackLibGlobals::CheckContext();
  1073. #endif
  1074. JackClient* client = (JackClient*)ext_client;
  1075. if (client == NULL) {
  1076. jack_error("jack_transport_locate called with a NULL client");
  1077. return -1;
  1078. } else {
  1079. return client->TransportLocate(frame);
  1080. }
  1081. }
  1082. EXPORT jack_transport_state_t jack_transport_query(const jack_client_t* ext_client, jack_position_t* pos)
  1083. {
  1084. #ifdef __CLIENTDEBUG__
  1085. JackLibGlobals::CheckContext();
  1086. #endif
  1087. JackClient* client = (JackClient*)ext_client;
  1088. if (client == NULL) {
  1089. jack_error("jack_transport_query called with a NULL client");
  1090. return JackTransportStopped;
  1091. } else {
  1092. return client->TransportQuery(pos);
  1093. }
  1094. }
  1095. EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t* ext_client)
  1096. {
  1097. #ifdef __CLIENTDEBUG__
  1098. JackLibGlobals::CheckContext();
  1099. #endif
  1100. JackClient* client = (JackClient*)ext_client;
  1101. if (client == NULL) {
  1102. jack_error("jack_get_current_transport_frame called with a NULL client");
  1103. return 0;
  1104. } else {
  1105. return client->GetCurrentTransportFrame();
  1106. }
  1107. }
  1108. EXPORT int jack_transport_reposition(jack_client_t* ext_client, jack_position_t* pos)
  1109. {
  1110. #ifdef __CLIENTDEBUG__
  1111. JackLibGlobals::CheckContext();
  1112. #endif
  1113. JackClient* client = (JackClient*)ext_client;
  1114. if (client == NULL) {
  1115. jack_error("jack_transport_reposition called with a NULL client");
  1116. return -1;
  1117. } else {
  1118. return client->TransportReposition(pos);
  1119. }
  1120. }
  1121. EXPORT void jack_transport_start(jack_client_t* ext_client)
  1122. {
  1123. #ifdef __CLIENTDEBUG__
  1124. JackLibGlobals::CheckContext();
  1125. #endif
  1126. JackClient* client = (JackClient*)ext_client;
  1127. if (client == NULL) {
  1128. jack_error("jack_transport_start called with a NULL client");
  1129. } else {
  1130. client->TransportStart();
  1131. }
  1132. }
  1133. EXPORT void jack_transport_stop(jack_client_t* ext_client)
  1134. {
  1135. #ifdef __CLIENTDEBUG__
  1136. JackLibGlobals::CheckContext();
  1137. #endif
  1138. JackClient* client = (JackClient*)ext_client;
  1139. if (client == NULL) {
  1140. jack_error("jack_transport_stop called with a NULL client");
  1141. } else {
  1142. client->TransportStop();
  1143. }
  1144. }
  1145. // deprecated
  1146. EXPORT void jack_get_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  1147. {
  1148. JackLog("jack_get_transport_info : deprecated");
  1149. if (tinfo)
  1150. memset(tinfo, 0, sizeof(jack_transport_info_t));
  1151. }
  1152. EXPORT void jack_set_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
  1153. {
  1154. JackLog("jack_set_transport_info : deprecated");
  1155. if (tinfo)
  1156. memset(tinfo, 0, sizeof(jack_transport_info_t));
  1157. }
  1158. // statistics.h
  1159. EXPORT float jack_get_max_delayed_usecs(jack_client_t* ext_client)
  1160. {
  1161. #ifdef __CLIENTDEBUG__
  1162. JackLibGlobals::CheckContext();
  1163. #endif
  1164. JackLog("jack_get_max_delayed_usecs: not yet implemented\n");
  1165. return 0.f;
  1166. }
  1167. EXPORT float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
  1168. {
  1169. #ifdef __CLIENTDEBUG__
  1170. JackLibGlobals::CheckContext();
  1171. #endif
  1172. JackLog("jack_get_xrun_delayed_usecs: not yet implemented\n");
  1173. return 0.f;
  1174. }
  1175. EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
  1176. {
  1177. #ifdef __CLIENTDEBUG__
  1178. JackLibGlobals::CheckContext();
  1179. #endif
  1180. JackLog("jack_reset_max_delayed_usecs: not yet implemented\n");
  1181. }
  1182. // thread.h
  1183. EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority)
  1184. {
  1185. #ifdef __APPLE__
  1186. return JackMachThread::AcquireRealTimeImp(thread, 0, 500 * 1000, 500 * 1000);
  1187. #elif WIN32
  1188. return JackWinThread::AcquireRealTimeImp(thread, priority);
  1189. #else
  1190. return JackPosixThread::AcquireRealTimeImp(thread, priority);
  1191. #endif
  1192. }
  1193. EXPORT int jack_client_create_thread(jack_client_t* client,
  1194. pthread_t *thread,
  1195. int priority,
  1196. int realtime, /* boolean */
  1197. void *(*start_routine)(void*),
  1198. void *arg)
  1199. {
  1200. #ifdef __APPLE__
  1201. return JackPosixThread::StartImp(thread, priority, realtime, start_routine, arg);
  1202. #elif WIN32
  1203. return JackWinThread::StartImp(thread, priority, realtime, (ThreadCallback)start_routine, arg);
  1204. #else
  1205. return JackPosixThread::StartImp(thread, priority, realtime, start_routine, arg);
  1206. #endif
  1207. }
  1208. EXPORT int jack_drop_real_time_scheduling(pthread_t thread)
  1209. {
  1210. #ifdef __APPLE__
  1211. return JackMachThread::DropRealTimeImp(thread);
  1212. #elif WIN32
  1213. return JackWinThread::DropRealTimeImp(thread);
  1214. #else
  1215. return JackPosixThread::DropRealTimeImp(thread);
  1216. #endif
  1217. }
  1218. // intclient.h
  1219. EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
  1220. {
  1221. JackLog("jack_get_internal_client_name: not yet implemented\n");
  1222. return "";
  1223. }
  1224. EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, const char* client_name, jack_status_t* status)
  1225. {
  1226. JackLog("jack_internal_client_handle: not yet implemented\n");
  1227. return 0;
  1228. }
  1229. EXPORT jack_intclient_t jack_internal_client_load(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, ...)
  1230. {
  1231. JackLog("jack_internal_client_load: not yet implemented\n");
  1232. return 0;
  1233. }
  1234. EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
  1235. {
  1236. JackLog("jack_internal_client_unload: not yet implemented\n");
  1237. return JackFailure;
  1238. }