00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "JackClient.h"
00022 #include "JackError.h"
00023 #include "JackGraphManager.h"
00024 #include "JackEngineControl.h"
00025 #include "JackClientControl.h"
00026 #include "JackGlobals.h"
00027 #include "JackTime.h"
00028 #include "JackCompilerDeps.h"
00029 #include "JackPortType.h"
00030 #include "JackPlatformPlug.h"
00031 #include <math.h>
00032
00033 #ifdef __CLIENTDEBUG__
00034 #include "JackLibGlobals.h"
00035 #endif
00036
00037 using namespace Jack;
00038
00039 #ifdef __cplusplus
00040 extern "C"
00041 {
00042 #endif
00043
00044 typedef void (*print_function)(const char *);
00045 typedef void *(*thread_routine)(void*);
00046
00047 EXPORT
00048 void
00049 jack_get_version(
00050 int *major_ptr,
00051 int *minor_ptr,
00052 int *micro_ptr,
00053 int *proto_ptr);
00054
00055 EXPORT
00056 const char *
00057 jack_get_version_string();
00058
00059 EXPORT jack_client_t * jack_client_open_aux (const char *client_name,
00060 jack_options_t options,
00061 jack_status_t *status, va_list ap);
00062 EXPORT jack_client_t * jack_client_open (const char *client_name,
00063 jack_options_t options,
00064 jack_status_t *status, ...);
00065 EXPORT jack_client_t * jack_client_new (const char *client_name);
00066 EXPORT int jack_client_name_size (void);
00067 EXPORT char* jack_get_client_name (jack_client_t *client);
00068 EXPORT int jack_internal_client_new (const char *client_name,
00069 const char *load_name,
00070 const char *load_init);
00071 EXPORT void jack_internal_client_close (const char *client_name);
00072 EXPORT int jack_is_realtime (jack_client_t *client);
00073 EXPORT void jack_on_shutdown (jack_client_t *client,
00074 JackShutdownCallback shutdown_callback, void *arg);
00075 EXPORT int jack_set_process_callback (jack_client_t *client,
00076 JackProcessCallback process_callback,
00077 void *arg);
00078 EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status);
00079
00080
00081 EXPORT jack_nframes_t jack_cycle_wait (jack_client_t*);
00082 EXPORT void jack_cycle_signal (jack_client_t*, int status);
00083 EXPORT int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg);
00084
00085 EXPORT int jack_set_thread_init_callback (jack_client_t *client,
00086 JackThreadInitCallback thread_init_callback,
00087 void *arg);
00088 EXPORT int jack_set_freewheel_callback (jack_client_t *client,
00089 JackFreewheelCallback freewheel_callback,
00090 void *arg);
00091 EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
00092 EXPORT int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
00093 EXPORT int jack_set_buffer_size_callback (jack_client_t *client,
00094 JackBufferSizeCallback bufsize_callback,
00095 void *arg);
00096 EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
00097 JackSampleRateCallback srate_callback,
00098 void *arg);
00099 EXPORT int jack_set_client_registration_callback (jack_client_t *,
00100 JackClientRegistrationCallback
00101 registration_callback, void *arg);
00102 EXPORT int jack_set_port_registration_callback (jack_client_t *,
00103 JackPortRegistrationCallback
00104 registration_callback, void *arg);
00105 EXPORT int jack_set_port_connect_callback (jack_client_t *,
00106 JackPortConnectCallback
00107 connect_callback, void *arg);
00108 EXPORT int jack_set_port_rename_callback (jack_client_t *,
00109 JackPortRenameCallback
00110 rename_callback, void *arg);
00111 EXPORT int jack_set_graph_order_callback (jack_client_t *,
00112 JackGraphOrderCallback graph_callback,
00113 void *);
00114 EXPORT int jack_set_xrun_callback (jack_client_t *,
00115 JackXRunCallback xrun_callback, void *arg);
00116 EXPORT int jack_activate (jack_client_t *client);
00117 EXPORT int jack_deactivate (jack_client_t *client);
00118 EXPORT jack_port_t * jack_port_register (jack_client_t *client,
00119 const char *port_name,
00120 const char *port_type,
00121 unsigned long flags,
00122 unsigned long buffer_size);
00123 EXPORT int jack_port_unregister (jack_client_t *, jack_port_t *);
00124 EXPORT void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
00125 EXPORT const char * jack_port_name (const jack_port_t *port);
00126 EXPORT const char * jack_port_short_name (const jack_port_t *port);
00127 EXPORT int jack_port_flags (const jack_port_t *port);
00128 EXPORT const char * jack_port_type (const jack_port_t *port);
00129 EXPORT jack_port_type_id_t jack_port_type_id (const jack_port_t *port);
00130 EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
00131 EXPORT int jack_port_connected (const jack_port_t *port);
00132 EXPORT int jack_port_connected_to (const jack_port_t *port,
00133 const char *port_name);
00134 EXPORT const char ** jack_port_get_connections (const jack_port_t *port);
00135 EXPORT const char ** jack_port_get_all_connections (const jack_client_t *client,
00136 const jack_port_t *port);
00137 EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst);
00138 EXPORT int jack_port_untie (jack_port_t *port);
00139 EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port);
00140 EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *,
00141 jack_port_t *port);
00142 EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t);
00143 EXPORT int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
00144 EXPORT int jack_recompute_total_latencies (jack_client_t*);
00145 EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name);
00146 EXPORT int jack_port_set_alias (jack_port_t *port, const char *alias);
00147 EXPORT int jack_port_unset_alias (jack_port_t *port, const char *alias);
00148 EXPORT int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
00149 EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff);
00150 EXPORT int jack_port_request_monitor_by_name (jack_client_t *client,
00151 const char *port_name, int onoff);
00152 EXPORT int jack_port_ensure_monitor (jack_port_t *port, int onoff);
00153 EXPORT int jack_port_monitoring_input (jack_port_t *port);
00154 EXPORT int jack_connect (jack_client_t *,
00155 const char *source_port,
00156 const char *destination_port);
00157 EXPORT int jack_disconnect (jack_client_t *,
00158 const char *source_port,
00159 const char *destination_port);
00160 EXPORT int jack_port_disconnect (jack_client_t *, jack_port_t *);
00161 EXPORT int jack_port_name_size(void);
00162 EXPORT int jack_port_type_size(void);
00163 EXPORT jack_nframes_t jack_get_sample_rate (jack_client_t *);
00164 EXPORT jack_nframes_t jack_get_buffer_size (jack_client_t *);
00165 EXPORT const char ** jack_get_ports (jack_client_t *,
00166 const char *port_name_pattern,
00167 const char *type_name_pattern,
00168 unsigned long flags);
00169 EXPORT jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
00170 EXPORT jack_port_t * jack_port_by_id (jack_client_t *client,
00171 jack_port_id_t port_id);
00172 EXPORT int jack_engine_takeover_timebase (jack_client_t *);
00173 EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
00174 EXPORT jack_time_t jack_get_time();
00175 EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t time);
00176 EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames);
00177 EXPORT jack_nframes_t jack_frame_time (const jack_client_t *);
00178 EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client);
00179 EXPORT float jack_cpu_load (jack_client_t *client);
00180 EXPORT pthread_t jack_client_thread_id (jack_client_t *);
00181 EXPORT void jack_set_error_function (print_function);
00182 EXPORT void jack_set_info_function (print_function);
00183
00184 EXPORT float jack_get_max_delayed_usecs (jack_client_t *client);
00185 EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client);
00186 EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client);
00187
00188 EXPORT int jack_release_timebase (jack_client_t *client);
00189 EXPORT int jack_set_sync_callback (jack_client_t *client,
00190 JackSyncCallback sync_callback,
00191 void *arg);
00192 EXPORT int jack_set_sync_timeout (jack_client_t *client,
00193 jack_time_t timeout);
00194 EXPORT int jack_set_timebase_callback (jack_client_t *client,
00195 int conditional,
00196 JackTimebaseCallback timebase_callback,
00197 void *arg);
00198 EXPORT int jack_transport_locate (jack_client_t *client,
00199 jack_nframes_t frame);
00200 EXPORT jack_transport_state_t jack_transport_query (const jack_client_t *client,
00201 jack_position_t *pos);
00202 EXPORT jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
00203 EXPORT int jack_transport_reposition (jack_client_t *client,
00204 jack_position_t *pos);
00205 EXPORT void jack_transport_start (jack_client_t *client);
00206 EXPORT void jack_transport_stop (jack_client_t *client);
00207 EXPORT void jack_get_transport_info (jack_client_t *client,
00208 jack_transport_info_t *tinfo);
00209 EXPORT void jack_set_transport_info (jack_client_t *client,
00210 jack_transport_info_t *tinfo);
00211
00212 EXPORT int jack_client_real_time_priority (jack_client_t*);
00213 EXPORT int jack_client_max_real_time_priority (jack_client_t*);
00214 EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
00215 EXPORT int jack_client_create_thread (jack_client_t* client,
00216 pthread_t *thread,
00217 int priority,
00218 int realtime,
00219 thread_routine routine,
00220 void *arg);
00221 EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
00222
00223 EXPORT int jack_client_stop_thread (jack_client_t* client, pthread_t thread);
00224 EXPORT int jack_client_kill_thread (jack_client_t* client, pthread_t thread);
00225
00226 EXPORT char * jack_get_internal_client_name (jack_client_t *client,
00227 jack_intclient_t intclient);
00228 EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client,
00229 const char *client_name,
00230 jack_status_t *status);
00231 EXPORT jack_intclient_t jack_internal_client_load (jack_client_t *client,
00232 const char *client_name,
00233 jack_options_t options,
00234 jack_status_t *status, ...);
00235 EXPORT jack_intclient_t jack_internal_client_load_aux (jack_client_t *client,
00236 const char *client_name,
00237 jack_options_t options,
00238 jack_status_t *status, va_list ap);
00239
00240 EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
00241 jack_intclient_t intclient);
00242
00243 #ifdef __cplusplus
00244 }
00245 #endif
00246
00247 static inline bool CheckPort(jack_port_id_t port_index)
00248 {
00249 return (port_index > 0 && port_index < PORT_NUM);
00250 }
00251
00252 static inline bool CheckBufferSize(jack_nframes_t buffer_size)
00253 {
00254 return (buffer_size <= BUFFER_SIZE_MAX);
00255 }
00256
00257 static inline void WaitGraphChange()
00258 {
00259
00260
00261
00262
00263
00264 if (jack_tls_get(JackGlobals::fRealTime) == NULL) {
00265 JackGraphManager* manager = GetGraphManager();
00266 JackEngineControl* control = GetEngineControl();
00267 assert(manager);
00268 assert(control);
00269 if (manager->IsPendingChange()) {
00270 jack_log("WaitGraphChange...");
00271 JackSleep(int(control->fPeriodUsecs * 1.1f));
00272 }
00273 }
00274 }
00275
00276 EXPORT void jack_set_error_function (print_function func)
00277 {
00278 jack_error_callback = func;
00279 }
00280
00281 EXPORT void jack_set_info_function (print_function func)
00282 {
00283 jack_info_callback = func;
00284 }
00285
00286 EXPORT jack_client_t* jack_client_new(const char* client_name)
00287 {
00288 assert(JackGlobals::fOpenMutex);
00289 JackGlobals::fOpenMutex->Lock();
00290 jack_error("jack_client_new: deprecated");
00291 int options = JackUseExactName;
00292 if (getenv("JACK_START_SERVER") == NULL)
00293 options |= JackNoStartServer;
00294 jack_client_t* res = jack_client_open_aux(client_name, (jack_options_t)options, NULL, NULL);
00295 JackGlobals::fOpenMutex->Unlock();
00296 return res;
00297 }
00298
00299 EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
00300 {
00301 #ifdef __CLIENTDEBUG__
00302 JackLibGlobals::CheckContext();
00303 #endif
00304 #if defined(__x86_64__) || defined(__ppc64__)
00305 uint64_t port_aux = (uint64_t)port;
00306 #else
00307 uint32_t port_aux = (uint32_t)port;
00308 #endif
00309 jack_port_id_t myport = (jack_port_id_t)port_aux;
00310 if (!CheckPort(myport)) {
00311 jack_error("jack_port_get_buffer called with an incorrect port %ld", myport);
00312 return NULL;
00313 } else {
00314 JackGraphManager* manager = GetGraphManager();
00315 return (manager ? manager->GetBuffer(myport, frames) : NULL);
00316 }
00317 }
00318
00319 EXPORT const char* jack_port_name(const jack_port_t* port)
00320 {
00321 #ifdef __CLIENTDEBUG__
00322 JackLibGlobals::CheckContext();
00323 #endif
00324 #if defined(__x86_64__) || defined(__ppc64__)
00325 uint64_t port_aux = (uint64_t)port;
00326 #else
00327 uint32_t port_aux = (uint32_t)port;
00328 #endif
00329 jack_port_id_t myport = (jack_port_id_t)port_aux;
00330 if (!CheckPort(myport)) {
00331 jack_error("jack_port_name called with an incorrect port %ld", myport);
00332 return NULL;
00333 } else {
00334 JackGraphManager* manager = GetGraphManager();
00335 return (manager ? manager->GetPort(myport)->GetName() : NULL);
00336 }
00337 }
00338
00339 EXPORT const char* jack_port_short_name(const jack_port_t* port)
00340 {
00341 #ifdef __CLIENTDEBUG__
00342 JackLibGlobals::CheckContext();
00343 #endif
00344 #if defined(__x86_64__) || defined(__ppc64__)
00345 uint64_t port_aux = (uint64_t)port;
00346 #else
00347 uint32_t port_aux = (uint32_t)port;
00348 #endif
00349 jack_port_id_t myport = (jack_port_id_t)port_aux;
00350 if (!CheckPort(myport)) {
00351 jack_error("jack_port_short_name called with an incorrect port %ld", myport);
00352 return NULL;
00353 } else {
00354 JackGraphManager* manager = GetGraphManager();
00355 return (manager ? manager->GetPort(myport)->GetShortName() : NULL);
00356 }
00357 }
00358
00359 EXPORT int jack_port_flags(const jack_port_t* port)
00360 {
00361 #ifdef __CLIENTDEBUG__
00362 JackLibGlobals::CheckContext();
00363 #endif
00364 #if defined(__x86_64__) || defined(__ppc64__)
00365 uint64_t port_aux = (uint64_t)port;
00366 #else
00367 uint32_t port_aux = (uint32_t)port;
00368 #endif
00369 jack_port_id_t myport = (jack_port_id_t)port_aux;
00370 if (!CheckPort(myport)) {
00371 jack_error("jack_port_flags called with an incorrect port %ld", myport);
00372 return -1;
00373 } else {
00374 JackGraphManager* manager = GetGraphManager();
00375 return (manager ? manager->GetPort(myport)->GetFlags() : -1);
00376 }
00377 }
00378
00379 EXPORT const char* jack_port_type(const jack_port_t* port)
00380 {
00381 #ifdef __CLIENTDEBUG__
00382 JackLibGlobals::CheckContext();
00383 #endif
00384 #if defined(__x86_64__) || defined(__ppc64__)
00385 uint64_t port_aux = (uint64_t)port;
00386 #else
00387 uint32_t port_aux = (uint32_t)port;
00388 #endif
00389 jack_port_id_t myport = (jack_port_id_t)port_aux;
00390 if (!CheckPort(myport)) {
00391 jack_error("jack_port_flags called an incorrect port %ld", myport);
00392 return NULL;
00393 } else {
00394 JackGraphManager* manager = GetGraphManager();
00395 return (manager ? manager->GetPort(myport)->GetType() : NULL);
00396 }
00397 }
00398
00399 EXPORT jack_port_type_id_t jack_port_type_id(const jack_port_t *port)
00400 {
00401 #ifdef __CLIENTDEBUG__
00402 JackLibGlobals::CheckContext();
00403 #endif
00404 #if defined(__x86_64__) || defined(__ppc64__)
00405 uint64_t port_aux = (uint64_t)port;
00406 #else
00407 uint32_t port_aux = (uint32_t)port;
00408 #endif
00409 jack_port_id_t myport = (jack_port_id_t)port_aux;
00410 if (!CheckPort(myport)) {
00411 jack_error("jack_port_type_id called an incorrect port %ld", myport);
00412 return 0;
00413 } else {
00414 JackGraphManager* manager = GetGraphManager();
00415 return (manager ? GetPortTypeId(manager->GetPort(myport)->GetType()) : 0);
00416 }
00417 }
00418
00419 EXPORT int jack_port_connected(const jack_port_t* port)
00420 {
00421 #ifdef __CLIENTDEBUG__
00422 JackLibGlobals::CheckContext();
00423 #endif
00424 #if defined(__x86_64__) || defined(__ppc64__)
00425 uint64_t port_aux = (uint64_t)port;
00426 #else
00427 uint32_t port_aux = (uint32_t)port;
00428 #endif
00429 jack_port_id_t myport = (jack_port_id_t)port_aux;
00430 if (!CheckPort(myport)) {
00431 jack_error("jack_port_connected called with an incorrect port %ld", myport);
00432 return -1;
00433 } else {
00434 WaitGraphChange();
00435 JackGraphManager* manager = GetGraphManager();
00436 return (manager ? manager->GetConnectionsNum(myport) : -1);
00437 }
00438 }
00439
00440 EXPORT int jack_port_connected_to(const jack_port_t* port, const char* port_name)
00441 {
00442 #ifdef __CLIENTDEBUG__
00443 JackLibGlobals::CheckContext();
00444 #endif
00445 #if defined(__x86_64__) || defined(__ppc64__)
00446 uint64_t port_aux = (uint64_t)port;
00447 #else
00448 uint32_t port_aux = (uint32_t)port;
00449 #endif
00450 jack_port_id_t src = (jack_port_id_t)port_aux;
00451 if (!CheckPort(src)) {
00452 jack_error("jack_port_connected_to called with an incorrect port %ld", src);
00453 return -1;
00454 } else if (port_name == NULL) {
00455 jack_error("jack_port_connected_to called with a NULL port name");
00456 return -1;
00457 } else {
00458 WaitGraphChange();
00459 JackGraphManager* manager = GetGraphManager();
00460 jack_port_id_t dst = (manager ? manager->GetPort(port_name) : NO_PORT);
00461 if (dst == NO_PORT) {
00462 jack_error("Unknown destination port port_name = %s", port_name);
00463 return 0;
00464 } else {
00465 return manager->IsConnected(src, dst);
00466 }
00467 }
00468 }
00469
00470 EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
00471 {
00472 #ifdef __CLIENTDEBUG__
00473 JackLibGlobals::CheckContext();
00474 #endif
00475 #if defined(__x86_64__) || defined(__ppc64__)
00476 uint64_t src_aux = (uint64_t)src;
00477 #else
00478 uint32_t src_aux = (uint32_t)src;
00479 #endif
00480 jack_port_id_t mysrc = (jack_port_id_t)src_aux;
00481 if (!CheckPort(mysrc)) {
00482 jack_error("jack_port_tie called with a NULL src port");
00483 return -1;
00484 }
00485 #if defined(__x86_64__) || defined(__ppc64__)
00486 uint64_t dst_aux = (uint64_t)dst;
00487 #else
00488 uint32_t dst_aux = (uint32_t)dst;
00489 #endif
00490 jack_port_id_t mydst = (jack_port_id_t)dst_aux;
00491 if (!CheckPort(mydst)) {
00492 jack_error("jack_port_tie called with a NULL dst port");
00493 return -1;
00494 }
00495 JackGraphManager* manager = GetGraphManager();
00496 if (manager && manager->GetPort(mysrc)->GetRefNum() != manager->GetPort(mydst)->GetRefNum()) {
00497 jack_error("jack_port_tie called with ports not belonging to the same client");
00498 return -1;
00499 } else {
00500 return manager->GetPort(mydst)->Tie(mysrc);
00501 }
00502 }
00503
00504 EXPORT int jack_port_untie(jack_port_t* port)
00505 {
00506 #ifdef __CLIENTDEBUG__
00507 JackLibGlobals::CheckContext();
00508 #endif
00509 #if defined(__x86_64__) || defined(__ppc64__)
00510 uint64_t port_aux = (uint64_t)port;
00511 #else
00512 uint32_t port_aux = (uint32_t)port;
00513 #endif
00514 jack_port_id_t myport = (jack_port_id_t)port_aux;
00515 if (!CheckPort(myport)) {
00516 jack_error("jack_port_untie called with an incorrect port %ld", myport);
00517 return -1;
00518 } else {
00519 JackGraphManager* manager = GetGraphManager();
00520 return (manager ? manager->GetPort(myport)->UnTie() : -1);
00521 }
00522 }
00523
00524 EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
00525 {
00526 #ifdef __CLIENTDEBUG__
00527 JackLibGlobals::CheckContext();
00528 #endif
00529 #if defined(__x86_64__) || defined(__ppc64__)
00530 uint64_t port_aux = (uint64_t)port;
00531 #else
00532 uint32_t port_aux = (uint32_t)port;
00533 #endif
00534 jack_port_id_t myport = (jack_port_id_t)port_aux;
00535 if (!CheckPort(myport)) {
00536 jack_error("jack_port_get_latency called with an incorrect port %ld", myport);
00537 return 0;
00538 } else {
00539 WaitGraphChange();
00540 JackGraphManager* manager = GetGraphManager();
00541 return (manager ? manager->GetPort(myport)->GetLatency() : 0);
00542 }
00543 }
00544
00545 EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
00546 {
00547 #ifdef __CLIENTDEBUG__
00548 JackLibGlobals::CheckContext();
00549 #endif
00550 #if defined(__x86_64__) || defined(__ppc64__)
00551 uint64_t port_aux = (uint64_t)port;
00552 #else
00553 uint32_t port_aux = (uint32_t)port;
00554 #endif
00555 jack_port_id_t myport = (jack_port_id_t)port_aux;
00556 if (!CheckPort(myport)) {
00557 jack_error("jack_port_set_latency called with an incorrect port %ld", myport);
00558 } else {
00559 JackGraphManager* manager = GetGraphManager();
00560 if (manager)
00561 manager->GetPort(myport)->SetLatency(frames);
00562 }
00563 }
00564
00565 EXPORT int jack_recompute_total_latency(jack_client_t* ext_client, jack_port_t* port)
00566 {
00567 #ifdef __CLIENTDEBUG__
00568 JackLibGlobals::CheckContext();
00569 #endif
00570
00571 JackClient* client = (JackClient*)ext_client;
00572 #if defined(__x86_64__) || defined(__ppc64__)
00573 uint64_t port_aux = (uint64_t)port;
00574 #else
00575 uint32_t port_aux = (uint32_t)port;
00576 #endif
00577 jack_port_id_t myport = (jack_port_id_t)port_aux;
00578 if (client == NULL) {
00579 jack_error("jack_recompute_total_latencies called with a NULL client");
00580 return -1;
00581 } else if (!CheckPort(myport)) {
00582 jack_error("jack_recompute_total_latencies called with a NULL port");
00583 return -1;
00584 } else {
00585 WaitGraphChange();
00586 JackGraphManager* manager = GetGraphManager();
00587 return (manager ? manager->ComputeTotalLatency(myport) : -1);
00588 }
00589 }
00590
00591 EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
00592 {
00593 #ifdef __CLIENTDEBUG__
00594 JackLibGlobals::CheckContext();
00595 #endif
00596
00597 JackClient* client = (JackClient*)ext_client;
00598 if (client == NULL) {
00599 jack_error("jack_recompute_total_latencies called with a NULL client");
00600 return -1;
00601 } else {
00602 WaitGraphChange();
00603 JackGraphManager* manager = GetGraphManager();
00604 return (manager ? manager->ComputeTotalLatencies() : -1);
00605 }
00606 }
00607
00608
00609
00610
00611
00612 EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
00613 {
00614 #ifdef __CLIENTDEBUG__
00615 JackLibGlobals::CheckContext();
00616 #endif
00617 #if defined(__x86_64__) || defined(__ppc64__)
00618 uint64_t port_aux = (uint64_t)port;
00619 #else
00620 uint32_t port_aux = (uint32_t)port;
00621 #endif
00622 jack_port_id_t myport = (jack_port_id_t)port_aux;
00623 if (!CheckPort(myport)) {
00624 jack_error("jack_port_set_name called with an incorrect port %ld", myport);
00625 return -1;
00626 } else if (name == NULL) {
00627 jack_error("jack_port_set_name called with a NULL port name");
00628 return -1;
00629 } else {
00630 JackGraphManager* manager = GetGraphManager();
00631 int refnum;
00632 if (manager && ((refnum = manager->GetPort(myport)->GetRefNum()) > 0)) {
00633 JackClient* client = JackGlobals::fClientTable[refnum];
00634 assert(client);
00635 return client->PortRename(myport, name);
00636 } else {
00637 return -1;
00638 }
00639 }
00640 }
00641
00642 EXPORT int jack_port_set_alias(jack_port_t* port, const char* name)
00643 {
00644 #ifdef __CLIENTDEBUG__
00645 JackLibGlobals::CheckContext();
00646 #endif
00647 #if defined(__x86_64__) || defined(__ppc64__)
00648 uint64_t port_aux = (uint64_t)port;
00649 #else
00650 uint32_t port_aux = (uint32_t)port;
00651 #endif
00652 jack_port_id_t myport = (jack_port_id_t)port_aux;
00653 if (!CheckPort(myport)) {
00654 jack_error("jack_port_set_alias called with an incorrect port %ld", myport);
00655 return -1;
00656 } else if (name == NULL) {
00657 jack_error("jack_port_set_alias called with a NULL port name");
00658 return -1;
00659 } else {
00660 JackGraphManager* manager = GetGraphManager();
00661 return (manager ? manager->GetPort(myport)->SetAlias(name) : -1);
00662 }
00663 }
00664
00665 EXPORT int jack_port_unset_alias(jack_port_t* port, const char* name)
00666 {
00667 #ifdef __CLIENTDEBUG__
00668 JackLibGlobals::CheckContext();
00669 #endif
00670 #if defined(__x86_64__) || defined(__ppc64__)
00671 uint64_t port_aux = (uint64_t)port;
00672 #else
00673 uint32_t port_aux = (uint32_t)port;
00674 #endif
00675 jack_port_id_t myport = (jack_port_id_t)port_aux;
00676 if (!CheckPort(myport)) {
00677 jack_error("jack_port_unset_alias called with an incorrect port %ld", myport);
00678 return -1;
00679 } else if (name == NULL) {
00680 jack_error("jack_port_unset_alias called with a NULL port name");
00681 return -1;
00682 } else {
00683 JackGraphManager* manager = GetGraphManager();
00684 return (manager ? manager->GetPort(myport)->UnsetAlias(name) : -1);
00685 }
00686 }
00687
00688 EXPORT int jack_port_get_aliases(const jack_port_t* port, char* const aliases[2])
00689 {
00690 #ifdef __CLIENTDEBUG__
00691 JackLibGlobals::CheckContext();
00692 #endif
00693 #if defined(__x86_64__) || defined(__ppc64__)
00694 uint64_t port_aux = (uint64_t)port;
00695 #else
00696 uint32_t port_aux = (uint32_t)port;
00697 #endif
00698 jack_port_id_t myport = (jack_port_id_t)port_aux;
00699 if (!CheckPort(myport)) {
00700 jack_error("jack_port_get_aliases called with an incorrect port %ld", myport);
00701 return -1;
00702 } else {
00703 JackGraphManager* manager = GetGraphManager();
00704 return (manager ? manager->GetPort(myport)->GetAliases(aliases) : -1);
00705 }
00706 }
00707
00708 EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
00709 {
00710 #ifdef __CLIENTDEBUG__
00711 JackLibGlobals::CheckContext();
00712 #endif
00713 #if defined(__x86_64__) || defined(__ppc64__)
00714 uint64_t port_aux = (uint64_t)port;
00715 #else
00716 uint32_t port_aux = (uint32_t)port;
00717 #endif
00718 jack_port_id_t myport = (jack_port_id_t)port_aux;
00719 if (!CheckPort(myport)) {
00720 jack_error("jack_port_request_monitor called with an incorrect port %ld", myport);
00721 return -1;
00722 } else {
00723 JackGraphManager* manager = GetGraphManager();
00724 return (manager ? manager->RequestMonitor(myport, onoff) : -1);
00725 }
00726 }
00727
00728 EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
00729 {
00730 #ifdef __CLIENTDEBUG__
00731 JackLibGlobals::CheckContext();
00732 #endif
00733 JackClient* client = (JackClient*)ext_client;
00734 if (client == NULL) {
00735 jack_error("jack_port_request_monitor_by_name called with a NULL client");
00736 return -1;
00737 } else {
00738 JackGraphManager* manager = GetGraphManager();
00739 if (!manager)
00740 return -1;
00741 jack_port_id_t myport = manager->GetPort(port_name);
00742 if (!CheckPort(myport)) {
00743 jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
00744 return -1;
00745 } else {
00746 return manager->RequestMonitor(myport, onoff);
00747 }
00748 }
00749 }
00750
00751 EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
00752 {
00753 #ifdef __CLIENTDEBUG__
00754 JackLibGlobals::CheckContext();
00755 #endif
00756 #if defined(__x86_64__) || defined(__ppc64__)
00757 uint64_t port_aux = (uint64_t)port;
00758 #else
00759 uint32_t port_aux = (uint32_t)port;
00760 #endif
00761 jack_port_id_t myport = (jack_port_id_t)port_aux;
00762 if (!CheckPort(myport)) {
00763 jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport);
00764 return -1;
00765 } else {
00766 JackGraphManager* manager = GetGraphManager();
00767 return (manager ? manager->GetPort(myport)->EnsureMonitor(onoff) : -1);
00768 }
00769 }
00770
00771 EXPORT int jack_port_monitoring_input(jack_port_t* port)
00772 {
00773 #ifdef __CLIENTDEBUG__
00774 JackLibGlobals::CheckContext();
00775 #endif
00776 #if defined(__x86_64__) || defined(__ppc64__)
00777 uint64_t port_aux = (uint64_t)port;
00778 #else
00779 uint32_t port_aux = (uint32_t)port;
00780 #endif
00781 jack_port_id_t myport = (jack_port_id_t)port_aux;
00782 if (!CheckPort(myport)) {
00783 jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport);
00784 return -1;
00785 } else {
00786 JackGraphManager* manager = GetGraphManager();
00787 return (manager ? manager->GetPort(myport)->MonitoringInput() : -1);
00788 }
00789 }
00790
00791 EXPORT int jack_is_realtime(jack_client_t* ext_client)
00792 {
00793 #ifdef __CLIENTDEBUG__
00794 JackLibGlobals::CheckContext();
00795 #endif
00796 JackClient* client = (JackClient*)ext_client;
00797 if (client == NULL) {
00798 jack_error("jack_is_realtime called with a NULL client");
00799 return -1;
00800 } else {
00801 JackEngineControl* control = GetEngineControl();
00802 return (control ? control->fRealTime : -1);
00803 }
00804 }
00805
00806 EXPORT void jack_on_shutdown(jack_client_t* ext_client, JackShutdownCallback callback, void* arg)
00807 {
00808 #ifdef __CLIENTDEBUG__
00809 JackLibGlobals::CheckContext();
00810 #endif
00811 JackClient* client = (JackClient*)ext_client;
00812 if (client == NULL) {
00813 jack_error("jack_on_shutdown called with a NULL client");
00814 } else {
00815 client->OnShutdown(callback, arg);
00816 }
00817 }
00818
00819 EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
00820 {
00821 #ifdef __CLIENTDEBUG__
00822 JackLibGlobals::CheckContext();
00823 #endif
00824 JackClient* client = (JackClient*)ext_client;
00825 if (client == NULL) {
00826 jack_error("jack_set_process_callback called with a NULL client");
00827 return -1;
00828 } else {
00829 return client->SetProcessCallback(callback, arg);
00830 }
00831 }
00832
00833 EXPORT jack_nframes_t jack_thread_wait(jack_client_t* ext_client, int status)
00834 {
00835 #ifdef __CLIENTDEBUG__
00836 JackLibGlobals::CheckContext();
00837 #endif
00838 JackClient* client = (JackClient*)ext_client;
00839 if (client == NULL) {
00840 jack_error("jack_thread_wait called with a NULL client");
00841 return 0;
00842 } else {
00843 return client->Wait(status);
00844 }
00845 }
00846
00847 EXPORT jack_nframes_t jack_cycle_wait(jack_client_t* ext_client)
00848 {
00849 #ifdef __CLIENTDEBUG__
00850 JackLibGlobals::CheckContext();
00851 #endif
00852 JackClient* client = (JackClient*)ext_client;
00853 if (client == NULL) {
00854 jack_error("jack_cycle_wait called with a NULL client");
00855 return 0;
00856 } else {
00857 return client->CycleWait();
00858 }
00859 }
00860
00861 EXPORT void jack_cycle_signal(jack_client_t* ext_client, int status)
00862 {
00863 #ifdef __CLIENTDEBUG__
00864 JackLibGlobals::CheckContext();
00865 #endif
00866 JackClient* client = (JackClient*)ext_client;
00867 if (client == NULL) {
00868 jack_error("jack_cycle_signal called with a NULL client");
00869 } else {
00870 client->CycleSignal(status);
00871 }
00872 }
00873
00874 EXPORT int jack_set_process_thread(jack_client_t* ext_client, JackThreadCallback fun, void *arg)
00875 {
00876 #ifdef __CLIENTDEBUG__
00877 JackLibGlobals::CheckContext();
00878 #endif
00879 JackClient* client = (JackClient*)ext_client;
00880 if (client == NULL) {
00881 jack_error("jack_set_process_thread called with a NULL client");
00882 return -1;
00883 } else {
00884 return client->SetProcessThread(fun, arg);
00885 }
00886 }
00887
00888 EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
00889 {
00890 #ifdef __CLIENTDEBUG__
00891 JackLibGlobals::CheckContext();
00892 #endif
00893 JackClient* client = (JackClient*)ext_client;
00894 if (client == NULL) {
00895 jack_error("jack_set_freewheel_callback called with a NULL client");
00896 return -1;
00897 } else {
00898 return client->SetFreewheelCallback(freewheel_callback, arg);
00899 }
00900 }
00901
00902 EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
00903 {
00904 #ifdef __CLIENTDEBUG__
00905 JackLibGlobals::CheckContext();
00906 #endif
00907 JackClient* client = (JackClient*)ext_client;
00908 if (client == NULL) {
00909 jack_error("jack_set_freewheel called with a NULL client");
00910 return -1;
00911 } else {
00912 return client->SetFreeWheel(onoff);
00913 }
00914 }
00915
00916 EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
00917 {
00918 #ifdef __CLIENTDEBUG__
00919 JackLibGlobals::CheckContext();
00920 #endif
00921 JackClient* client = (JackClient*)ext_client;
00922 if (client == NULL) {
00923 jack_error("jack_set_buffer_size called with a NULL client");
00924 return -1;
00925 } else if (!CheckBufferSize(buffer_size)) {
00926 return -1;
00927 } else {
00928 return client->SetBufferSize(buffer_size);
00929 }
00930 }
00931
00932 EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
00933 {
00934 #ifdef __CLIENTDEBUG__
00935 JackLibGlobals::CheckContext();
00936 #endif
00937 JackClient* client = (JackClient*)ext_client;
00938 if (client == NULL) {
00939 jack_error("jack_set_buffer_size_callback called with a NULL client");
00940 return -1;
00941 } else {
00942 return client->SetBufferSizeCallback(bufsize_callback, arg);
00943 }
00944 }
00945
00946 EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
00947 {
00948 #ifdef __CLIENTDEBUG__
00949 JackLibGlobals::CheckContext();
00950 #endif
00951 JackClient* client = (JackClient*)ext_client;
00952 if (client == NULL) {
00953 jack_error("jack_set_sample_rate_callback called with a NULL client");
00954 return -1;
00955 } else {
00956 return client->SetSampleRateCallback(srate_callback, arg);
00957 }
00958 }
00959
00960 EXPORT int jack_set_client_registration_callback(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg)
00961 {
00962 #ifdef __CLIENTDEBUG__
00963 JackLibGlobals::CheckContext();
00964 #endif
00965 JackClient* client = (JackClient*)ext_client;
00966 if (client == NULL) {
00967 jack_error("jack_set_client_registration_callback called with a NULL client");
00968 return -1;
00969 } else {
00970 return client->SetClientRegistrationCallback(registration_callback, arg);
00971 }
00972 }
00973
00974 EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
00975 {
00976 #ifdef __CLIENTDEBUG__
00977 JackLibGlobals::CheckContext();
00978 #endif
00979 JackClient* client = (JackClient*)ext_client;
00980 if (client == NULL) {
00981 jack_error("jack_set_port_registration_callback called with a NULL client");
00982 return -1;
00983 } else {
00984 return client->SetPortRegistrationCallback(registration_callback, arg);
00985 }
00986 }
00987
00988 EXPORT int jack_set_port_connect_callback(jack_client_t* ext_client, JackPortConnectCallback portconnect_callback, void* arg)
00989 {
00990 #ifdef __CLIENTDEBUG__
00991 JackLibGlobals::CheckContext();
00992 #endif
00993 JackClient* client = (JackClient*)ext_client;
00994 if (client == NULL) {
00995 jack_error("jack_set_port_connect_callback called with a NULL client");
00996 return -1;
00997 } else {
00998 return client->SetPortConnectCallback(portconnect_callback, arg);
00999 }
01000 }
01001
01002 EXPORT int jack_set_port_rename_callback(jack_client_t* ext_client, JackPortRenameCallback rename_callback, void* arg)
01003 {
01004 #ifdef __CLIENTDEBUG__
01005 JackLibGlobals::CheckContext();
01006 #endif
01007 JackClient* client = (JackClient*)ext_client;
01008 if (client == NULL) {
01009 jack_error("jack_set_port_rename_callback called with a NULL client");
01010 return -1;
01011 } else {
01012 return client->SetPortRenameCallback(rename_callback, arg);
01013 }
01014 }
01015
01016 EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
01017 {
01018 #ifdef __CLIENTDEBUG__
01019 JackLibGlobals::CheckContext();
01020 #endif
01021 JackClient* client = (JackClient*)ext_client;
01022 jack_log("jack_set_graph_order_callback ext_client %x client %x ", ext_client, client);
01023 if (client == NULL) {
01024 jack_error("jack_set_graph_order_callback called with a NULL client");
01025 return -1;
01026 } else {
01027 return client->SetGraphOrderCallback(graph_callback, arg);
01028 }
01029 }
01030
01031 EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
01032 {
01033 #ifdef __CLIENTDEBUG__
01034 JackLibGlobals::CheckContext();
01035 #endif
01036 JackClient* client = (JackClient*)ext_client;
01037 if (client == NULL) {
01038 jack_error("jack_set_xrun_callback called with a NULL client");
01039 return -1;
01040 } else {
01041 return client->SetXRunCallback(xrun_callback, arg);
01042 }
01043 }
01044
01045 EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
01046 {
01047 #ifdef __CLIENTDEBUG__
01048 JackLibGlobals::CheckContext();
01049 #endif
01050 JackClient* client = (JackClient*)ext_client;
01051 jack_log("jack_set_thread_init_callback ext_client %x client %x ", ext_client, client);
01052 if (client == NULL) {
01053 jack_error("jack_set_thread_init_callback called with a NULL client");
01054 return -1;
01055 } else {
01056 return client->SetInitCallback(init_callback, arg);
01057 }
01058 }
01059
01060 EXPORT int jack_activate(jack_client_t* ext_client)
01061 {
01062 #ifdef __CLIENTDEBUG__
01063 JackLibGlobals::CheckContext();
01064 #endif
01065 JackClient* client = (JackClient*)ext_client;
01066 if (client == NULL) {
01067 jack_error("jack_activate called with a NULL client");
01068 return -1;
01069 } else {
01070 return client->Activate();
01071 }
01072 }
01073
01074 EXPORT int jack_deactivate(jack_client_t* ext_client)
01075 {
01076 #ifdef __CLIENTDEBUG__
01077 JackLibGlobals::CheckContext();
01078 #endif
01079 JackClient* client = (JackClient*)ext_client;
01080 if (client == NULL) {
01081 jack_error("jack_deactivate called with a NULL client");
01082 return -1;
01083 } else {
01084 return client->Deactivate();
01085 }
01086 }
01087
01088 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)
01089 {
01090 #ifdef __CLIENTDEBUG__
01091 JackLibGlobals::CheckContext();
01092 #endif
01093 JackClient* client = (JackClient*)ext_client;
01094 if (client == NULL) {
01095 jack_error("jack_port_register called with a NULL client");
01096 return NULL;
01097 } else if ((port_name == NULL) || (port_type == NULL)) {
01098 jack_error("jack_port_register called with a NULL port name or a NULL port_type");
01099 return NULL;
01100 } else {
01101 return (jack_port_t *)client->PortRegister(port_name, port_type, flags, buffer_size);
01102 }
01103 }
01104
01105 EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port)
01106 {
01107 #ifdef __CLIENTDEBUG__
01108 JackLibGlobals::CheckContext();
01109 #endif
01110 JackClient* client = (JackClient*)ext_client;
01111 if (client == NULL) {
01112 jack_error("jack_port_unregister called with a NULL client");
01113 return -1;
01114 }
01115 #if defined(__x86_64__) || defined(__ppc64__)
01116 uint64_t port_aux = (uint64_t)port;
01117 #else
01118 uint32_t port_aux = (uint32_t)port;
01119 #endif
01120 jack_port_id_t myport = (jack_port_id_t)port_aux;
01121 if (!CheckPort(myport)) {
01122 jack_error("jack_port_unregister called with an incorrect port %ld", myport);
01123 return -1;
01124 }
01125 return client->PortUnRegister(myport);
01126 }
01127
01128 EXPORT int jack_port_is_mine(const jack_client_t* ext_client, const jack_port_t* port)
01129 {
01130 #ifdef __CLIENTDEBUG__
01131 JackLibGlobals::CheckContext();
01132 #endif
01133 JackClient* client = (JackClient*)ext_client;
01134 if (client == NULL) {
01135 jack_error("jack_port_is_mine called with a NULL client");
01136 return -1;
01137 }
01138 #if defined(__x86_64__) || defined(__ppc64__)
01139 uint64_t port_aux = (uint64_t)port;
01140 #else
01141 uint32_t port_aux = (uint32_t)port;
01142 #endif
01143 jack_port_id_t myport = (jack_port_id_t)port_aux;
01144 if (!CheckPort(myport)) {
01145 jack_error("jack_port_is_mine called with an incorrect port %ld", myport);
01146 return -1;
01147 }
01148 return client->PortIsMine(myport);
01149 }
01150
01151 EXPORT const char** jack_port_get_connections(const jack_port_t* port)
01152 {
01153 #ifdef __CLIENTDEBUG__
01154 JackLibGlobals::CheckContext();
01155 #endif
01156 #if defined(__x86_64__) || defined(__ppc64__)
01157 uint64_t port_aux = (uint64_t)port;
01158 #else
01159 uint32_t port_aux = (uint32_t)port;
01160 #endif
01161 jack_port_id_t myport = (jack_port_id_t)port_aux;
01162 if (!CheckPort(myport)) {
01163 jack_error("jack_port_get_connections called with an incorrect port %ld", myport);
01164 return NULL;
01165 } else {
01166 WaitGraphChange();
01167 JackGraphManager* manager = GetGraphManager();
01168 return (manager ? manager->GetConnections(myport) : NULL);
01169 }
01170 }
01171
01172
01173 EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_client, const jack_port_t* port)
01174 {
01175 #ifdef __CLIENTDEBUG__
01176 JackLibGlobals::CheckContext();
01177 #endif
01178 JackClient* client = (JackClient*)ext_client;
01179 if (client == NULL) {
01180 jack_error("jack_port_get_all_connections called with a NULL client");
01181 return NULL;
01182 }
01183
01184 #if defined(__x86_64__) || defined(__ppc64__)
01185 uint64_t port_aux = (uint64_t)port;
01186 #else
01187 uint32_t port_aux = (uint32_t)port;
01188 #endif
01189 jack_port_id_t myport = (jack_port_id_t)port_aux;
01190 if (!CheckPort(myport)) {
01191 jack_error("jack_port_get_all_connections called with an incorrect port %ld", myport);
01192 return NULL;
01193 } else {
01194 WaitGraphChange();
01195 JackGraphManager* manager = GetGraphManager();
01196 return (manager ? manager->GetConnections(myport) : NULL);
01197 }
01198 }
01199
01200 EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port)
01201 {
01202 #ifdef __CLIENTDEBUG__
01203 JackLibGlobals::CheckContext();
01204 #endif
01205 JackClient* client = (JackClient*)ext_client;
01206 if (client == NULL) {
01207 jack_error("jack_port_get_total_latency called with a NULL client");
01208 return 0;
01209 }
01210
01211 #if defined(__x86_64__) || defined(__ppc64__)
01212 uint64_t port_aux = (uint64_t)port;
01213 #else
01214 uint32_t port_aux = (uint32_t)port;
01215 #endif
01216 jack_port_id_t myport = (jack_port_id_t)port_aux;
01217 if (!CheckPort(myport)) {
01218 jack_error("jack_port_get_total_latency called with an incorrect port %ld", myport);
01219 return 0;
01220 } else {
01221 WaitGraphChange();
01222 JackGraphManager* manager = GetGraphManager();
01223 if (manager) {
01224 manager->ComputeTotalLatency(myport);
01225 return manager->GetPort(myport)->GetTotalLatency();
01226 } else {
01227 return 0;
01228 }
01229 }
01230 }
01231
01232 EXPORT int jack_connect(jack_client_t* ext_client, const char* src, const char* dst)
01233 {
01234 #ifdef __CLIENTDEBUG__
01235 JackLibGlobals::CheckContext();
01236 #endif
01237 JackClient* client = (JackClient*)ext_client;
01238 if (client == NULL) {
01239 jack_error("jack_connect called with a NULL client");
01240 return -1;
01241 } else if ((src == NULL) || (dst == NULL)) {
01242 jack_error("jack_connect called with a NULL port name");
01243 return -1;
01244 } else {
01245 return client->PortConnect(src, dst);
01246 }
01247 }
01248
01249 EXPORT int jack_disconnect(jack_client_t* ext_client, const char* src, const char* dst)
01250 {
01251 #ifdef __CLIENTDEBUG__
01252 JackLibGlobals::CheckContext();
01253 #endif
01254 JackClient* client = (JackClient*)ext_client;
01255 if (client == NULL) {
01256 jack_error("jack_disconnect called with a NULL client");
01257 return -1;
01258 } else if ((src == NULL) || (dst == NULL)) {
01259 jack_error("jack_connect called with a NULL port name");
01260 return -1;
01261 } else {
01262 return client->PortDisconnect(src, dst);
01263 }
01264 }
01265
01266 EXPORT int jack_port_disconnect(jack_client_t* ext_client, jack_port_t* src)
01267 {
01268 #ifdef __CLIENTDEBUG__
01269 JackLibGlobals::CheckContext();
01270 #endif
01271 JackClient* client = (JackClient*)ext_client;
01272 if (client == NULL) {
01273 jack_error("jack_port_disconnect called with a NULL client");
01274 return -1;
01275 }
01276 #if defined(__x86_64__) || defined(__ppc64__)
01277 uint64_t port_aux = (uint64_t)src;
01278 #else
01279 uint32_t port_aux = (uint32_t)src;
01280 #endif
01281 jack_port_id_t myport = (jack_port_id_t)port_aux;
01282 if (!CheckPort(myport)) {
01283 jack_error("jack_port_disconnect called with an incorrect port %ld", myport);
01284 return -1;
01285 }
01286 return client->PortDisconnect(myport);
01287 }
01288
01289 EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t* ext_client)
01290 {
01291 #ifdef __CLIENTDEBUG__
01292 JackLibGlobals::CheckContext();
01293 #endif
01294 JackClient* client = (JackClient*)ext_client;
01295 if (client == NULL) {
01296 jack_error("jack_get_sample_rate called with a NULL client");
01297 return 0;
01298 } else {
01299 JackEngineControl* control = GetEngineControl();
01300 return (control ? control->fSampleRate : 0);
01301 }
01302 }
01303
01304 EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client)
01305 {
01306 #ifdef __CLIENTDEBUG__
01307 JackLibGlobals::CheckContext();
01308 #endif
01309 JackClient* client = (JackClient*)ext_client;
01310 if (client == NULL) {
01311 jack_error("jack_get_buffer_size called with a NULL client");
01312 return 0;
01313 } else {
01314 JackEngineControl* control = GetEngineControl();
01315 return (control ? control->fBufferSize : 0);
01316 }
01317 }
01318
01319 EXPORT const char** jack_get_ports(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
01320 {
01321 #ifdef __CLIENTDEBUG__
01322 JackLibGlobals::CheckContext();
01323 #endif
01324 JackClient* client = (JackClient*)ext_client;
01325 if (client == NULL) {
01326 jack_error("jack_get_ports called with a NULL client");
01327 return NULL;
01328 }
01329 JackGraphManager* manager = GetGraphManager();
01330 return (manager ? manager->GetPorts(port_name_pattern, type_name_pattern, flags) : NULL);
01331 }
01332
01333 EXPORT jack_port_t* jack_port_by_name(jack_client_t* ext_client, const char* portname)
01334 {
01335 #ifdef __CLIENTDEBUG__
01336 JackLibGlobals::CheckContext();
01337 #endif
01338 JackClient* client = (JackClient*)ext_client;
01339 if (client == NULL) {
01340 jack_error("jack_get_ports called with a NULL client");
01341 return 0;
01342 }
01343
01344 if (portname == NULL) {
01345 jack_error("jack_port_by_name called with a NULL port name");
01346 return NULL;
01347 } else {
01348 JackGraphManager* manager = GetGraphManager();
01349 if (!manager)
01350 return NULL;
01351 int res = manager->GetPort(portname);
01352 return (res == NO_PORT) ? NULL : (jack_port_t*)res;
01353 }
01354 }
01355
01356 EXPORT jack_port_t* jack_port_by_id(jack_client_t* ext_client, jack_port_id_t id)
01357 {
01358 #ifdef __CLIENTDEBUG__
01359 JackLibGlobals::CheckContext();
01360 #endif
01361
01362 return (jack_port_t*)id;
01363 }
01364
01365 EXPORT int jack_engine_takeover_timebase(jack_client_t* ext_client)
01366 {
01367 #ifdef __CLIENTDEBUG__
01368 JackLibGlobals::CheckContext();
01369 #endif
01370 JackClient* client = (JackClient*)ext_client;
01371 if (client == NULL) {
01372 jack_error("jack_engine_takeover_timebase called with a NULL client");
01373 return -1;
01374 } else {
01375 jack_error("jack_engine_takeover_timebase: deprecated\n");
01376 return 0;
01377 }
01378 }
01379
01380 EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t* ext_client)
01381 {
01382 #ifdef __CLIENTDEBUG__
01383 JackLibGlobals::CheckContext();
01384 #endif
01385 JackTimer timer;
01386 JackEngineControl* control = GetEngineControl();
01387 if (control) {
01388 control->ReadFrameTime(&timer);
01389 return timer.FramesSinceCycleStart(GetMicroSeconds(), control->fSampleRate);
01390 } else {
01391 return 0;
01392 }
01393 }
01394
01395 EXPORT jack_time_t jack_get_time()
01396 {
01397 return GetMicroSeconds();
01398 }
01399
01400 EXPORT jack_time_t jack_frames_to_time(const jack_client_t* ext_client, jack_nframes_t frames)
01401 {
01402 #ifdef __CLIENTDEBUG__
01403 JackLibGlobals::CheckContext();
01404 #endif
01405 JackClient* client = (JackClient*)ext_client;
01406 if (client == NULL) {
01407 jack_error("jack_frames_to_time called with a NULL client");
01408 return 0;
01409 } else {
01410 JackTimer timer;
01411 JackEngineControl* control = GetEngineControl();
01412 if (control) {
01413 control->ReadFrameTime(&timer);
01414 return timer.Frames2Time(frames, control->fBufferSize);
01415 } else {
01416 return 0;
01417 }
01418 }
01419 }
01420
01421 EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t* ext_client, jack_time_t time)
01422 {
01423 #ifdef __CLIENTDEBUG__
01424 JackLibGlobals::CheckContext();
01425 #endif
01426 JackClient* client = (JackClient*)ext_client;
01427 if (client == NULL) {
01428 jack_error("jack_time_to_frames called with a NULL client");
01429 return 0;
01430 } else {
01431 JackTimer timer;
01432 JackEngineControl* control = GetEngineControl();
01433 if (control) {
01434 control->ReadFrameTime(&timer);
01435 return timer.Time2Frames(time, control->fBufferSize);
01436 } else {
01437 return 0;
01438 }
01439 }
01440 }
01441
01442 EXPORT jack_nframes_t jack_frame_time(const jack_client_t* ext_client)
01443 {
01444 return jack_time_to_frames(ext_client, GetMicroSeconds());
01445 }
01446
01447 EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
01448 {
01449 #ifdef __CLIENTDEBUG__
01450 JackLibGlobals::CheckContext();
01451 #endif
01452 JackTimer timer;
01453 JackEngineControl* control = GetEngineControl();
01454 if (control) {
01455 control->ReadFrameTime(&timer);
01456 return timer.CurFrame();
01457 } else {
01458 return 0;
01459 }
01460 }
01461
01462 EXPORT float jack_cpu_load(jack_client_t* ext_client)
01463 {
01464 #ifdef __CLIENTDEBUG__
01465 JackLibGlobals::CheckContext();
01466 #endif
01467 JackClient* client = (JackClient*)ext_client;
01468 if (client == NULL) {
01469 jack_error("jack_cpu_load called with a NULL client");
01470 return 0.0f;
01471 } else {
01472 JackEngineControl* control = GetEngineControl();
01473 return (control ? control->fCPULoad : 0.0f);
01474 }
01475 }
01476
01477 EXPORT pthread_t jack_client_thread_id(jack_client_t* ext_client)
01478 {
01479 #ifdef __CLIENTDEBUG__
01480 JackLibGlobals::CheckContext();
01481 #endif
01482 JackClient* client = (JackClient*)ext_client;
01483 if (client == NULL) {
01484 jack_error("jack_client_thread_id called with a NULL client");
01485 return (pthread_t)NULL;
01486 } else {
01487 return client->GetThreadID();
01488 }
01489 }
01490
01491 EXPORT char* jack_get_client_name(jack_client_t* ext_client)
01492 {
01493 #ifdef __CLIENTDEBUG__
01494 JackLibGlobals::CheckContext();
01495 #endif
01496 JackClient* client = (JackClient*)ext_client;
01497 if (client == NULL) {
01498 jack_error("jack_get_client_name called with a NULL client");
01499 return NULL;
01500 } else {
01501 return client->GetClientControl()->fName;
01502 }
01503 }
01504
01505 EXPORT int jack_client_name_size(void)
01506 {
01507 return JACK_CLIENT_NAME_SIZE;
01508 }
01509
01510 EXPORT int jack_port_name_size(void)
01511 {
01512 return JACK_PORT_NAME_SIZE;
01513 }
01514
01515 EXPORT int jack_port_type_size(void)
01516 {
01517 return JACK_PORT_TYPE_SIZE;
01518 }
01519
01520
01521 EXPORT int jack_release_timebase(jack_client_t* ext_client)
01522 {
01523 #ifdef __CLIENTDEBUG__
01524 JackLibGlobals::CheckContext();
01525 #endif
01526 JackClient* client = (JackClient*)ext_client;
01527 if (client == NULL) {
01528 jack_error("jack_release_timebase called with a NULL client");
01529 return -1;
01530 } else {
01531 return client->ReleaseTimebase();
01532 }
01533 }
01534
01535 EXPORT int jack_set_sync_callback(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg)
01536 {
01537 #ifdef __CLIENTDEBUG__
01538 JackLibGlobals::CheckContext();
01539 #endif
01540 JackClient* client = (JackClient*)ext_client;
01541 if (client == NULL) {
01542 jack_error("jack_set_sync_callback called with a NULL client");
01543 return -1;
01544 } else {
01545 return client->SetSyncCallback(sync_callback, arg);
01546 }
01547 }
01548
01549 EXPORT int jack_set_sync_timeout(jack_client_t* ext_client, jack_time_t timeout)
01550 {
01551 #ifdef __CLIENTDEBUG__
01552 JackLibGlobals::CheckContext();
01553 #endif
01554 JackClient* client = (JackClient*)ext_client;
01555 if (client == NULL) {
01556 jack_error("jack_set_sync_timeout called with a NULL client");
01557 return -1;
01558 } else {
01559 return client->SetSyncTimeout(timeout);
01560 }
01561 }
01562
01563 EXPORT int jack_set_timebase_callback(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg)
01564 {
01565 #ifdef __CLIENTDEBUG__
01566 JackLibGlobals::CheckContext();
01567 #endif
01568 JackClient* client = (JackClient*)ext_client;
01569 if (client == NULL) {
01570 jack_error("jack_set_timebase_callback called with a NULL client");
01571 return -1;
01572 } else {
01573 return client->SetTimebaseCallback(conditional, timebase_callback, arg);
01574 }
01575 }
01576
01577 EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame)
01578 {
01579 #ifdef __CLIENTDEBUG__
01580 JackLibGlobals::CheckContext();
01581 #endif
01582 JackClient* client = (JackClient*)ext_client;
01583 if (client == NULL) {
01584 jack_error("jack_transport_locate called with a NULL client");
01585 return -1;
01586 } else {
01587 client->TransportLocate(frame);
01588 return 0;
01589 }
01590 }
01591
01592 EXPORT jack_transport_state_t jack_transport_query(const jack_client_t* ext_client, jack_position_t* pos)
01593 {
01594 #ifdef __CLIENTDEBUG__
01595 JackLibGlobals::CheckContext();
01596 #endif
01597 JackClient* client = (JackClient*)ext_client;
01598 if (client == NULL) {
01599 jack_error("jack_transport_query called with a NULL client");
01600 return JackTransportStopped;
01601 } else {
01602 return client->TransportQuery(pos);
01603 }
01604 }
01605
01606 EXPORT jack_nframes_t jack_get_current_transport_frame(const jack_client_t* ext_client)
01607 {
01608 #ifdef __CLIENTDEBUG__
01609 JackLibGlobals::CheckContext();
01610 #endif
01611 JackClient* client = (JackClient*)ext_client;
01612 if (client == NULL) {
01613 jack_error("jack_get_current_transport_frame called with a NULL client");
01614 return 0;
01615 } else {
01616 return client->GetCurrentTransportFrame();
01617 }
01618 }
01619
01620 EXPORT int jack_transport_reposition(jack_client_t* ext_client, jack_position_t* pos)
01621 {
01622 #ifdef __CLIENTDEBUG__
01623 JackLibGlobals::CheckContext();
01624 #endif
01625 JackClient* client = (JackClient*)ext_client;
01626 if (client == NULL) {
01627 jack_error("jack_transport_reposition called with a NULL client");
01628 return -1;
01629 } else {
01630 client->TransportReposition(pos);
01631 return 0;
01632 }
01633 }
01634
01635 EXPORT void jack_transport_start(jack_client_t* ext_client)
01636 {
01637 #ifdef __CLIENTDEBUG__
01638 JackLibGlobals::CheckContext();
01639 #endif
01640 JackClient* client = (JackClient*)ext_client;
01641 if (client == NULL) {
01642 jack_error("jack_transport_start called with a NULL client");
01643 } else {
01644 client->TransportStart();
01645 }
01646 }
01647
01648 EXPORT void jack_transport_stop(jack_client_t* ext_client)
01649 {
01650 #ifdef __CLIENTDEBUG__
01651 JackLibGlobals::CheckContext();
01652 #endif
01653 JackClient* client = (JackClient*)ext_client;
01654 if (client == NULL) {
01655 jack_error("jack_transport_stop called with a NULL client");
01656 } else {
01657 client->TransportStop();
01658 }
01659 }
01660
01661
01662 EXPORT void jack_get_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
01663 {
01664 jack_error("jack_get_transport_info: deprecated");
01665 if (tinfo)
01666 memset(tinfo, 0, sizeof(jack_transport_info_t));
01667 }
01668
01669 EXPORT void jack_set_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
01670 {
01671 jack_error("jack_set_transport_info: deprecated");
01672 if (tinfo)
01673 memset(tinfo, 0, sizeof(jack_transport_info_t));
01674 }
01675
01676
01677 EXPORT float jack_get_max_delayed_usecs(jack_client_t* ext_client)
01678 {
01679 #ifdef __CLIENTDEBUG__
01680 JackLibGlobals::CheckContext();
01681 #endif
01682 JackClient* client = (JackClient*)ext_client;
01683 if (client == NULL) {
01684 jack_error("jack_get_max_delayed_usecs called with a NULL client");
01685 return 0.f;
01686 } else {
01687 JackEngineControl* control = GetEngineControl();
01688 return (control ? control->fMaxDelayedUsecs : 0.f);
01689 }
01690 }
01691
01692 EXPORT float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
01693 {
01694 #ifdef __CLIENTDEBUG__
01695 JackLibGlobals::CheckContext();
01696 #endif
01697 JackClient* client = (JackClient*)ext_client;
01698 if (client == NULL) {
01699 jack_error("jack_get_xrun_delayed_usecs called with a NULL client");
01700 return 0.f;
01701 } else {
01702 JackEngineControl* control = GetEngineControl();
01703 return (control ? control->fXrunDelayedUsecs : 0.f);
01704 }
01705 }
01706
01707 EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
01708 {
01709 #ifdef __CLIENTDEBUG__
01710 JackLibGlobals::CheckContext();
01711 #endif
01712 JackClient* client = (JackClient*)ext_client;
01713 if (client == NULL) {
01714 jack_error("jack_reset_max_delayed_usecs called with a NULL client");
01715 } else {
01716 JackEngineControl* control = GetEngineControl();
01717 control->ResetXRun();
01718 }
01719 }
01720
01721
01722 EXPORT int jack_client_real_time_priority(jack_client_t* ext_client)
01723 {
01724 #ifdef __CLIENTDEBUG__
01725 JackLibGlobals::CheckContext();
01726 #endif
01727 JackClient* client = (JackClient*)ext_client;
01728 if (client == NULL) {
01729 jack_error("jack_client_real_time_priority called with a NULL client");
01730 return -1;
01731 } else {
01732 JackEngineControl* control = GetEngineControl();
01733 return (control->fRealTime) ? control->fClientPriority : -1;
01734 }
01735 }
01736
01737 EXPORT int jack_client_max_real_time_priority(jack_client_t* ext_client)
01738 {
01739 #ifdef __CLIENTDEBUG__
01740 JackLibGlobals::CheckContext();
01741 #endif
01742 JackClient* client = (JackClient*)ext_client;
01743 if (client == NULL) {
01744 jack_error("jack_client_max_real_time_priority called with a NULL client");
01745 return -1;
01746 } else {
01747 JackEngineControl* control = GetEngineControl();
01748 return (control->fRealTime) ? control->fMaxClientPriority : -1;
01749 }
01750 }
01751
01752 EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority)
01753 {
01754 JackEngineControl* control = GetEngineControl();
01755 return (control ? JackThread::AcquireRealTimeImp(thread, priority, GetEngineControl()->fPeriod, GetEngineControl()->fComputation, GetEngineControl()->fConstraint) : -1);
01756 }
01757
01758 EXPORT int jack_client_create_thread(jack_client_t* client,
01759 pthread_t *thread,
01760 int priority,
01761 int realtime,
01762 thread_routine routine,
01763 void *arg)
01764 {
01765 return JackThread::StartImp(thread, priority, realtime, routine, arg);
01766 }
01767
01768 EXPORT int jack_drop_real_time_scheduling(pthread_t thread)
01769 {
01770 return JackThread::DropRealTimeImp(thread);
01771 }
01772
01773 EXPORT int jack_client_stop_thread(jack_client_t* client, pthread_t thread)
01774 {
01775 return JackThread::StopImp(thread);
01776 }
01777
01778 EXPORT int jack_client_kill_thread(jack_client_t* client, pthread_t thread)
01779 {
01780 return JackThread::KillImp(thread);
01781 }
01782
01783
01784 EXPORT int jack_internal_client_new (const char *client_name,
01785 const char *load_name,
01786 const char *load_init)
01787 {
01788 jack_error("jack_internal_client_new: deprecated");
01789 return -1;
01790 }
01791
01792 EXPORT void jack_internal_client_close (const char *client_name)
01793 {
01794 jack_error("jack_internal_client_close: deprecated");
01795 }
01796
01797 EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
01798 {
01799 #ifdef __CLIENTDEBUG__
01800 JackLibGlobals::CheckContext();
01801 #endif
01802 JackClient* client = (JackClient*)ext_client;
01803 if (client == NULL) {
01804 jack_error("jack_get_internal_client_name called with a NULL client");
01805 return NULL;
01806 } else if (intclient >= CLIENT_NUM) {
01807 jack_error("jack_get_internal_client_name: incorrect client");
01808 return NULL;
01809 } else {
01810 return client->GetInternalClientName(intclient);
01811 }
01812 }
01813
01814 EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, const char* client_name, jack_status_t* status)
01815 {
01816 #ifdef __CLIENTDEBUG__
01817 JackLibGlobals::CheckContext();
01818 #endif
01819 JackClient* client = (JackClient*)ext_client;
01820 if (client == NULL) {
01821 jack_error("jack_internal_client_handle called with a NULL client");
01822 return 0;
01823 } else {
01824 jack_status_t my_status;
01825 if (status == NULL)
01826 status = &my_status;
01827 *status = (jack_status_t)0;
01828 return client->InternalClientHandle(client_name, status);
01829 }
01830 }
01831
01832 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)
01833 {
01834 #ifdef __CLIENTDEBUG__
01835 JackLibGlobals::CheckContext();
01836 #endif
01837 JackClient* client = (JackClient*)ext_client;
01838 if (client == NULL) {
01839 jack_error("jack_internal_client_load called with a NULL client");
01840 return 0;
01841 } else {
01842 jack_varargs_t va;
01843 jack_status_t my_status;
01844
01845 if (status == NULL)
01846 status = &my_status;
01847 *status = (jack_status_t)0;
01848
01849
01850 if ((options & ~JackLoadOptions)) {
01851 int my_status1 = *status | (JackFailure | JackInvalidOption);
01852 *status = (jack_status_t)my_status1;
01853 return 0;
01854 }
01855
01856
01857 jack_varargs_parse(options, ap, &va);
01858 return client->InternalClientLoad(client_name, options, status, &va);
01859 }
01860 }
01861
01862 EXPORT jack_intclient_t jack_internal_client_load(jack_client_t *client, const char *client_name, jack_options_t options, jack_status_t *status, ...)
01863 {
01864 va_list ap;
01865 va_start(ap, status);
01866 jack_intclient_t res = jack_internal_client_load_aux(client, client_name, options, status, ap);
01867 va_end(ap);
01868 return res;
01869 }
01870
01871 EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
01872 {
01873 #ifdef __CLIENTDEBUG__
01874 JackLibGlobals::CheckContext();
01875 #endif
01876 JackClient* client = (JackClient*)ext_client;
01877 if (client == NULL) {
01878 jack_error("jack_internal_client_unload called with a NULL client");
01879 return (jack_status_t)(JackNoSuchClient | JackFailure);
01880 } else if (intclient >= CLIENT_NUM) {
01881 jack_error("jack_internal_client_unload: incorrect client");
01882 return (jack_status_t)(JackNoSuchClient | JackFailure);
01883 } else {
01884 jack_status_t my_status;
01885 client->InternalClientUnload(intclient, &my_status);
01886 return my_status;
01887 }
01888 }
01889
01890 EXPORT
01891 void
01892 jack_get_version(
01893 int *major_ptr,
01894 int *minor_ptr,
01895 int *micro_ptr,
01896 int *proto_ptr)
01897 {
01898
01899 *major_ptr = 0;
01900 *minor_ptr = 0;
01901 *micro_ptr = 0;
01902 *proto_ptr = 0;
01903 }
01904
01905 EXPORT
01906 const char *
01907 jack_get_version_string()
01908 {
01909 return VERSION;
01910 }