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