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 "JackExports.h"
00029 #include "JackAPI.h"
00030
00031 #ifdef __APPLE__
00032 #include "JackMachThread.h"
00033 #elif WIN32
00034 #include "JackWinThread.h"
00035 #else
00036 #include "JackPosixThread.h"
00037 #endif
00038 #include <math.h>
00039
00040 #ifdef __CLIENTDEBUG__
00041 #include "JackLibGlobals.h"
00042 #endif
00043
00044 using namespace Jack;
00045
00046 #ifdef __cplusplus
00047 extern "C"
00048 {
00049 #endif
00050
00051 EXPORT int jack_client_name_size (void);
00052 EXPORT char* jack_get_client_name (jack_client_t *client);
00053 EXPORT int jack_internal_client_new (const char *client_name,
00054 const char *load_name,
00055 const char *load_init);
00056 EXPORT jack_client_t* my_jack_internal_client_new(const char* client_name);
00057 EXPORT void jack_internal_client_close (const char *client_name);
00058 EXPORT void my_jack_internal_client_close (jack_client_t* client);
00059 EXPORT int jack_is_realtime (jack_client_t *client);
00060 EXPORT void jack_on_shutdown (jack_client_t *client,
00061 void (*function)(void *arg), void *arg);
00062 EXPORT int jack_set_process_callback (jack_client_t *client,
00063 JackProcessCallback process_callback,
00064 void *arg);
00065 EXPORT int jack_set_thread_init_callback (jack_client_t *client,
00066 JackThreadInitCallback thread_init_callback,
00067 void *arg);
00068 EXPORT int jack_set_freewheel_callback (jack_client_t *client,
00069 JackFreewheelCallback freewheel_callback,
00070 void *arg);
00071 EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
00072 EXPORT int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
00073 EXPORT int jack_set_buffer_size_callback (jack_client_t *client,
00074 JackBufferSizeCallback bufsize_callback,
00075 void *arg);
00076 EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
00077 JackSampleRateCallback srate_callback,
00078 void *arg);
00079 EXPORT int jack_set_client_registration_callback (jack_client_t *,
00080 JackClientRegistrationCallback
00081 registration_callback, void *arg);
00082 EXPORT int jack_set_port_registration_callback (jack_client_t *,
00083 JackPortRegistrationCallback
00084 registration_callback, void *arg);
00085 EXPORT int jack_set_graph_order_callback (jack_client_t *,
00086 JackGraphOrderCallback graph_callback,
00087 void *);
00088 EXPORT int jack_set_xrun_callback (jack_client_t *,
00089 JackXRunCallback xrun_callback, void *arg);
00090 EXPORT int jack_activate (jack_client_t *client);
00091 EXPORT int jack_deactivate (jack_client_t *client);
00092 EXPORT jack_port_t * jack_port_register (jack_client_t *client,
00093 const char *port_name,
00094 const char *port_type,
00095 unsigned long flags,
00096 unsigned long buffer_size);
00097 EXPORT int jack_port_unregister (jack_client_t *, jack_port_t *);
00098 EXPORT void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
00099 EXPORT const char * jack_port_name (const jack_port_t *port);
00100 EXPORT const char * jack_port_short_name (const jack_port_t *port);
00101 EXPORT int jack_port_flags (const jack_port_t *port);
00102 EXPORT const char * jack_port_type (const jack_port_t *port);
00103 EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
00104 EXPORT int jack_port_connected (const jack_port_t *port);
00105 EXPORT int jack_port_connected_to (const jack_port_t *port,
00106 const char *port_name);
00107 EXPORT const char ** jack_port_get_connections (const jack_port_t *port);
00108 EXPORT const char ** jack_port_get_all_connections (const jack_client_t *client,
00109 const jack_port_t *port);
00110 EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst);
00111 EXPORT int jack_port_untie (jack_port_t *port);
00112 EXPORT int jack_port_lock (jack_client_t *, jack_port_t *);
00113 EXPORT int jack_port_unlock (jack_client_t *, jack_port_t *);
00114 EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port);
00115 EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *,
00116 jack_port_t *port);
00117 EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t);
00118 EXPORT int jack_recompute_total_latencies (jack_client_t*);
00119 EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name);
00120 EXPORT int jack_port_set_alias (jack_port_t *port, const char *alias);
00121 EXPORT int jack_port_unset_alias (jack_port_t *port, const char *alias);
00122 EXPORT int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
00123 EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff);
00124 EXPORT int jack_port_request_monitor_by_name (jack_client_t *client,
00125 const char *port_name, int onoff);
00126 EXPORT int jack_port_ensure_monitor (jack_port_t *port, int onoff);
00127 EXPORT int jack_port_monitoring_input (jack_port_t *port);
00128 EXPORT int jack_connect (jack_client_t *,
00129 const char *source_port,
00130 const char *destination_port);
00131 EXPORT int jack_disconnect (jack_client_t *,
00132 const char *source_port,
00133 const char *destination_port);
00134 EXPORT int jack_port_disconnect (jack_client_t *, jack_port_t *);
00135 EXPORT int jack_port_name_size(void);
00136 EXPORT int jack_port_type_size(void);
00137 EXPORT jack_nframes_t jack_get_sample_rate (jack_client_t *);
00138 EXPORT jack_nframes_t jack_get_buffer_size (jack_client_t *);
00139 EXPORT const char ** jack_get_ports (jack_client_t *,
00140 const char *port_name_pattern,
00141 const char *type_name_pattern,
00142 unsigned long flags);
00143 EXPORT jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
00144 EXPORT jack_port_t * jack_port_by_id (jack_client_t *client,
00145 jack_port_id_t port_id);
00146 EXPORT int jack_engine_takeover_timebase (jack_client_t *);
00147 EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
00148 EXPORT jack_time_t jack_get_time(const jack_client_t *client);
00149 EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t time);
00150 EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames);
00151 EXPORT jack_nframes_t jack_frame_time (const jack_client_t *);
00152 EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client);
00153 EXPORT float jack_cpu_load (jack_client_t *client);
00154 EXPORT pthread_t jack_client_thread_id (jack_client_t *);
00155 EXPORT void jack_set_error_function (void (*func)(const char *));
00156
00157 EXPORT float jack_get_max_delayed_usecs (jack_client_t *client);
00158 EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client);
00159 EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client);
00160
00161 EXPORT int jack_release_timebase (jack_client_t *client);
00162 EXPORT int jack_set_sync_callback (jack_client_t *client,
00163 JackSyncCallback sync_callback,
00164 void *arg);
00165 EXPORT int jack_set_sync_timeout (jack_client_t *client,
00166 jack_time_t timeout);
00167 EXPORT int jack_set_timebase_callback (jack_client_t *client,
00168 int conditional,
00169 JackTimebaseCallback timebase_callback,
00170 void *arg);
00171 EXPORT int jack_transport_locate (jack_client_t *client,
00172 jack_nframes_t frame);
00173 EXPORT jack_transport_state_t jack_transport_query (const jack_client_t *client,
00174 jack_position_t *pos);
00175 EXPORT jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
00176 EXPORT int jack_transport_reposition (jack_client_t *client,
00177 jack_position_t *pos);
00178 EXPORT void jack_transport_start (jack_client_t *client);
00179 EXPORT void jack_transport_stop (jack_client_t *client);
00180 EXPORT void jack_get_transport_info (jack_client_t *client,
00181 jack_transport_info_t *tinfo);
00182 EXPORT void jack_set_transport_info (jack_client_t *client,
00183 jack_transport_info_t *tinfo);
00184
00185 EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
00186 EXPORT int jack_client_create_thread (jack_client_t* client,
00187 pthread_t *thread,
00188 int priority,
00189 int realtime,
00190 void *(*start_routine)(void*),
00191 void *arg);
00192 EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
00193
00194 EXPORT char * jack_get_internal_client_name (jack_client_t *client,
00195 jack_intclient_t intclient);
00196 EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client,
00197 const char *client_name,
00198 jack_status_t *status);
00199 EXPORT jack_intclient_t jack_internal_client_load (jack_client_t *client,
00200 const char *client_name,
00201 jack_options_t options,
00202 jack_status_t *status, ...);
00203 EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
00204 jack_intclient_t intclient);
00205
00206 #ifdef __cplusplus
00207 }
00208 #endif
00209
00210 #ifdef WIN32
00211
00212 inline double rint(double nr)
00213 {
00214 double f = floor(nr);
00215 double c = ceil(nr);
00216 return (((c -nr) >= (nr - f)) ? f : c);
00217 }
00218 #endif
00219
00220 static inline bool CheckPort(jack_port_id_t port_index)
00221 {
00222 return (port_index < PORT_NUM);
00223 }
00224
00225 static inline bool CheckBufferSize(jack_nframes_t buffer_size)
00226 {
00227 return (buffer_size <= BUFFER_SIZE_MAX);
00228 }
00229
00230 static inline void WaitGraphChange()
00231 {
00232 if (GetGraphManager()->IsPendingChange()) {
00233 JackLog("WaitGraphChange...\n");
00234 JackSleep(GetEngineControl()->fPeriodUsecs * 2);
00235 }
00236 }
00237
00238 static void default_jack_error_callback(const char *desc)
00239 {
00240 fprintf(stderr, "%s\n", desc);
00241 }
00242
00243 void (*jack_error_callback)(const char *desc) = &default_jack_error_callback;
00244
00245 EXPORT void jack_set_error_function (void (*func)(const char *))
00246 {
00247 jack_error_callback = func;
00248 }
00249
00250 EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
00251 {
00252 #ifdef __CLIENTDEBUG__
00253 JackLibGlobals::CheckContext();
00254 #endif
00255 jack_port_id_t myport = (jack_port_id_t)port;
00256 if (!CheckPort(myport)) {
00257 jack_error("jack_port_get_buffer called with an incorrect port %ld", myport);
00258 return NULL;
00259 } else {
00260 return GetGraphManager()->GetBuffer(myport, frames);
00261 }
00262 }
00263
00264 EXPORT const char* jack_port_name(const jack_port_t* port)
00265 {
00266 #ifdef __CLIENTDEBUG__
00267 JackLibGlobals::CheckContext();
00268 #endif
00269 jack_port_id_t myport = (jack_port_id_t)port;
00270 if (!CheckPort(myport)) {
00271 jack_error("jack_port_name called with an incorrect port %ld", myport);
00272 return NULL;
00273 } else {
00274 return GetGraphManager()->GetPort(myport)->GetName();
00275 }
00276 }
00277
00278 EXPORT const char* jack_port_short_name(const jack_port_t* port)
00279 {
00280 #ifdef __CLIENTDEBUG__
00281 JackLibGlobals::CheckContext();
00282 #endif
00283 jack_port_id_t myport = (jack_port_id_t)port;
00284 if (!CheckPort(myport)) {
00285 jack_error("jack_port_short_name called with an incorrect port %ld", myport);
00286 return NULL;
00287 } else {
00288 return GetGraphManager()->GetPort(myport)->GetShortName();
00289 }
00290 }
00291
00292 EXPORT int jack_port_flags(const jack_port_t* port)
00293 {
00294 #ifdef __CLIENTDEBUG__
00295 JackLibGlobals::CheckContext();
00296 #endif
00297 jack_port_id_t myport = (jack_port_id_t)port;
00298 if (!CheckPort(myport)) {
00299 jack_error("jack_port_flags called with an incorrect port %ld", myport);
00300 return -1;
00301 } else {
00302 return GetGraphManager()->GetPort(myport)->Flags();
00303 }
00304 }
00305
00306 EXPORT const char* jack_port_type(const jack_port_t* port)
00307 {
00308 #ifdef __CLIENTDEBUG__
00309 JackLibGlobals::CheckContext();
00310 #endif
00311 jack_port_id_t myport = (jack_port_id_t)port;
00312 if (!CheckPort(myport)) {
00313 jack_error("jack_port_flags called an incorrect port %ld", myport);
00314 return NULL;
00315 } else {
00316 return GetGraphManager()->GetPort(myport)->Type();
00317 }
00318 }
00319
00320 EXPORT int jack_port_connected(const jack_port_t* port)
00321 {
00322 #ifdef __CLIENTDEBUG__
00323 JackLibGlobals::CheckContext();
00324 #endif
00325 jack_port_id_t myport = (jack_port_id_t)port;
00326 if (!CheckPort(myport)) {
00327 jack_error("jack_port_connected called with an incorrect port %ld", myport);
00328 return -1;
00329 } else {
00330 WaitGraphChange();
00331 return GetGraphManager()->GetConnectionsNum(myport);
00332 }
00333 }
00334
00335 EXPORT int jack_port_connected_to(const jack_port_t* port, const char* portname)
00336 {
00337 #ifdef __CLIENTDEBUG__
00338 JackLibGlobals::CheckContext();
00339 #endif
00340 jack_port_id_t myport = (jack_port_id_t)port;
00341 if (!CheckPort(myport)) {
00342 jack_error("jack_port_connected_to called with an incorrect port %ld", myport);
00343 return -1;
00344 } else if (portname == NULL) {
00345 jack_error("jack_port_connected_to called with a NULL port name");
00346 return -1;
00347 } else {
00348 WaitGraphChange();
00349 return GetGraphManager()->ConnectedTo(myport, portname);
00350 }
00351 }
00352
00353 EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
00354 {
00355 #ifdef __CLIENTDEBUG__
00356 JackLibGlobals::CheckContext();
00357 #endif
00358 jack_port_id_t mysrc = (jack_port_id_t)src;
00359 if (!CheckPort(mysrc)) {
00360 jack_error("jack_port_tie called with a NULL src port");
00361 return -1;
00362 }
00363 jack_port_id_t mydst = (jack_port_id_t)dst;
00364 if (!CheckPort(mydst)) {
00365 jack_error("jack_port_tie called with a NULL dst port");
00366 return -1;
00367 }
00368 if (GetGraphManager()->GetPort(mysrc)->GetRefNum() != GetGraphManager()->GetPort(mydst)->GetRefNum()) {
00369 jack_error("jack_port_tie called with ports not belonging to the same client");
00370 return -1;
00371 }
00372 return GetGraphManager()->GetPort(mydst)->Tie(mysrc);
00373 }
00374
00375 EXPORT int jack_port_untie(jack_port_t* port)
00376 {
00377 #ifdef __CLIENTDEBUG__
00378 JackLibGlobals::CheckContext();
00379 #endif
00380 jack_port_id_t myport = (jack_port_id_t)port;
00381 if (!CheckPort(myport)) {
00382 jack_error("jack_port_untie called with an incorrect port %ld", myport);
00383 return -1;
00384 } else {
00385 return GetGraphManager()->GetPort(myport)->UnTie();
00386 }
00387 }
00388
00389 EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
00390 {
00391 #ifdef __CLIENTDEBUG__
00392 JackLibGlobals::CheckContext();
00393 #endif
00394 jack_port_id_t myport = (jack_port_id_t)port;
00395 if (!CheckPort(myport)) {
00396 jack_error("jack_port_get_latency called with an incorrect port %ld", myport);
00397 return 0;
00398 } else {
00399 WaitGraphChange();
00400 return GetGraphManager()->GetPort(myport)->GetLatency();
00401 }
00402 }
00403
00404 EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
00405 {
00406 #ifdef __CLIENTDEBUG__
00407 JackLibGlobals::CheckContext();
00408 #endif
00409 jack_port_id_t myport = (jack_port_id_t)port;
00410 if (!CheckPort(myport)) {
00411 jack_error("jack_port_set_latency called with an incorrect port %ld", myport);
00412 } else {
00413 GetGraphManager()->GetPort(myport)->SetLatency(frames);
00414 }
00415 }
00416
00417 EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
00418 {
00419
00420 return 0;
00421 }
00422
00423 EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
00424 {
00425 #ifdef __CLIENTDEBUG__
00426 JackLibGlobals::CheckContext();
00427 #endif
00428 jack_port_id_t myport = (jack_port_id_t)port;
00429 if (!CheckPort(myport)) {
00430 jack_error("jack_port_set_name called with an incorrect port %ld", myport);
00431 return -1;
00432 } else if (name == NULL) {
00433 jack_error("jack_port_set_name called with a NULL port name");
00434 return -1;
00435 } else {
00436 return GetGraphManager()->GetPort(myport)->SetName(name);
00437 }
00438 }
00439
00440 EXPORT int jack_port_set_alias(jack_port_t* port, const char* name)
00441 {
00442 #ifdef __CLIENTDEBUG__
00443 JackLibGlobals::CheckContext();
00444 #endif
00445 jack_port_id_t myport = (jack_port_id_t)port;
00446 if (!CheckPort(myport)) {
00447 jack_error("jack_port_set_alias called with an incorrect port %ld", myport);
00448 return -1;
00449 } else if (name == NULL) {
00450 jack_error("jack_port_set_alias called with a NULL port name");
00451 return -1;
00452 } else {
00453 return GetGraphManager()->GetPort(myport)->SetAlias(name);
00454 }
00455 }
00456
00457 EXPORT int jack_port_unset_alias(jack_port_t* port, const char* name)
00458 {
00459 #ifdef __CLIENTDEBUG__
00460 JackLibGlobals::CheckContext();
00461 #endif
00462 jack_port_id_t myport = (jack_port_id_t)port;
00463 if (!CheckPort(myport)) {
00464 jack_error("jack_port_unset_alias called with an incorrect port %ld", myport);
00465 return -1;
00466 } else if (name == NULL) {
00467 jack_error("jack_port_unset_alias called with a NULL port name");
00468 return -1;
00469 } else {
00470 return GetGraphManager()->GetPort(myport)->UnsetAlias(name);
00471 }
00472 }
00473
00474 EXPORT int jack_port_get_aliases(const jack_port_t* port, char* const aliases[2])
00475 {
00476 #ifdef __CLIENTDEBUG__
00477 JackLibGlobals::CheckContext();
00478 #endif
00479 jack_port_id_t myport = (jack_port_id_t)port;
00480 if (!CheckPort(myport)) {
00481 jack_error("jack_port_get_aliases called with an incorrect port %ld", myport);
00482 return -1;
00483 } else {
00484 return GetGraphManager()->GetPort(myport)->GetAliases(aliases);
00485 }
00486 }
00487
00488 EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
00489 {
00490 #ifdef __CLIENTDEBUG__
00491 JackLibGlobals::CheckContext();
00492 #endif
00493 jack_port_id_t myport = (jack_port_id_t)port;
00494 if (!CheckPort(myport)) {
00495 jack_error("jack_port_request_monitor called with an incorrect port %ld", myport);
00496 return -1;
00497 } else {
00498 return GetGraphManager()->RequestMonitor(myport, onoff);
00499 }
00500 }
00501
00502 EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
00503 {
00504 #ifdef __CLIENTDEBUG__
00505 JackLibGlobals::CheckContext();
00506 #endif
00507 JackClient* client = (JackClient*)ext_client;
00508 if (client == NULL) {
00509 jack_error("jack_port_request_monitor_by_name called with a NULL client");
00510 return -1;
00511 } else {
00512 jack_port_id_t myport = GetGraphManager()->GetPort(port_name);
00513 if (!CheckPort(myport)) {
00514 jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
00515 return -1;
00516 } else {
00517 return GetGraphManager()->RequestMonitor(myport, onoff);
00518 }
00519 }
00520 }
00521
00522 EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
00523 {
00524 #ifdef __CLIENTDEBUG__
00525 JackLibGlobals::CheckContext();
00526 #endif
00527 jack_port_id_t myport = (jack_port_id_t)port;
00528 if (!CheckPort(myport)) {
00529 jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport);
00530 return -1;
00531 } else {
00532 return GetGraphManager()->GetPort(myport)->EnsureMonitor(onoff);
00533 }
00534 }
00535
00536 EXPORT int jack_port_monitoring_input(jack_port_t* port)
00537 {
00538 #ifdef __CLIENTDEBUG__
00539 JackLibGlobals::CheckContext();
00540 #endif
00541 jack_port_id_t myport = (jack_port_id_t)port;
00542 if (!CheckPort(myport)) {
00543 jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport);
00544 return -1;
00545 } else {
00546 return GetGraphManager()->GetPort(myport)->MonitoringInput();
00547 }
00548 }
00549
00550 EXPORT int jack_is_realtime(jack_client_t* ext_client)
00551 {
00552 #ifdef __CLIENTDEBUG__
00553 JackLibGlobals::CheckContext();
00554 #endif
00555 JackClient* client = (JackClient*)ext_client;
00556 if (client == NULL) {
00557 jack_error("jack_is_realtime called with a NULL client");
00558 return -1;
00559 } else {
00560 return GetEngineControl()->fRealTime;
00561 }
00562 }
00563
00564 EXPORT void jack_on_shutdown(jack_client_t* ext_client, void (*function)(void* arg), void* arg)
00565 {
00566 #ifdef __CLIENTDEBUG__
00567 JackLibGlobals::CheckContext();
00568 #endif
00569 JackClient* client = (JackClient*)ext_client;
00570 if (client == NULL) {
00571 jack_error("jack_on_shutdown called with a NULL client");
00572 } else {
00573 client->OnShutdown(function, arg);
00574 }
00575 }
00576
00577 EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
00578 {
00579 #ifdef __CLIENTDEBUG__
00580 JackLibGlobals::CheckContext();
00581 #endif
00582 JackClient* client = (JackClient*)ext_client;
00583 if (client == NULL) {
00584 jack_error("jack_set_process_callback called with a NULL client");
00585 return -1;
00586 } else {
00587 return client->SetProcessCallback(callback, arg);
00588 }
00589 }
00590
00591 EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
00592 {
00593 #ifdef __CLIENTDEBUG__
00594 JackLibGlobals::CheckContext();
00595 #endif
00596 JackClient* client = (JackClient*)ext_client;
00597 if (client == NULL) {
00598 jack_error("jack_set_freewheel_callback called with a NULL client");
00599 return -1;
00600 } else {
00601 return client->SetFreewheelCallback(freewheel_callback, arg);
00602 }
00603 }
00604
00605 EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
00606 {
00607 #ifdef __CLIENTDEBUG__
00608 JackLibGlobals::CheckContext();
00609 #endif
00610 JackClient* client = (JackClient*)ext_client;
00611 if (client == NULL) {
00612 jack_error("jack_set_freewheel called with a NULL client");
00613 return -1;
00614 } else {
00615 return client->SetFreeWheel(onoff);
00616 }
00617 }
00618
00619 EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
00620 {
00621 #ifdef __CLIENTDEBUG__
00622 JackLibGlobals::CheckContext();
00623 #endif
00624 JackClient* client = (JackClient*)ext_client;
00625 if (client == NULL) {
00626 jack_error("jack_set_buffer_size called with a NULL client");
00627 return -1;
00628 } else if (!CheckBufferSize(buffer_size)) {
00629 return -1;
00630 } else {
00631 return client->SetBufferSize(buffer_size);
00632 }
00633 }
00634
00635 EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
00636 {
00637 #ifdef __CLIENTDEBUG__
00638 JackLibGlobals::CheckContext();
00639 #endif
00640 JackClient* client = (JackClient*)ext_client;
00641 if (client == NULL) {
00642 jack_error("jack_set_buffer_size_callback called with a NULL client");
00643 return -1;
00644 } else {
00645 return client->SetBufferSizeCallback(bufsize_callback, arg);
00646 }
00647 }
00648
00649 EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
00650 {
00651 #ifdef __CLIENTDEBUG__
00652 JackLibGlobals::CheckContext();
00653 #endif
00654 JackClient* client = (JackClient*)ext_client;
00655 if (client == NULL) {
00656 jack_error("jack_set_sample_rate_callback called with a NULL client");
00657 return -1;
00658 } else {
00659 jack_error("jack_set_sample_rate_callback: deprecated");
00660 return 0;
00661 }
00662 }
00663
00664 EXPORT int jack_set_client_registration_callback(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg)
00665 {
00666 #ifdef __CLIENTDEBUG__
00667 JackLibGlobals::CheckContext();
00668 #endif
00669 JackClient* client = (JackClient*)ext_client;
00670 if (client == NULL) {
00671 jack_error("jack_set_client_registration_callback called with a NULL client");
00672 return -1;
00673 } else {
00674 return client->SetClientRegistrationCallback(registration_callback, arg);
00675 }
00676 }
00677
00678 EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
00679 {
00680 #ifdef __CLIENTDEBUG__
00681 JackLibGlobals::CheckContext();
00682 #endif
00683 JackClient* client = (JackClient*)ext_client;
00684 if (client == NULL) {
00685 jack_error("jack_set_port_registration_callback called with a NULL client");
00686 return -1;
00687 } else {
00688 return client->SetPortRegistrationCallback(registration_callback, arg);
00689 }
00690 }
00691
00692 EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
00693 {
00694 #ifdef __CLIENTDEBUG__
00695 JackLibGlobals::CheckContext();
00696 #endif
00697 JackClient* client = (JackClient*)ext_client;
00698 JackLog("jack_set_graph_order_callback ext_client %x client %x \n", ext_client, client);
00699 if (client == NULL) {
00700 jack_error("jack_set_graph_order_callback called with a NULL client");
00701 return -1;
00702 } else {
00703 return client->SetGraphOrderCallback(graph_callback, arg);
00704 }
00705 }
00706
00707 EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
00708 {
00709 #ifdef __CLIENTDEBUG__
00710 JackLibGlobals::CheckContext();
00711 #endif
00712 JackClient* client = (JackClient*)ext_client;
00713 if (client == NULL) {
00714 jack_error("jack_set_xrun_callback called with a NULL client");
00715 return -1;
00716 } else {
00717 return client->SetXRunCallback(xrun_callback, arg);
00718 }
00719 }
00720
00721 EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
00722 {
00723 #ifdef __CLIENTDEBUG__
00724 JackLibGlobals::CheckContext();
00725 #endif
00726 JackClient* client = (JackClient*)ext_client;
00727 JackLog("jack_set_thread_init_callback ext_client %x client %x \n", ext_client, client);
00728 if (client == NULL) {
00729 jack_error("jack_set_thread_init_callback called with a NULL client");
00730 return -1;
00731 } else {
00732 return client->SetInitCallback(init_callback, arg);
00733 }
00734 }
00735
00736 EXPORT int jack_activate(jack_client_t* ext_client)
00737 {
00738 #ifdef __CLIENTDEBUG__
00739 JackLibGlobals::CheckContext();
00740 #endif
00741 JackClient* client = (JackClient*)ext_client;
00742 if (client == NULL) {
00743 jack_error("jack_activate called with a NULL client");
00744 return -1;
00745 } else {
00746 return client->Activate();
00747 }
00748 }
00749
00750 EXPORT int jack_deactivate(jack_client_t* ext_client)
00751 {
00752 #ifdef __CLIENTDEBUG__
00753 JackLibGlobals::CheckContext();
00754 #endif
00755 JackClient* client = (JackClient*)ext_client;
00756 if (client == NULL) {
00757 jack_error("jack_deactivate called with a NULL client");
00758 return -1;
00759 } else {
00760 return client->Deactivate();
00761 }
00762 }
00763
00764 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)
00765 {
00766 #ifdef __CLIENTDEBUG__
00767 JackLibGlobals::CheckContext();
00768 #endif
00769 JackClient* client = (JackClient*)ext_client;
00770 if (client == NULL) {
00771 jack_error("jack_port_register called with a NULL client");
00772 return NULL;
00773 } else if ((port_name == NULL) || (port_type == NULL)) {
00774 jack_error("jack_port_register called with a NULL port name or a NULL port_type");
00775 return NULL;
00776 } else {
00777 return (jack_port_t *)client->PortRegister(port_name, port_type, flags, buffer_size);
00778 }
00779 }
00780
00781 EXPORT int jack_port_unregister(jack_client_t* ext_client, jack_port_t* port)
00782 {
00783 #ifdef __CLIENTDEBUG__
00784 JackLibGlobals::CheckContext();
00785 #endif
00786 JackClient* client = (JackClient*)ext_client;
00787 if (client == NULL) {
00788 jack_error("jack_port_unregister called with a NULL client");
00789 return -1;
00790 }
00791 jack_port_id_t myport = (jack_port_id_t)port;
00792 if (!CheckPort(myport)) {
00793 jack_error("jack_port_unregister called with an incorrect port %ld", myport);
00794 return -1;
00795 }
00796 return client->PortUnRegister(myport);
00797 }
00798
00799 EXPORT int jack_port_is_mine(const jack_client_t* ext_client, const jack_port_t* port)
00800 {
00801 #ifdef __CLIENTDEBUG__
00802 JackLibGlobals::CheckContext();
00803 #endif
00804 JackClient* client = (JackClient*)ext_client;
00805 if (client == NULL) {
00806 jack_error("jack_port_is_mine called with a NULL client");
00807 return -1;
00808 }
00809 jack_port_id_t myport = (jack_port_id_t)port;
00810 if (!CheckPort(myport)) {
00811 jack_error("jack_port_is_mine called with an incorrect port %ld", myport);
00812 return -1;
00813 }
00814 return client->PortIsMine(myport);
00815 }
00816
00817 EXPORT const char** jack_port_get_connections(const jack_port_t* port)
00818 {
00819 #ifdef __CLIENTDEBUG__
00820 JackLibGlobals::CheckContext();
00821 #endif
00822 jack_port_id_t myport = (jack_port_id_t)port;
00823 if (!CheckPort(myport)) {
00824 jack_error("jack_port_get_connections called with an incorrect port %ld", myport);
00825 return NULL;
00826 } else {
00827 WaitGraphChange();
00828 return GetGraphManager()->GetConnections(myport);
00829 }
00830 }
00831
00832
00833 EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_client, const jack_port_t* port)
00834 {
00835 #ifdef __CLIENTDEBUG__
00836 JackLibGlobals::CheckContext();
00837 #endif
00838 JackClient* client = (JackClient*)ext_client;
00839 if (client == NULL) {
00840 jack_error("jack_port_get_all_connections called with a NULL client");
00841 return NULL;
00842 }
00843
00844 jack_port_id_t myport = (jack_port_id_t)port;
00845 if (!CheckPort(myport)) {
00846 jack_error("jack_port_get_all_connections called with an incorrect port %ld", myport);
00847 return NULL;
00848 } else {
00849 WaitGraphChange();
00850 return GetGraphManager()->GetConnections(myport);
00851 }
00852 }
00853
00854
00855 EXPORT int jack_port_lock(jack_client_t* ext_client, jack_port_t* port)
00856 {
00857 #ifdef __CLIENTDEBUG__
00858 JackLibGlobals::CheckContext();
00859 #endif
00860 JackClient* client = (JackClient*)ext_client;
00861 if (client == NULL) {
00862 jack_error("jack_port_lock called with a NULL client");
00863 return -1;
00864 }
00865
00866 jack_port_id_t myport = (jack_port_id_t)port;
00867 if (!CheckPort(myport)) {
00868 jack_error("jack_port_lock called with an incorrect port %ld", myport);
00869 return -1;
00870 } else {
00871 return (myport && client->PortIsMine(myport)) ? GetGraphManager()->GetPort(myport)->Lock() : -1;
00872 }
00873 }
00874
00875
00876 EXPORT int jack_port_unlock(jack_client_t* ext_client, jack_port_t* port)
00877 {
00878 #ifdef __CLIENTDEBUG__
00879 JackLibGlobals::CheckContext();
00880 #endif
00881 JackClient* client = (JackClient*)ext_client;
00882 if (client == NULL) {
00883 jack_error("jack_port_unlock called with a NULL client");
00884 return -1;
00885 }
00886
00887 jack_port_id_t myport = (jack_port_id_t)port;
00888 if (!CheckPort(myport)) {
00889 jack_error("jack_port_unlock called with an incorrect port %ld", myport);
00890 return -1;
00891 } else {
00892 return (myport && client->PortIsMine(myport)) ? GetGraphManager()->GetPort(myport)->Unlock() : -1;
00893 }
00894 }
00895
00896 EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port)
00897 {
00898 #ifdef __CLIENTDEBUG__
00899 JackLibGlobals::CheckContext();
00900 #endif
00901 JackClient* client = (JackClient*)ext_client;
00902 if (client == NULL) {
00903 jack_error("jack_port_get_total_latency called with a NULL client");
00904 return 0;
00905 }
00906
00907 jack_port_id_t myport = (jack_port_id_t)port;
00908 if (!CheckPort(myport)) {
00909 jack_error("jack_port_get_total_latency called with an incorrect port %ld", myport);
00910 return 0;
00911 } else {
00912
00913 WaitGraphChange();
00914 return GetGraphManager()->GetTotalLatency(myport);
00915 }
00916 }
00917
00918 EXPORT int jack_connect(jack_client_t* ext_client, const char* src, const char* dst)
00919 {
00920 #ifdef __CLIENTDEBUG__
00921 JackLibGlobals::CheckContext();
00922 #endif
00923 JackClient* client = (JackClient*)ext_client;
00924 if (client == NULL) {
00925 jack_error("jack_connect called with a NULL client");
00926 return -1;
00927 } else if ((src == NULL) || (dst == NULL)) {
00928 jack_error("jack_connect called with a NULL port name");
00929 return -1;
00930 } else {
00931 return client->PortConnect(src, dst);
00932 }
00933 }
00934
00935 EXPORT int jack_disconnect(jack_client_t* ext_client, const char* src, const char* dst)
00936 {
00937 #ifdef __CLIENTDEBUG__
00938 JackLibGlobals::CheckContext();
00939 #endif
00940 JackClient* client = (JackClient*)ext_client;
00941 if (client == NULL) {
00942 jack_error("jack_disconnect called with a NULL client");
00943 return -1;
00944 } else if ((src == NULL) || (dst == NULL)) {
00945 jack_error("jack_connect called with a NULL port name");
00946 return -1;
00947 } else {
00948 return client->PortDisconnect(src, dst);
00949 }
00950 }
00951
00952 EXPORT int jack_port_connect(jack_client_t* ext_client, jack_port_t* src, jack_port_t* dst)
00953 {
00954 #ifdef __CLIENTDEBUG__
00955 JackLibGlobals::CheckContext();
00956 #endif
00957 JackClient* client = (JackClient*)ext_client;
00958 if (client == NULL) {
00959 jack_error("jack_port_connect called with a NULL client");
00960 return -1;
00961 }
00962 jack_port_id_t mysrc = (jack_port_id_t)src;
00963 if (!CheckPort(mysrc)) {
00964 jack_error("jack_port_connect called with a NULL src port");
00965 return -1;
00966 }
00967 jack_port_id_t mydst = (jack_port_id_t)dst;
00968 if (!CheckPort(mydst)) {
00969 jack_error("jack_port_connect called with a NULL dst port");
00970 return -1;
00971 }
00972 return client->PortConnect(mysrc, mydst);
00973 }
00974
00975 EXPORT int jack_port_disconnect(jack_client_t* ext_client, jack_port_t* src)
00976 {
00977 #ifdef __CLIENTDEBUG__
00978 JackLibGlobals::CheckContext();
00979 #endif
00980 JackClient* client = (JackClient*)ext_client;
00981 if (client == NULL) {
00982 jack_error("jack_port_disconnect called with a NULL client");
00983 return -1;
00984 }
00985 jack_port_id_t myport = (jack_port_id_t)src;
00986 if (!CheckPort(myport)) {
00987 jack_error("jack_port_disconnect called with an incorrect port %ld", myport);
00988 return -1;
00989 }
00990 return client->PortDisconnect(myport);
00991 }
00992
00993 EXPORT jack_nframes_t jack_get_sample_rate(jack_client_t* ext_client)
00994 {
00995 #ifdef __CLIENTDEBUG__
00996 JackLibGlobals::CheckContext();
00997 #endif
00998 JackClient* client = (JackClient*)ext_client;
00999 if (client == NULL) {
01000 jack_error("jack_get_sample_rate called with a NULL client");
01001 return 0;
01002 } else {
01003 return GetEngineControl()->fSampleRate;
01004 }
01005 }
01006
01007 EXPORT jack_nframes_t jack_get_buffer_size(jack_client_t* ext_client)
01008 {
01009 #ifdef __CLIENTDEBUG__
01010 JackLibGlobals::CheckContext();
01011 #endif
01012 JackClient* client = (JackClient*)ext_client;
01013 if (client == NULL) {
01014 jack_error("jack_get_buffer_size called with a NULL client");
01015 return 0;
01016 } else {
01017 return GetEngineControl()->fBufferSize;
01018 }
01019 }
01020
01021 EXPORT const char** jack_get_ports(jack_client_t* ext_client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags)
01022 {
01023 #ifdef __CLIENTDEBUG__
01024 JackLibGlobals::CheckContext();
01025 #endif
01026 JackClient* client = (JackClient*)ext_client;
01027 if (client == NULL) {
01028 jack_error("jack_get_ports called with a NULL client");
01029 return NULL;
01030 }
01031 return GetGraphManager()->GetPorts(port_name_pattern, type_name_pattern, flags);
01032 }
01033
01034 EXPORT jack_port_t* jack_port_by_name(jack_client_t* ext_client, const char* portname)
01035 {
01036 #ifdef __CLIENTDEBUG__
01037 JackLibGlobals::CheckContext();
01038 #endif
01039 JackClient* client = (JackClient*)ext_client;
01040 if (client == NULL) {
01041 jack_error("jack_get_ports called with a NULL client");
01042 return 0;
01043 }
01044
01045 if (portname == NULL) {
01046 jack_error("jack_port_by_name called with a NULL port name");
01047 return NULL;
01048 } else {
01049 int res = GetGraphManager()->GetPort(portname);
01050 return (res == NO_PORT) ? NULL : (jack_port_t*)res;
01051 }
01052 }
01053
01054 EXPORT jack_port_t* jack_port_by_id(jack_client_t* ext_client, jack_port_id_t id)
01055 {
01056 #ifdef __CLIENTDEBUG__
01057 JackLibGlobals::CheckContext();
01058 #endif
01059
01060 return (jack_port_t*)id;
01061 }
01062
01063 EXPORT int jack_engine_takeover_timebase(jack_client_t* ext_client)
01064 {
01065 #ifdef __CLIENTDEBUG__
01066 JackLibGlobals::CheckContext();
01067 #endif
01068 JackClient* client = (JackClient*)ext_client;
01069 if (client == NULL) {
01070 jack_error("jack_engine_takeover_timebase called with a NULL client");
01071 return -1;
01072 } else {
01073 jack_error("jack_engine_takeover_timebase: deprecated\n");
01074 return 0;
01075 }
01076 }
01077
01078 EXPORT jack_nframes_t jack_frames_since_cycle_start(const jack_client_t* ext_client)
01079 {
01080 #ifdef __CLIENTDEBUG__
01081 JackLibGlobals::CheckContext();
01082 #endif
01083 JackTimer timer;
01084 GetEngineControl()->ReadFrameTime(&timer);
01085 return (jack_nframes_t) floor((((float)GetEngineControl()->fSampleRate) / 1000000.0f) * (GetMicroSeconds() - timer.fCurrentCallback));
01086 }
01087
01088 EXPORT jack_time_t jack_get_time(jack_client_t *client)
01089 {
01090 return GetMicroSeconds();
01091 }
01092
01093 EXPORT jack_time_t jack_frames_to_time(const jack_client_t* ext_client, jack_nframes_t frames)
01094 {
01095 #ifdef __CLIENTDEBUG__
01096 JackLibGlobals::CheckContext();
01097 #endif
01098 JackClient* client = (JackClient*)ext_client;
01099 if (client == NULL) {
01100 jack_error("jack_frames_to_time called with a NULL client");
01101 return 0;
01102 } else {
01103 JackTimer timer;
01104 GetEngineControl()->ReadFrameTime(&timer);
01105 if (timer.fInitialized) {
01106 return timer.fCurrentWakeup +
01107 (long) rint(((double) ((frames - timer.fFrames)) *
01108 ((jack_time_t)(timer.fNextWakeUp - timer.fCurrentWakeup))) / GetEngineControl()->fBufferSize);
01109 } else {
01110 return 0;
01111 }
01112 }
01113 }
01114
01115 EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t* ext_client, jack_time_t time)
01116 {
01117 #ifdef __CLIENTDEBUG__
01118 JackLibGlobals::CheckContext();
01119 #endif
01120 JackClient* client = (JackClient*)ext_client;
01121 if (client == NULL) {
01122 jack_error("jack_time_to_frames called with a NULL client");
01123 return 0;
01124 } else {
01125 JackTimer timer;
01126 GetEngineControl()->ReadFrameTime(&timer);
01127 if (timer.fInitialized) {
01128 return timer.fFrames +
01129 (long) rint(((double) ((time - timer.fCurrentWakeup)) /
01130 ((jack_time_t)(timer.fNextWakeUp - timer.fCurrentWakeup))) * GetEngineControl()->fBufferSize);
01131 } else {
01132 return 0;
01133 }
01134 }
01135 }
01136
01137 EXPORT jack_nframes_t jack_frame_time(const jack_client_t* ext_client)
01138 {
01139 return jack_time_to_frames(ext_client, GetMicroSeconds());
01140 }
01141
01142 EXPORT jack_nframes_t jack_last_frame_time(const jack_client_t* ext_client)
01143 {
01144 #ifdef __CLIENTDEBUG__
01145 JackLibGlobals::CheckContext();
01146 #endif
01147 JackTimer timer;
01148 GetEngineControl()->ReadFrameTime(&timer);
01149 return timer.fFrames;
01150 }
01151
01152 EXPORT float jack_cpu_load(jack_client_t* ext_client)
01153 {
01154 #ifdef __CLIENTDEBUG__
01155 JackLibGlobals::CheckContext();
01156 #endif
01157 JackClient* client = (JackClient*)ext_client;
01158 if (client == NULL) {
01159 jack_error("jack_cpu_load called with a NULL client");
01160 return 0.0f;
01161 } else {
01162 return GetEngineControl()->fCPULoad;
01163 }
01164 }
01165
01166 EXPORT pthread_t jack_client_thread_id(jack_client_t* ext_client)
01167 {
01168 #ifdef __CLIENTDEBUG__
01169 JackLibGlobals::CheckContext();
01170 #endif
01171 JackClient* client = (JackClient*)ext_client;
01172 if (client == NULL) {
01173 jack_error("jack_client_thread_id called with a NULL client");
01174 return (pthread_t)NULL;
01175 } else {
01176 return client->GetThreadID();
01177 }
01178 }
01179
01180 EXPORT char* jack_get_client_name (jack_client_t* ext_client)
01181 {
01182 #ifdef __CLIENTDEBUG__
01183 JackLibGlobals::CheckContext();
01184 #endif
01185 JackClient* client = (JackClient*)ext_client;
01186 if (client == NULL) {
01187 jack_error("jack_get_client_name called with a NULL client");
01188 return NULL;
01189 } else {
01190 return client->GetClientControl()->fName;
01191 }
01192 }
01193
01194 EXPORT int jack_client_name_size(void)
01195 {
01196 return JACK_CLIENT_NAME_SIZE;
01197 }
01198
01199 EXPORT int jack_port_name_size(void)
01200 {
01201 return JACK_PORT_NAME_SIZE;
01202 }
01203
01204
01205 EXPORT int jack_release_timebase(jack_client_t* ext_client)
01206 {
01207 #ifdef __CLIENTDEBUG__
01208 JackLibGlobals::CheckContext();
01209 #endif
01210 JackClient* client = (JackClient*)ext_client;
01211 if (client == NULL) {
01212 jack_error("jack_release_timebase called with a NULL client");
01213 return -1;
01214 } else {
01215 return client->ReleaseTimebase();
01216 }
01217 }
01218
01219 EXPORT int jack_set_sync_callback(jack_client_t* ext_client, JackSyncCallback sync_callback, void *arg)
01220 {
01221 #ifdef __CLIENTDEBUG__
01222 JackLibGlobals::CheckContext();
01223 #endif
01224 JackClient* client = (JackClient*)ext_client;
01225 if (client == NULL) {
01226 jack_error("jack_set_sync_callback called with a NULL client");
01227 return -1;
01228 } else {
01229 return client->SetSyncCallback(sync_callback, arg);
01230 }
01231 }
01232
01233 EXPORT int jack_set_sync_timeout(jack_client_t* ext_client, jack_time_t timeout)
01234 {
01235 #ifdef __CLIENTDEBUG__
01236 JackLibGlobals::CheckContext();
01237 #endif
01238 JackClient* client = (JackClient*)ext_client;
01239 if (client == NULL) {
01240 jack_error("jack_set_sync_timeout called with a NULL client");
01241 return -1;
01242 } else {
01243 return client->SetSyncTimeout(timeout);
01244 }
01245 }
01246
01247 EXPORT int jack_set_timebase_callback(jack_client_t* ext_client, int conditional, JackTimebaseCallback timebase_callback, void* arg)
01248 {
01249 #ifdef __CLIENTDEBUG__
01250 JackLibGlobals::CheckContext();
01251 #endif
01252 JackClient* client = (JackClient*)ext_client;
01253 if (client == NULL) {
01254 jack_error("jack_set_timebase_callback called with a NULL client");
01255 return -1;
01256 } else {
01257 return client->SetTimebaseCallback(conditional, timebase_callback, arg);
01258 }
01259 }
01260
01261 EXPORT int jack_transport_locate(jack_client_t* ext_client, jack_nframes_t frame)
01262 {
01263 #ifdef __CLIENTDEBUG__
01264 JackLibGlobals::CheckContext();
01265 #endif
01266 JackClient* client = (JackClient*)ext_client;
01267 if (client == NULL) {
01268 jack_error("jack_transport_locate called with a NULL client");
01269 return -1;
01270 } else {
01271 return client->TransportLocate(frame);
01272 }
01273 }
01274
01275 EXPORT jack_transport_state_t jack_transport_query(const jack_client_t* ext_client, jack_position_t* pos)
01276 {
01277 #ifdef __CLIENTDEBUG__
01278 JackLibGlobals::CheckContext();
01279 #endif
01280 JackClient* client = (JackClient*)ext_client;
01281 if (client == NULL) {
01282 jack_error("jack_transport_query called with a NULL client");
01283 return JackTransportStopped;
01284 } else {
01285 return client->TransportQuery(pos);
01286 }
01287 }
01288
01289 EXPORT jack_nframes_t jack_get_current_transport_frame(const 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_current_transport_frame called with a NULL client");
01297 return 0;
01298 } else {
01299 return client->GetCurrentTransportFrame();
01300 }
01301 }
01302
01303 EXPORT int jack_transport_reposition(jack_client_t* ext_client, jack_position_t* pos)
01304 {
01305 #ifdef __CLIENTDEBUG__
01306 JackLibGlobals::CheckContext();
01307 #endif
01308 JackClient* client = (JackClient*)ext_client;
01309 if (client == NULL) {
01310 jack_error("jack_transport_reposition called with a NULL client");
01311 return -1;
01312 } else {
01313 return client->TransportReposition(pos);
01314 }
01315 }
01316
01317 EXPORT void jack_transport_start(jack_client_t* ext_client)
01318 {
01319 #ifdef __CLIENTDEBUG__
01320 JackLibGlobals::CheckContext();
01321 #endif
01322 JackClient* client = (JackClient*)ext_client;
01323 if (client == NULL) {
01324 jack_error("jack_transport_start called with a NULL client");
01325 } else {
01326 client->TransportStart();
01327 }
01328 }
01329
01330 EXPORT void jack_transport_stop(jack_client_t* ext_client)
01331 {
01332 #ifdef __CLIENTDEBUG__
01333 JackLibGlobals::CheckContext();
01334 #endif
01335 JackClient* client = (JackClient*)ext_client;
01336 if (client == NULL) {
01337 jack_error("jack_transport_stop called with a NULL client");
01338 } else {
01339 client->TransportStop();
01340 }
01341 }
01342
01343
01344 EXPORT void jack_get_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
01345 {
01346 jack_error("jack_get_transport_info: deprecated");
01347 if (tinfo)
01348 memset(tinfo, 0, sizeof(jack_transport_info_t));
01349 }
01350
01351 EXPORT void jack_set_transport_info(jack_client_t* ext_client, jack_transport_info_t* tinfo)
01352 {
01353 jack_error("jack_set_transport_info: deprecated");
01354 if (tinfo)
01355 memset(tinfo, 0, sizeof(jack_transport_info_t));
01356 }
01357
01358
01359 EXPORT float jack_get_max_delayed_usecs(jack_client_t* ext_client)
01360 {
01361 #ifdef __CLIENTDEBUG__
01362 JackLibGlobals::CheckContext();
01363 #endif
01364 JackLog("jack_get_max_delayed_usecs: not yet implemented\n");
01365 return 0.f;
01366 }
01367
01368 EXPORT float jack_get_xrun_delayed_usecs(jack_client_t* ext_client)
01369 {
01370 #ifdef __CLIENTDEBUG__
01371 JackLibGlobals::CheckContext();
01372 #endif
01373 JackLog("jack_get_xrun_delayed_usecs: not yet implemented\n");
01374 return 0.f;
01375 }
01376
01377 EXPORT void jack_reset_max_delayed_usecs(jack_client_t* ext_client)
01378 {
01379 #ifdef __CLIENTDEBUG__
01380 JackLibGlobals::CheckContext();
01381 #endif
01382 JackLog("jack_reset_max_delayed_usecs: not yet implemented\n");
01383 }
01384
01385
01386 EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority)
01387 {
01388 #ifdef __APPLE__
01389 return JackMachThread::AcquireRealTimeImp(thread, 0, 500 * 1000, 500 * 1000);
01390 #elif WIN32
01391 return JackWinThread::AcquireRealTimeImp(thread, priority);
01392 #else
01393 return JackPosixThread::AcquireRealTimeImp(thread, priority);
01394 #endif
01395 }
01396
01397 EXPORT int jack_client_create_thread(jack_client_t* client,
01398 pthread_t *thread,
01399 int priority,
01400 int realtime,
01401 void *(*start_routine)(void*),
01402 void *arg)
01403 {
01404 #ifdef __APPLE__
01405 return JackPosixThread::StartImp(thread, priority, realtime, start_routine, arg);
01406 #elif WIN32
01407 return JackWinThread::StartImp(thread, priority, realtime, (ThreadCallback)start_routine, arg);
01408 #else
01409 return JackPosixThread::StartImp(thread, priority, realtime, start_routine, arg);
01410 #endif
01411 }
01412
01413 EXPORT int jack_drop_real_time_scheduling(pthread_t thread)
01414 {
01415 #ifdef __APPLE__
01416 return JackMachThread::DropRealTimeImp(thread);
01417 #elif WIN32
01418 return JackWinThread::DropRealTimeImp(thread);
01419 #else
01420 return JackPosixThread::DropRealTimeImp(thread);
01421 #endif
01422 }
01423
01424
01425 EXPORT char* jack_get_internal_client_name(jack_client_t* ext_client, jack_intclient_t intclient)
01426 {
01427 #ifdef __CLIENTDEBUG__
01428 JackLibGlobals::CheckContext();
01429 #endif
01430 JackClient* client = (JackClient*)ext_client;
01431 if (client == NULL) {
01432 jack_error("jack_get_internal_client_name called with a NULL client");
01433 return NULL;
01434 } else if (intclient < 0 || intclient >= CLIENT_NUM) {
01435 jack_error("jack_get_internal_client_name: incorrect client");
01436 return NULL;
01437 } else {
01438 return client->GetInternalClientName(intclient);
01439 }
01440 }
01441
01442 EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, const char* client_name, jack_status_t* status)
01443 {
01444 #ifdef __CLIENTDEBUG__
01445 JackLibGlobals::CheckContext();
01446 #endif
01447 JackClient* client = (JackClient*)ext_client;
01448 if (client == NULL) {
01449 jack_error("jack_internal_client_handle called with a NULL client");
01450 return 0;
01451 } else {
01452 jack_status_t my_status;
01453 if (status == NULL)
01454 status = &my_status;
01455 *status = (jack_status_t)0;
01456 return client->InternalClientHandle(client_name, status);
01457 }
01458 }
01459
01460 EXPORT jack_intclient_t jack_internal_client_load(jack_client_t* ext_client, const char* client_name, jack_options_t options, jack_status_t* status, ...)
01461 {
01462 #ifdef __CLIENTDEBUG__
01463 JackLibGlobals::CheckContext();
01464 #endif
01465 JackClient* client = (JackClient*)ext_client;
01466 if (client == NULL) {
01467 jack_error("jack_internal_client_load called with a NULL client");
01468 return 0;
01469 } else {
01470 va_list ap;
01471 jack_varargs_t va;
01472 jack_status_t my_status;
01473
01474 if (status == NULL)
01475 status = &my_status;
01476 *status = (jack_status_t)0;
01477
01478
01479 if ((options & ~JackLoadOptions)) {
01480 int my_status1 = *status | (JackFailure | JackInvalidOption);
01481 *status = (jack_status_t)my_status1;
01482 return 0;
01483 }
01484
01485
01486 va_start(ap, status);
01487 jack_varargs_parse(options, ap, &va);
01488 va_end(ap);
01489
01490 return client->InternalClientLoad(client_name, options, status, &va);
01491 }
01492 }
01493
01494 EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack_intclient_t intclient)
01495 {
01496 #ifdef __CLIENTDEBUG__
01497 JackLibGlobals::CheckContext();
01498 #endif
01499 JackClient* client = (JackClient*)ext_client;
01500 if (client == NULL) {
01501 jack_error("jack_internal_client_unload called with a NULL client");
01502 return (jack_status_t)(JackNoSuchClient | JackFailure);
01503 } else if (intclient < 0 || intclient >= CLIENT_NUM) {
01504 jack_error("jack_internal_client_unload: incorrect client");
01505 return (jack_status_t)(JackNoSuchClient | JackFailure);
01506 } else {
01507 jack_status_t my_status;
01508 client->InternalClientUnload(intclient, &my_status);
01509 return my_status;
01510 }
01511 }