1 /* 2 Copyright (C) 2001 Paul Davis 3 Copyright (C) 2004 Jack O'Quin 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU Lesser General Public License as published by 7 the Free Software Foundation; either version 2.1 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 */ 20 21 module jack.c.jack; 22 public import jack.c.systemdeps; 23 public import jack.c.types; 24 public import jack.c.transport; 25 import core.stdc.config: c_ulong; 26 27 extern(C) 28 { 29 30 /** 31 * Note: More documentation can be found in jack/types.h. 32 */ 33 34 /************************************************************* 35 * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function 36 * added to the JACK API after the 0.116.2 release. 37 * 38 * Functions that predate this release are marked with 39 * JACK_WEAK_OPTIONAL_EXPORT which can be defined at compile 40 * time in a variety of ways. The default definition is empty, 41 * so that these symbols get normal linkage. If you wish to 42 * use all JACK symbols with weak linkage, include 43 * <jack/weakjack.h> before jack.h. 44 *************************************************************/ 45 46 /** 47 * Call this function to get version of the JACK, in form of several numbers 48 * 49 * @param major_ptr pointer to variable receiving major version of JACK. 50 * 51 * @param minor_ptr pointer to variable receiving minor version of JACK. 52 * 53 * @param major_ptr pointer to variable receiving micro version of JACK. 54 * 55 * @param major_ptr pointer to variable receiving protocol version of JACK. 56 * 57 */ 58 void 59 jack_get_version( 60 int *major_ptr, 61 int *minor_ptr, 62 int *micro_ptr, 63 int *proto_ptr) /* JACK_OPTIONAL_WEAK_EXPORT */; 64 65 /** 66 * Call this function to get version of the JACK, in form of a string 67 * 68 * @return Human readable string describing JACK version being used. 69 * 70 */ 71 const(char) * 72 jack_get_version_string() /* JACK_OPTIONAL_WEAK_EXPORT */; 73 74 /** 75 * @defgroup ClientFunctions Creating & manipulating clients 76 * @{ 77 */ 78 79 /** 80 * Open an external client session with a JACK server. This interface 81 * is more complex but more powerful than jack_client_new(). With it, 82 * clients may choose which of several servers to connect, and control 83 * whether and how to start the server automatically, if it was not 84 * already running. There is also an option for JACK to generate a 85 * unique client name, when necessary. 86 * 87 * @param client_name of at most jack_client_name_size() characters. 88 * The name scope is local to each server. Unless forbidden by the 89 * @ref JackUseExactName option, the server will modify this name to 90 * create a unique variant, if needed. 91 * 92 * @param options formed by OR-ing together @ref JackOptions bits. 93 * Only the @ref JackOpenOptions bits are allowed. 94 * 95 * @param status (if non-NULL) an address for JACK to return 96 * information from the open operation. This status word is formed by 97 * OR-ing together the relevant @ref JackStatus bits. 98 * 99 * 100 * <b>Optional parameters:</b> depending on corresponding [@a options 101 * bits] additional parameters may follow @a status (in this order). 102 * 103 * @arg [@ref JackServerName] <em>(char *) server_name</em> selects 104 * from among several possible concurrent server instances. Server 105 * names are unique to each user. If unspecified, use "default" 106 * unless \$JACK_DEFAULT_SERVER is defined in the process environment. 107 * 108 * @return Opaque client handle if successful. If this is NULL, the 109 * open operation failed, @a *status includes @ref JackFailure and the 110 * caller is not a JACK client. 111 */ 112 jack_client_t * jack_client_open (const(char) *client_name, 113 jack_options_t options, 114 jack_status_t *status, ...) /* JACK_OPTIONAL_WEAK_EXPORT */; 115 116 /** 117 * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN 118 * NEW JACK CLIENTS 119 * 120 * @deprecated Please use jack_client_open(). 121 */ 122 deprecated 123 jack_client_t * jack_client_new (const(char) *client_name) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 124 125 /** 126 * Disconnects an external client from a JACK server. 127 * 128 * @return 0 on success, otherwise a non-zero error code 129 */ 130 int jack_client_close (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 131 132 /** 133 * @return the maximum number of characters in a JACK client name 134 * including the final NULL character. This value is a constant. 135 */ 136 int jack_client_name_size () /* JACK_OPTIONAL_WEAK_EXPORT */; 137 138 /** 139 * @return pointer to actual client name. This is useful when @ref 140 * JackUseExactName is not specified on open and @ref 141 * JackNameNotUnique status was returned. In that case, the actual 142 * name will differ from the @a client_name requested. 143 */ 144 char * jack_get_client_name (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 145 146 /** 147 * Load an internal client into the Jack server. 148 * 149 * Internal clients run inside the JACK server process. They can use 150 * most of the same functions as external clients. Each internal 151 * client must declare jack_initialize() and jack_finish() entry 152 * points, called at load and unload times. See inprocess.c for an 153 * example of how to write an internal client. 154 * 155 * @deprecated Please use jack_internal_client_load(). 156 * 157 * @param client_name of at most jack_client_name_size() characters. 158 * 159 * @param load_name of a shared object file containing the code for 160 * the new client. 161 * 162 * @param load_init an arbitary string passed to the jack_initialize() 163 * routine of the new client (may be NULL). 164 * 165 * @return 0 if successful. 166 */ 167 deprecated 168 int jack_internal_client_new (const(char) *client_name, 169 const(char) *load_name, 170 const(char) *load_init) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 171 172 /** 173 * Remove an internal client from a JACK server. 174 * 175 * @deprecated Please use jack_internal_client_unload(). 176 */ 177 deprecated 178 void jack_internal_client_close (const(char) *client_name) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 179 180 /** 181 * Tell the Jack server that the program is ready to start processing 182 * audio. 183 * 184 * @return 0 on success, otherwise a non-zero error code 185 */ 186 int jack_activate (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 187 188 /** 189 * Tell the Jack server to remove this @a client from the process 190 * graph. Also, disconnect all ports belonging to it, since inactive 191 * clients have no port connections. 192 * 193 * @return 0 on success, otherwise a non-zero error code 194 */ 195 int jack_deactivate (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 196 197 /** 198 * @return pid of client. If not available, 0 will be returned. 199 */ 200 int jack_get_client_pid (const(char) *name) /* JACK_OPTIONAL_WEAK_EXPORT */; 201 202 /** 203 * @return the pthread ID of the thread running the JACK client side 204 * real-time code. 205 */ 206 jack_native_thread_t jack_client_thread_id (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 207 208 /*@}*/ 209 210 /** 211 * @param client pointer to JACK client structure. 212 * 213 * Check if the JACK subsystem is running with -R (--realtime). 214 * 215 * @return 1 if JACK is running realtime, 0 otherwise 216 */ 217 int jack_is_realtime (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 218 219 /** 220 * @defgroup NonCallbackAPI The non-callback API 221 * @{ 222 */ 223 224 /** 225 * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN 226 * NEW JACK CLIENTS. 227 * 228 * @deprecated Please use jack_cycle_wait() and jack_cycle_signal() functions. 229 */ 230 deprecated 231 jack_nframes_t jack_thread_wait (jack_client_t *client, int status) /* JACK_OPTIONAL_WEAK_EXPORT */; 232 233 /** 234 * Wait until this JACK client should process data. 235 * 236 * @param client - pointer to a JACK client structure 237 * 238 * @return the number of frames of data to process 239 */ 240 jack_nframes_t jack_cycle_wait (jack_client_t* client) /* JACK_OPTIONAL_WEAK_EXPORT */; 241 242 /** 243 * Signal next clients in the graph. 244 * 245 * @param client - pointer to a JACK client structure 246 * @param status - if non-zero, calling thread should exit 247 */ 248 void jack_cycle_signal (jack_client_t* client, int status) /* JACK_OPTIONAL_WEAK_EXPORT */; 249 250 /** 251 * Tell the Jack server to call @a thread_callback in the RT thread. 252 * Typical use are in conjunction with @a jack_cycle_wait and @a jack_cycle_signal functions. 253 * The code in the supplied function must be suitable for real-time 254 * execution. That means that it cannot call functions that might 255 * block for a long time. This includes malloc, free, printf, 256 * pthread_mutex_lock, sleep, wait, poll, select, pthread_join, 257 * pthread_cond_wait, etc, etc. See 258 * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000 259 * for more information. 260 * 261 * NOTE: this function cannot be called while the client is activated 262 * (after jack_activate has been called.) 263 * 264 * @return 0 on success, otherwise a non-zero error code. 265 */ 266 int jack_set_process_thread(jack_client_t* client, JackThreadCallback thread_callback, void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 267 268 /*@}*/ 269 270 /** 271 * @defgroup ClientCallbacks Setting Client Callbacks 272 * @{ 273 */ 274 275 /** 276 * Tell JACK to call @a thread_init_callback once just after 277 * the creation of the thread in which all other callbacks 278 * will be handled. 279 * 280 * The code in the supplied function does not need to be 281 * suitable for real-time execution. 282 * 283 * NOTE: this function cannot be called while the client is activated 284 * (after jack_activate has been called.) 285 * 286 * @return 0 on success, otherwise a non-zero error code, causing JACK 287 * to remove that client from the process() graph. 288 */ 289 int jack_set_thread_init_callback (jack_client_t *client, 290 JackThreadInitCallback thread_init_callback, 291 void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 292 293 /** 294 * @param client pointer to JACK client structure. 295 * @param function The jack_shutdown function pointer. 296 * @param arg The arguments for the jack_shutdown function. 297 * 298 * Register a function (and argument) to be called if and when the 299 * JACK server shuts down the client thread. The function must 300 * be written as if it were an asynchonrous POSIX signal 301 * handler --- use only async-safe functions, and remember that it 302 * is executed from another thread. A typical function might 303 * set a flag or write to a pipe so that the rest of the 304 * application knows that the JACK client thread has shut 305 * down. 306 * 307 * NOTE: clients do not need to call this. It exists only 308 * to help more complex clients understand what is going 309 * on. It should be called before jack_client_activate(). 310 * 311 * NOTE: if a client calls this AND jack_on_info_shutdown(), then 312 * the event of a client thread shutdown, the callback 313 * passed to this function will not be called, and the one passed to 314 * jack_on_info_shutdown() will. 315 */ 316 void jack_on_shutdown (jack_client_t *client, 317 JackShutdownCallback shutdown_callback, void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 318 319 /** 320 * @param client pointer to JACK client structure. 321 * @param function The jack_info_shutdown function pointer. 322 * @param arg The arguments for the jack_info_shutdown function. 323 * 324 * Register a function (and argument) to be called if and when the 325 * JACK server shuts down the client thread. The function must 326 * be written as if it were an asynchonrous POSIX signal 327 * handler --- use only async-safe functions, and remember that it 328 * is executed from another thread. A typical function might 329 * set a flag or write to a pipe so that the rest of the 330 * application knows that the JACK client thread has shut 331 * down. 332 * 333 * NOTE: clients do not need to call this. It exists only 334 * to help more complex clients understand what is going 335 * on. It should be called before jack_client_activate(). 336 * 337 * NOTE: if a client calls this AND jack_on_info_shutdown(), then 338 * the event of a client thread shutdown, the callback 339 * passed to this function will not be called, and the one passed to 340 * jack_on_info_shutdown() will. 341 */ 342 void jack_on_info_shutdown (jack_client_t *client, 343 JackInfoShutdownCallback shutdown_callback, void *arg) /* JACK_WEAK_EXPORT */; 344 345 /** 346 * Tell the Jack server to call @a process_callback whenever there is 347 * work be done, passing @a arg as the second argument. 348 * 349 * The code in the supplied function must be suitable for real-time 350 * execution. That means that it cannot call functions that might 351 * block for a long time. This includes malloc, free, printf, 352 * pthread_mutex_lock, sleep, wait, poll, select, pthread_join, 353 * pthread_cond_wait, etc, etc. See 354 * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000 355 * for more information. 356 * 357 * NOTE: this function cannot be called while the client is activated 358 * (after jack_activate has been called.) 359 * 360 * @return 0 on success, otherwise a non-zero error code. 361 */ 362 int jack_set_process_callback (jack_client_t *client, 363 JackProcessCallback process_callback, 364 void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 365 366 /** 367 * Tell the Jack server to call @a freewheel_callback 368 * whenever we enter or leave "freewheel" mode, passing @a 369 * arg as the second argument. The first argument to the 370 * callback will be non-zero if JACK is entering freewheel 371 * mode, and zero otherwise. 372 * 373 * All "notification events" are received in a seperated non RT thread, 374 * the code in the supplied function does not need to be 375 * suitable for real-time execution. 376 * 377 * NOTE: this function cannot be called while the client is activated 378 * (after jack_activate has been called.) 379 * 380 * @return 0 on success, otherwise a non-zero error code. 381 */ 382 int jack_set_freewheel_callback (jack_client_t *client, 383 JackFreewheelCallback freewheel_callback, 384 void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 385 386 /** 387 * Tell JACK to call @a bufsize_callback whenever the size of the the 388 * buffer that will be passed to the @a process_callback is about to 389 * change. Clients that depend on knowing the buffer size must supply 390 * a @a bufsize_callback before activating themselves. 391 * 392 * All "notification events" are received in a seperated non RT thread, 393 * the code in the supplied function does not need to be 394 * suitable for real-time execution. 395 * 396 * NOTE: this function cannot be called while the client is activated 397 * (after jack_activate has been called.) 398 * 399 * @param client pointer to JACK client structure. 400 * @param bufsize_callback function to call when the buffer size changes. 401 * @param arg argument for @a bufsize_callback. 402 * 403 * @return 0 on success, otherwise a non-zero error code 404 */ 405 int jack_set_buffer_size_callback (jack_client_t *client, 406 JackBufferSizeCallback bufsize_callback, 407 void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 408 409 /** 410 * Tell the Jack server to call @a srate_callback whenever the system 411 * sample rate changes. 412 * 413 * All "notification events" are received in a seperated non RT thread, 414 * the code in the supplied function does not need to be 415 * suitable for real-time execution. 416 * 417 * NOTE: this function cannot be called while the client is activated 418 * (after jack_activate has been called.) 419 * 420 * @return 0 on success, otherwise a non-zero error code 421 */ 422 int jack_set_sample_rate_callback (jack_client_t *client, 423 JackSampleRateCallback srate_callback, 424 void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 425 426 /** 427 * Tell the JACK server to call @a client_registration_callback whenever a 428 * client is registered or unregistered, passing @a arg as a parameter. 429 * 430 * All "notification events" are received in a seperated non RT thread, 431 * the code in the supplied function does not need to be 432 * suitable for real-time execution. 433 * 434 * NOTE: this function cannot be called while the client is activated 435 * (after jack_activate has been called.) 436 * 437 * @return 0 on success, otherwise a non-zero error code 438 */ 439 int jack_set_client_registration_callback (jack_client_t *client, 440 JackClientRegistrationCallback 441 registration_callback, void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 442 443 /** 444 * Tell the JACK server to call @a registration_callback whenever a 445 * port is registered or unregistered, passing @a arg as a parameter. 446 * 447 * All "notification events" are received in a seperated non RT thread, 448 * the code in the supplied function does not need to be 449 * suitable for real-time execution. 450 * 451 * NOTE: this function cannot be called while the client is activated 452 * (after jack_activate has been called.) 453 * 454 * @return 0 on success, otherwise a non-zero error code 455 */ 456 int jack_set_port_registration_callback (jack_client_t *client, 457 JackPortRegistrationCallback 458 registration_callback, void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 459 460 /** 461 * Tell the JACK server to call @a connect_callback whenever a 462 * port is connected or disconnected, passing @a arg as a parameter. 463 * 464 * All "notification events" are received in a seperated non RT thread, 465 * the code in the supplied function does not need to be 466 * suitable for real-time execution. 467 * 468 * NOTE: this function cannot be called while the client is activated 469 * (after jack_activate has been called.) 470 * 471 * @return 0 on success, otherwise a non-zero error code 472 */ 473 int jack_set_port_connect_callback (jack_client_t *client, 474 JackPortConnectCallback 475 connect_callback, void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 476 477 /** 478 * Tell the JACK server to call @a rename_callback whenever a 479 * port is renamed, passing @a arg as a parameter. 480 * 481 * All "notification events" are received in a seperated non RT thread, 482 * the code in the supplied function does not need to be 483 * suitable for real-time execution. 484 * 485 * NOTE: this function cannot be called while the client is activated 486 * (after jack_activate has been called.) 487 * 488 * @return 0 on success, otherwise a non-zero error code 489 */ 490 int jack_set_port_rename_callback (jack_client_t *client, 491 JackPortRenameCallback 492 rename_callback, void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 493 494 /** 495 * Tell the JACK server to call @a graph_callback whenever the 496 * processing graph is reordered, passing @a arg as a parameter. 497 * 498 * All "notification events" are received in a seperated non RT thread, 499 * the code in the supplied function does not need to be 500 * suitable for real-time execution. 501 * 502 * NOTE: this function cannot be called while the client is activated 503 * (after jack_activate has been called.) 504 * 505 * @return 0 on success, otherwise a non-zero error code 506 */ 507 int jack_set_graph_order_callback (jack_client_t *client, 508 JackGraphOrderCallback graph_callback, 509 void *) /* JACK_OPTIONAL_WEAK_EXPORT */; 510 511 /** 512 * Tell the JACK server to call @a xrun_callback whenever there is a 513 * xrun, passing @a arg as a parameter. 514 * 515 * All "notification events" are received in a seperated non RT thread, 516 * the code in the supplied function does not need to be 517 * suitable for real-time execution. 518 * 519 * NOTE: this function cannot be called while the client is activated 520 * (after jack_activate has been called.) 521 * 522 * @return 0 on success, otherwise a non-zero error code 523 */ 524 int jack_set_xrun_callback (jack_client_t *client, 525 JackXRunCallback xrun_callback, void *arg) /* JACK_OPTIONAL_WEAK_EXPORT */; 526 527 /*@}*/ 528 529 /** 530 * Tell the Jack server to call @a latency_callback whenever it 531 * is necessary to recompute the latencies for some or all 532 * Jack ports. 533 * 534 * @a latency_callback will be called twice each time it is 535 * needed, once being passed JackCaptureLatency and once 536 * JackPlaybackLatency. See @ref LatencyFunctions for 537 * the definition of each type of latency and related functions. 538 * 539 * <b>IMPORTANT: Most JACK clients do NOT need to register a latency 540 * callback.</b> 541 * 542 * Clients that meet any of the following conditions do NOT 543 * need to register a latency callback: 544 * 545 * - have only input ports 546 * - have only output ports 547 * - their output is totally unrelated to their input 548 * - their output is not delayed relative to their input 549 * (i.e. data that arrives in a given process() 550 * callback is processed and output again in the 551 * same callback) 552 * 553 * Clients NOT registering a latency callback MUST also 554 * satisfy this condition: 555 * 556 * - have no multiple distinct internal signal pathways 557 * 558 * This means that if your client has more than 1 input and 559 * output port, and considers them always "correlated" 560 * (e.g. as a stereo pair), then there is only 1 (e.g. stereo) 561 * signal pathway through the client. This would be true, 562 * for example, of a stereo FX rack client that has a 563 * left/right input pair and a left/right output pair. 564 * 565 * However, this is somewhat a matter of perspective. The 566 * same FX rack client could be connected so that its 567 * two input ports were connected to entirely separate 568 * sources. Under these conditions, the fact that the client 569 * does not register a latency callback MAY result 570 * in port latency values being incorrect. 571 * 572 * Clients that do not meet any of those conditions SHOULD 573 * register a latency callback. 574 * 575 * See the documentation for @ref jack_port_set_latency_range() 576 * on how the callback should operate. Remember that the @a mode 577 * argument given to the latency callback will need to be 578 * passed into @ref jack_port_set_latency_range() 579 * 580 * @return 0 on success, otherwise a non-zero error code 581 */ 582 int jack_set_latency_callback (jack_client_t *client, 583 JackLatencyCallback latency_callback, 584 void *) /* JACK_WEAK_EXPORT */; 585 /*@}*/ 586 587 /** 588 * @defgroup ServerClientControl Controlling & querying JACK server operation 589 * @{ 590 */ 591 592 /** 593 * Start/Stop JACK's "freewheel" mode. 594 * 595 * When in "freewheel" mode, JACK no longer waits for 596 * any external event to begin the start of the next process 597 * cycle. 598 * 599 * As a result, freewheel mode causes "faster than realtime" 600 * execution of a JACK graph. If possessed, real-time 601 * scheduling is dropped when entering freewheel mode, and 602 * if appropriate it is reacquired when stopping. 603 * 604 * IMPORTANT: on systems using capabilities to provide real-time 605 * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function 606 * must be called from the thread that originally called jack_activate(). 607 * This restriction does not apply to other systems (e.g. Linux kernel 2.6 608 * or OS X). 609 * 610 * @param client pointer to JACK client structure 611 * @param onoff if non-zero, freewheel mode starts. Otherwise 612 * freewheel mode ends. 613 * 614 * @return 0 on success, otherwise a non-zero error code. 615 */ 616 int jack_set_freewheel(jack_client_t* client, int onoff) /* JACK_OPTIONAL_WEAK_EXPORT */; 617 618 /** 619 * Change the buffer size passed to the @a process_callback. 620 * 621 * This operation stops the JACK engine process cycle, then calls all 622 * registered @a bufsize_callback functions before restarting the 623 * process cycle. This will cause a gap in the audio flow, so it 624 * should only be done at appropriate stopping points. 625 * 626 * @see jack_set_buffer_size_callback() 627 * 628 * @param client pointer to JACK client structure. 629 * @param nframes new buffer size. Must be a power of two. 630 * 631 * @return 0 on success, otherwise a non-zero error code 632 */ 633 int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes) /* JACK_OPTIONAL_WEAK_EXPORT */; 634 635 /** 636 * @return the sample rate of the jack system, as set by the user when 637 * jackd was started. 638 */ 639 jack_nframes_t jack_get_sample_rate (jack_client_t *) /* JACK_OPTIONAL_WEAK_EXPORT */; 640 641 /** 642 * @return the current maximum size that will ever be passed to the @a 643 * process_callback. It should only be used *before* the client has 644 * been activated. This size may change, clients that depend on it 645 * must register a @a bufsize_callback so they will be notified if it 646 * does. 647 * 648 * @see jack_set_buffer_size_callback() 649 */ 650 jack_nframes_t jack_get_buffer_size (jack_client_t *) /* JACK_OPTIONAL_WEAK_EXPORT */; 651 652 /** 653 * Old-style interface to become the timebase for the entire JACK 654 * subsystem. 655 * 656 * @deprecated This function still exists for compatibility with the 657 * earlier transport interface, but it does nothing. Instead, see 658 * transport.h and use jack_set_timebase_callback(). 659 * 660 * @return ENOSYS, function not implemented. 661 */ 662 deprecated 663 int jack_engine_takeover_timebase (jack_client_t *) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 664 665 /** 666 * @return the current CPU load estimated by JACK. This is a running 667 * average of the time it takes to execute a full process cycle for 668 * all clients as a percentage of the real time available per cycle 669 * determined by the buffer size and sample rate. 670 */ 671 float jack_cpu_load (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 672 673 /*@}*/ 674 675 /** 676 * @defgroup PortFunctions Creating & manipulating ports 677 * @{ 678 */ 679 680 /** 681 * Create a new port for the client. This is an object used for moving 682 * data of any type in or out of the client. Ports may be connected 683 * in various ways. 684 * 685 * Each port has a short name. The port's full name contains the name 686 * of the client concatenated with a colon (:) followed by its short 687 * name. The jack_port_name_size() is the maximum length of this full 688 * name. Exceeding that will cause the port registration to fail and 689 * return NULL. 690 * 691 * The @a port_name must be unique among all ports owned by this client. 692 * If the name is not unique, the registration will fail. 693 * 694 * All ports have a type, which may be any non-NULL and non-zero 695 * length string, passed as an argument. Some port types are built 696 * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE. 697 * 698 * @param client pointer to JACK client structure. 699 * @param port_name non-empty short name for the new port (not 700 * including the leading @a "client_name:"). Must be unique. 701 * @param port_type port type name. If longer than 702 * jack_port_type_size(), only that many characters are significant. 703 * @param flags @ref JackPortFlags bit mask. 704 * @param buffer_size must be non-zero if this is not a built-in @a 705 * port_type. Otherwise, it is ignored. 706 * 707 * @return jack_port_t pointer on success, otherwise NULL. 708 */ 709 jack_port_t * jack_port_register (jack_client_t *client, 710 const(char) *port_name, 711 const(char) *port_type, 712 c_ulong flags, 713 c_ulong buffer_size) /* JACK_OPTIONAL_WEAK_EXPORT */; 714 715 /** 716 * Remove the port from the client, disconnecting any existing 717 * connections. 718 * 719 * @return 0 on success, otherwise a non-zero error code 720 */ 721 int jack_port_unregister (jack_client_t *client, jack_port_t *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 722 723 /** 724 * This returns a pointer to the memory area associated with the 725 * specified port. For an output port, it will be a memory area 726 * that can be written to; for an input port, it will be an area 727 * containing the data from the port's connection(s), or 728 * zero-filled. if there are multiple inbound connections, the data 729 * will be mixed appropriately. 730 * 731 * FOR OUTPUT PORTS ONLY : DEPRECATED in Jack 2.0 !! 732 * --------------------------------------------------- 733 * You may cache the value returned, but only between calls to 734 * your "blocksize" callback. For this reason alone, you should 735 * either never cache the return value or ensure you have 736 * a "blocksize" callback and be sure to invalidate the cached 737 * address from there. 738 * 739 * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining"). 740 * Port buffers have to be retrieved in each callback for proper functionning. 741 */ 742 // deprecated 743 void * jack_port_get_buffer (jack_port_t *port, jack_nframes_t) /* JACK_OPTIONAL_WEAK_EXPORT */; 744 745 /** 746 * @return the full name of the jack_port_t (including the @a 747 * "client_name:" prefix). 748 * 749 * @see jack_port_name_size(). 750 */ 751 const(char) * jack_port_name (const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 752 753 /** 754 * @return the short name of the jack_port_t (not including the @a 755 * "client_name:" prefix). 756 * 757 * @see jack_port_name_size(). 758 */ 759 const(char) * jack_port_short_name (const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 760 761 /** 762 * @return the @ref JackPortFlags of the jack_port_t. 763 */ 764 int jack_port_flags (const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 765 766 /** 767 * @return the @a port type, at most jack_port_type_size() characters 768 * including a final NULL. 769 */ 770 const(char) * jack_port_type (const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 771 772 /** 773 * @return the @a port type id. 774 */ 775 jack_port_type_id_t jack_port_type_id (const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 776 777 /** 778 * @return TRUE if the jack_port_t belongs to the jack_client_t. 779 */ 780 int jack_port_is_mine (const(jack_client_t) *client, const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 781 782 /** 783 * @return number of connections to or from @a port. 784 * 785 * @pre The calling client must own @a port. 786 */ 787 int jack_port_connected (const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 788 789 /** 790 * @return TRUE if the locally-owned @a port is @b directly connected 791 * to the @a port_name. 792 * 793 * @see jack_port_name_size() 794 */ 795 int jack_port_connected_to (const(jack_port_t) *port, 796 const(char) *port_name) /* JACK_OPTIONAL_WEAK_EXPORT */; 797 798 /** 799 * @return a null-terminated array of full port names to which the @a 800 * port is connected. If none, returns NULL. 801 * 802 * The caller is responsible for calling jack_free() on any non-NULL 803 * returned value. 804 * 805 * @param port locally owned jack_port_t pointer. 806 * 807 * @see jack_port_name_size(), jack_port_get_all_connections() 808 */ 809 const(char) ** jack_port_get_connections (const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 810 811 /** 812 * @return a null-terminated array of full port names to which the @a 813 * port is connected. If none, returns NULL. 814 * 815 * The caller is responsible for calling jack_free() on any non-NULL 816 * returned value. 817 * 818 * This differs from jack_port_get_connections() in two important 819 * respects: 820 * 821 * 1) You may not call this function from code that is 822 * executed in response to a JACK event. For example, 823 * you cannot use it in a GraphReordered handler. 824 * 825 * 2) You need not be the owner of the port to get information 826 * about its connections. 827 * 828 * @see jack_port_name_size() 829 */ 830 const(char) ** jack_port_get_all_connections (const(jack_client_t) *client, 831 const(jack_port_t) *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 832 833 /** 834 * 835 * @deprecated This function will be removed from a future version 836 * of JACK. Do not use it. There is no replacement. It has 837 * turned out to serve essentially no purpose in real-life 838 * JACK clients. 839 */ 840 deprecated 841 int jack_port_tie (jack_port_t *src, jack_port_t *dst) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 842 843 /** 844 * 845 * @deprecated This function will be removed from a future version 846 * of JACK. Do not use it. There is no replacement. It has 847 * turned out to serve essentially no purpose in real-life 848 * JACK clients. 849 */ 850 deprecated 851 int jack_port_untie (jack_port_t *port) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 852 853 /** 854 * Modify a port's short name. May be called at any time. If the 855 * resulting full name (including the @a "client_name:" prefix) is 856 * longer than jack_port_name_size(), it will be truncated. 857 * 858 * @return 0 on success, otherwise a non-zero error code. 859 */ 860 int jack_port_set_name (jack_port_t *port, const(char) *port_name) /* JACK_OPTIONAL_WEAK_EXPORT */; 861 862 /** 863 * Set @a alias as an alias for @a port. May be called at any time. 864 * If the alias is longer than jack_port_name_size(), it will be truncated. 865 * 866 * After a successful call, and until JACK exits or 867 * @function jack_port_unset_alias() is called, @alias may be 868 * used as a alternate name for the port. 869 * 870 * Ports can have up to two aliases - if both are already 871 * set, this function will return an error. 872 * 873 * @return 0 on success, otherwise a non-zero error code. 874 */ 875 int jack_port_set_alias (jack_port_t *port, const(char) *alia) /* JACK_OPTIONAL_WEAK_EXPORT */; 876 877 /** 878 * Remove @a alias as an alias for @a port. May be called at any time. 879 * 880 * After a successful call, @a alias can no longer be 881 * used as a alternate name for the port. 882 * 883 * @return 0 on success, otherwise a non-zero error code. 884 */ 885 int jack_port_unset_alias (jack_port_t *port, const(char) *alia) /* JACK_OPTIONAL_WEAK_EXPORT */; 886 887 /** 888 * Get any aliases known for @port. 889 * 890 * @return the number of aliases discovered for the port 891 */ 892 int jack_port_get_aliases (const(jack_port_t) *port, const(char*) *aliases/*[2]*/) /* JACK_OPTIONAL_WEAK_EXPORT */; 893 894 /** 895 * If @ref JackPortCanMonitor is set for this @a port, turn input 896 * monitoring on or off. Otherwise, do nothing. 897 */ 898 int jack_port_request_monitor (jack_port_t *port, int onoff) /* JACK_OPTIONAL_WEAK_EXPORT */; 899 900 /** 901 * If @ref JackPortCanMonitor is set for this @a port_name, turn input 902 * monitoring on or off. Otherwise, do nothing. 903 * 904 * @return 0 on success, otherwise a non-zero error code. 905 * 906 * @see jack_port_name_size() 907 */ 908 int jack_port_request_monitor_by_name (jack_client_t *client, 909 const(char) *port_name, int onoff) /* JACK_OPTIONAL_WEAK_EXPORT */; 910 911 /** 912 * If @ref JackPortCanMonitor is set for a port, this function turns 913 * on input monitoring if it was off, and turns it off if only one 914 * request has been made to turn it on. Otherwise it does nothing. 915 * 916 * @return 0 on success, otherwise a non-zero error code 917 */ 918 int jack_port_ensure_monitor (jack_port_t *port, int onoff) /* JACK_OPTIONAL_WEAK_EXPORT */; 919 920 /** 921 * @return TRUE if input monitoring has been requested for @a port. 922 */ 923 int jack_port_monitoring_input (jack_port_t *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 924 925 /** 926 * Establish a connection between two ports. 927 * 928 * When a connection exists, data written to the source port will 929 * be available to be read at the destination port. 930 * 931 * @pre The port types must be identical. 932 * 933 * @pre The @ref JackPortFlags of the @a source_port must include @ref 934 * JackPortIsOutput. 935 * 936 * @pre The @ref JackPortFlags of the @a destination_port must include 937 * @ref JackPortIsInput. 938 * 939 * @return 0 on success, EEXIST if the connection is already made, 940 * otherwise a non-zero error code 941 */ 942 int jack_connect (jack_client_t *client, 943 const(char) *source_port, 944 const(char) *destination_port) /* JACK_OPTIONAL_WEAK_EXPORT */; 945 946 /** 947 * Remove a connection between two ports. 948 * 949 * @pre The port types must be identical. 950 * 951 * @pre The @ref JackPortFlags of the @a source_port must include @ref 952 * JackPortIsOutput. 953 * 954 * @pre The @ref JackPortFlags of the @a destination_port must include 955 * @ref JackPortIsInput. 956 * 957 * @return 0 on success, otherwise a non-zero error code 958 */ 959 int jack_disconnect (jack_client_t *client, 960 const(char) *source_port, 961 const(char) *destination_port) /* JACK_OPTIONAL_WEAK_EXPORT */; 962 963 /** 964 * Perform the same function as jack_disconnect() using port handles 965 * rather than names. This avoids the name lookup inherent in the 966 * name-based version. 967 * 968 * Clients connecting their own ports are likely to use this function, 969 * while generic connection clients (e.g. patchbays) would use 970 * jack_disconnect(). 971 */ 972 int jack_port_disconnect (jack_client_t *client, jack_port_t *port) /* JACK_OPTIONAL_WEAK_EXPORT */; 973 974 /** 975 * @return the maximum number of characters in a full JACK port name 976 * including the final NULL character. This value is a constant. 977 * 978 * A port's full name contains the owning client name concatenated 979 * with a colon (:) followed by its short name and a NULL 980 * character. 981 */ 982 int jack_port_name_size() /* JACK_OPTIONAL_WEAK_EXPORT */; 983 984 /** 985 * @return the maximum number of characters in a JACK port type name 986 * including the final NULL character. This value is a constant. 987 */ 988 int jack_port_type_size() /* JACK_OPTIONAL_WEAK_EXPORT */; 989 990 /** 991 * @return the buffersize of a port of type @arg port_type. 992 * 993 * this function may only be called in a buffer_size callback. 994 */ 995 size_t jack_port_type_get_buffer_size (jack_client_t *client, const(char) *port_type) /* JACK_WEAK_EXPORT */; 996 997 /*@}*/ 998 999 /** 1000 * @defgroup LatencyFunctions Managing and determining latency 1001 * 1002 * The purpose of JACK's latency API is to allow clients to 1003 * easily answer two questions: 1004 * 1005 * - How long has it been since the data read from a port arrived 1006 * at the edge of the JACK graph (either via a physical port 1007 * or being synthesized from scratch)? 1008 * 1009 * - How long will it be before the data written to a port arrives 1010 * at the edge of a JACK graph? 1011 1012 * To help answering these two questions, all JACK ports have two 1013 * latency values associated with them, both measured in frames: 1014 * 1015 * <b>capture latency</b>: how long since the data read from 1016 * the buffer of a port arrived at at 1017 * a port marked with JackPortIsTerminal. 1018 * The data will have come from the "outside 1019 * world" if the terminal port is also 1020 * marked with JackPortIsPhysical, or 1021 * will have been synthesized by the client 1022 * that owns the terminal port. 1023 * 1024 * <b>playback latency</b>: how long until the data 1025 * written to the buffer of port will reach a port 1026 * marked with JackPortIsTerminal. 1027 * 1028 * Both latencies might potentially have more than one value 1029 * because there may be multiple pathways to/from a given port 1030 * and a terminal port. Latency is therefore generally 1031 * expressed a min/max pair. 1032 * 1033 * In most common setups, the minimum and maximum latency 1034 * are the same, but this design accomodates more complex 1035 * routing, and allows applications (and thus users) to 1036 * detect cases where routing is creating an anomalous 1037 * situation that may either need fixing or more 1038 * sophisticated handling by clients that care about 1039 * latency. 1040 * 1041 * See also @ref jack_set_latency_callback for details on how 1042 * clients that add latency to the signal path should interact 1043 * with JACK to ensure that the correct latency figures are 1044 * used. 1045 * @{ 1046 */ 1047 1048 /** 1049 * The port latency is zero by default. Clients that control 1050 * physical hardware with non-zero latency should call this 1051 * to set the latency to its correct value. Note that the value 1052 * should include any systemic latency present "outside" the 1053 * physical hardware controlled by the client. For example, 1054 * for a client controlling a digital audio interface connected 1055 * to an external digital converter, the latency setting should 1056 * include both buffering by the audio interface *and* the converter. 1057 * 1058 * @deprecated This method will be removed in the next major 1059 * release of JACK. It should not be used in new code, and should 1060 * be replaced by a latency callback that calls @ref 1061 * jack_port_set_latency_range(). 1062 */ 1063 deprecated 1064 void jack_port_set_latency (jack_port_t *port, jack_nframes_t) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 1065 1066 /** 1067 * return the latency range defined by @a mode for 1068 * @a port, in frames. 1069 * 1070 * See @ref LatencyFunctions for the definition of each latency value. 1071 * 1072 * This is normally used in the LatencyCallback. 1073 * and therefor safe to execute from callbacks. 1074 */ 1075 void jack_port_get_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) /* JACK_WEAK_EXPORT */; 1076 1077 /** 1078 * set the minimum and maximum latencies defined by 1079 * @a mode for @a port, in frames. 1080 * 1081 * See @ref LatencyFunctions for the definition of each latency value. 1082 * 1083 * This function should ONLY be used inside a latency 1084 * callback. The client should determine the current 1085 * value of the latency using @ref jack_port_get_latency_range() 1086 * (called using the same mode as @a mode) 1087 * and then add some number of frames to that reflects 1088 * latency added by the client. 1089 * 1090 * How much latency a client adds will vary 1091 * dramatically. For most clients, the answer is zero 1092 * and there is no reason for them to register a latency 1093 * callback and thus they should never call this 1094 * function. 1095 * 1096 * More complex clients that take an input signal, 1097 * transform it in some way and output the result but 1098 * not during the same process() callback will 1099 * generally know a single constant value to add 1100 * to the value returned by @ref jack_port_get_latency_range(). 1101 * 1102 * Such clients would register a latency callback (see 1103 * @ref jack_set_latency_callback) and must know what input 1104 * ports feed which output ports as part of their 1105 * internal state. Their latency callback will update 1106 * the ports' latency values appropriately. 1107 * 1108 * A pseudo-code example will help. The @a mode argument to the latency 1109 * callback will determine whether playback or capture 1110 * latency is being set. The callback will use 1111 * @ref jack_port_set_latency_range() as follows: 1112 * 1113 * \code 1114 * jack_latency_range_t range; 1115 * if (mode == JackPlaybackLatency) { 1116 * foreach input_port in (all self-registered port) { 1117 * jack_port_get_latency_range (port_feeding_input_port, JackPlaybackLatency, &range); 1118 * range.min += min_delay_added_as_signal_flows_from port_feeding to input_port; 1119 * range.max += max_delay_added_as_signal_flows_from port_feeding to input_port; 1120 * jack_port_set_latency_range (input_port, JackPlaybackLatency, &range); 1121 * } 1122 * } else if (mode == JackCaptureLatency) { 1123 * foreach output_port in (all self-registered port) { 1124 * jack_port_get_latency_range (port_fed_by_output_port, JackCaptureLatency, &range); 1125 * range.min += min_delay_added_as_signal_flows_from_output_port_to_fed_by_port; 1126 * range.max += max_delay_added_as_signal_flows_from_output_port_to_fed_by_port; 1127 * jack_port_set_latency_range (output_port, JackCaptureLatency, &range); 1128 * } 1129 * } 1130 * \endcode 1131 * 1132 * In this relatively simple pseudo-code example, it is assumed that 1133 * each input port or output is connected to only 1 output or input 1134 * port respectively. 1135 * 1136 * If a port is connected to more than 1 other port, then the 1137 * range.min and range.max values passed to @ref 1138 * jack_port_set_latency_range() should reflect the minimum and 1139 * maximum values across all connected ports. 1140 * 1141 * See the description of @ref jack_set_latency_callback for more 1142 * information. 1143 */ 1144 void jack_port_set_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) /* JACK_WEAK_EXPORT */; 1145 1146 /** 1147 * Request a complete recomputation of all port latencies. This 1148 * can be called by a client that has just changed the internal 1149 * latency of its port using jack_port_set_latency 1150 * and wants to ensure that all signal pathways in the graph 1151 * are updated with respect to the values that will be returned 1152 * by jack_port_get_total_latency. It allows a client 1153 * to change multiple port latencies without triggering a 1154 * recompute for each change. 1155 * 1156 * @return zero for successful execution of the request. non-zero 1157 * otherwise. 1158 */ 1159 int jack_recompute_total_latencies (jack_client_t *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 1160 1161 /** 1162 * @return the time (in frames) between data being available or 1163 * delivered at/to a port, and the time at which it arrived at or is 1164 * delivered to the "other side" of the port. E.g. for a physical 1165 * audio output port, this is the time between writing to the port and 1166 * when the signal will leave the connector. For a physical audio 1167 * input port, this is the time between the sound arriving at the 1168 * connector and the corresponding frames being readable from the 1169 * port. 1170 * 1171 * @deprecated This method will be removed in the next major 1172 * release of JACK. It should not be used in new code, and should 1173 * be replaced by jack_port_get_latency_range() in any existing 1174 * use cases. 1175 */ 1176 deprecated 1177 jack_nframes_t jack_port_get_latency (jack_port_t *port) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 1178 1179 /** 1180 * The maximum of the sum of the latencies in every 1181 * connection path that can be drawn between the port and other 1182 * ports with the @ref JackPortIsTerminal flag set. 1183 * 1184 * @deprecated This method will be removed in the next major 1185 * release of JACK. It should not be used in new code, and should 1186 * be replaced by jack_port_get_latency_range() in any existing 1187 * use cases. 1188 */ 1189 deprecated 1190 jack_nframes_t jack_port_get_total_latency (jack_client_t *client, 1191 jack_port_t *port) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 1192 1193 /** 1194 * Request a complete recomputation of a port's total latency. This 1195 * can be called by a client that has just changed the internal 1196 * latency of its port using jack_port_set_latency 1197 * and wants to ensure that all signal pathways in the graph 1198 * are updated with respect to the values that will be returned 1199 * by jack_port_get_total_latency. 1200 * 1201 * @return zero for successful execution of the request. non-zero 1202 * otherwise. 1203 * 1204 * @deprecated This method will be removed in the next major 1205 * release of JACK. It should not be used in new code, and should 1206 * be replaced by jack_recompute_total_latencies() in any existing 1207 * use cases. 1208 */ 1209 deprecated 1210 int jack_recompute_total_latency (jack_client_t*, jack_port_t* port) /* JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT */; 1211 1212 /*@}*/ 1213 1214 /** 1215 * @defgroup PortSearching Looking up ports 1216 * @{ 1217 */ 1218 1219 /** 1220 * @param port_name_pattern A regular expression used to select 1221 * ports by name. If NULL or of zero length, no selection based 1222 * on name will be carried out. 1223 * @param type_name_pattern A regular expression used to select 1224 * ports by type. If NULL or of zero length, no selection based 1225 * on type will be carried out. 1226 * @param flags A value used to select ports by their flags. 1227 * If zero, no selection based on flags will be carried out. 1228 * 1229 * @return a NULL-terminated array of ports that match the specified 1230 * arguments. The caller is responsible for calling jack_free() any 1231 * non-NULL returned value. 1232 * 1233 * @see jack_port_name_size(), jack_port_type_size() 1234 */ 1235 const(char) ** jack_get_ports (jack_client_t *client, 1236 const(char) *port_name_pattern, 1237 const(char) *type_name_pattern, 1238 c_ulong flags) /* JACK_OPTIONAL_WEAK_EXPORT */; 1239 1240 /** 1241 * @return address of the jack_port_t named @a port_name. 1242 * 1243 * @see jack_port_name_size() 1244 */ 1245 jack_port_t * jack_port_by_name (jack_client_t *client, const(char) *port_name) /* JACK_OPTIONAL_WEAK_EXPORT */; 1246 1247 /** 1248 * @return address of the jack_port_t of a @a port_id. 1249 */ 1250 jack_port_t * jack_port_by_id (jack_client_t *client, 1251 jack_port_id_t port_id) /* JACK_OPTIONAL_WEAK_EXPORT */; 1252 1253 /*@}*/ 1254 1255 /** 1256 * @defgroup TimeFunctions Handling time 1257 * @{ 1258 * 1259 * JACK time is in units of 'frames', according to the current sample rate. 1260 * The absolute value of frame times is meaningless, frame times have meaning 1261 * only relative to each other. 1262 */ 1263 1264 /** 1265 * @return the estimated time in frames that has passed since the JACK 1266 * server began the current process cycle. 1267 */ 1268 jack_nframes_t jack_frames_since_cycle_start (const(jack_client_t) *) /* JACK_OPTIONAL_WEAK_EXPORT */; 1269 1270 /** 1271 * @return the estimated current time in frames. 1272 * This function is intended for use in other threads (not the process 1273 * callback). The return value can be compared with the value of 1274 * jack_last_frame_time to relate time in other threads to JACK time. 1275 */ 1276 jack_nframes_t jack_frame_time (const(jack_client_t) *) /* JACK_OPTIONAL_WEAK_EXPORT */; 1277 1278 /** 1279 * @return the precise time at the start of the current process cycle. 1280 * This function may only be used from the process callback, and can 1281 * be used to interpret timestamps generated by jack_frame_time() in 1282 * other threads with respect to the current process cycle. 1283 * 1284 * This is the only jack time function that returns exact time: 1285 * when used during the process callback it always returns the same 1286 * value (until the next process callback, where it will return 1287 * that value + nframes, etc). The return value is guaranteed to be 1288 * monotonic and linear in this fashion unless an xrun occurs. 1289 * If an xrun occurs, clients must check this value again, as time 1290 * may have advanced in a non-linear way (e.g. cycles may have been skipped). 1291 */ 1292 jack_nframes_t jack_last_frame_time (const(jack_client_t) *client) /* JACK_OPTIONAL_WEAK_EXPORT */; 1293 1294 /** 1295 * This function may only be used from the process callback. 1296 * It provides the internal cycle timing information as used by 1297 * most of the other time related functions. This allows the 1298 * caller to map between frame counts and microseconds with full 1299 * precision (i.e. without rounding frame times to integers), 1300 * and also provides e.g. the microseconds time of the start of 1301 * the current cycle directly (it has to be computed otherwise). 1302 * 1303 * If the return value is zero, the following information is 1304 * provided in the variables pointed to by the arguments: 1305 * 1306 * current_frames: the frame time counter at the start of the 1307 * current cycle, same as jack_last_frame_time(). 1308 * current_usecs: the microseconds time at the start of the 1309 * current cycle. 1310 * next_usecs: the microseconds time of the start of the next 1311 * next cycle as computed by the DLL. 1312 * period_usecs: the current best estimate of the period time in 1313 * microseconds. 1314 * 1315 * NOTES: 1316 * 1317 * Because of the types used, all the returned values except period_usecs 1318 * are unsigned. In computations mapping between frames and microseconds 1319 * *signed* differences are required. The easiest way is to compute those 1320 * separately and assign them to the appropriate signed variables, 1321 * int32_t for frames and int64_t for usecs. See the implementation of 1322 * jack_frames_to_time() and Jack_time_to_frames() for an example. 1323 * 1324 * Unless there was an xrun, skipped cycles, or the current cycle is the 1325 * first after freewheeling or starting Jack, the value of current_usecs 1326 * will always be the value of next_usecs of the previous cycle. 1327 * 1328 * The value of period_usecs will in general NOT be exactly equal to 1329 * the difference of next_usecs and current_usecs. This is because to 1330 * ensure stability of the DLL and continuity of the mapping, a fraction 1331 * of the loop error must be included in next_usecs. For an accurate 1332 * mapping between frames and microseconds, the difference of next_usecs 1333 * and current_usecs should be used, and not period_usecs. 1334 * 1335 * @return zero if OK, non-zero otherwise. 1336 */ 1337 int jack_get_cycle_times(const(jack_client_t) *client, 1338 jack_nframes_t *current_frames, 1339 jack_time_t *current_usecs, 1340 jack_time_t *next_usecs, 1341 float *period_usecs) /* JACK_OPTIONAL_WEAK_EXPORT */; 1342 1343 /** 1344 * @return the estimated time in microseconds of the specified frame time 1345 */ 1346 jack_time_t jack_frames_to_time(const(jack_client_t) *client, jack_nframes_t) /* JACK_OPTIONAL_WEAK_EXPORT */; 1347 1348 /** 1349 * @return the estimated time in frames for the specified system time. 1350 */ 1351 jack_nframes_t jack_time_to_frames(const(jack_client_t) *client, jack_time_t) /* JACK_OPTIONAL_WEAK_EXPORT */; 1352 1353 /** 1354 * @return return JACK's current system time in microseconds, 1355 * using the JACK clock source. 1356 * 1357 * The value returned is guaranteed to be monotonic, but not linear. 1358 */ 1359 jack_time_t jack_get_time() /* JACK_OPTIONAL_WEAK_EXPORT */; 1360 1361 /*@}*/ 1362 1363 /** 1364 * @defgroup ErrorOutput Controlling error/information output 1365 */ 1366 /*@{*/ 1367 1368 /** 1369 * Display JACK error message. 1370 * 1371 * Set via jack_set_error_function(), otherwise a JACK-provided 1372 * default will print @a msg (plus a newline) to stderr. 1373 * 1374 * @param msg error message text (no newline at end). 1375 */ 1376 extern void function(const(char) *msg) jack_error_callback /* JACK_OPTIONAL_WEAK_EXPORT */; 1377 1378 /** 1379 * Set the @ref jack_error_callback for error message display. 1380 * Set it to NULL to restore default_jack_error_callback function. 1381 * 1382 * The JACK library provides two built-in callbacks for this purpose: 1383 * default_jack_error_callback() and silent_jack_error_callback(). 1384 */ 1385 void jack_set_error_function (void function(const(char) *)) /* JACK_OPTIONAL_WEAK_EXPORT */; 1386 1387 /** 1388 * Display JACK info message. 1389 * 1390 * Set via jack_set_info_function(), otherwise a JACK-provided 1391 * default will print @a msg (plus a newline) to stdout. 1392 * 1393 * @param msg info message text (no newline at end). 1394 */ 1395 extern void function(const(char) *msg) jack_info_callback /* JACK_OPTIONAL_WEAK_EXPORT */; 1396 1397 /** 1398 * Set the @ref jack_info_callback for info message display. 1399 * Set it to NULL to restore default_jack_info_callback function. 1400 * 1401 * The JACK library provides two built-in callbacks for this purpose: 1402 * default_jack_info_callback() and silent_jack_info_callback(). 1403 */ 1404 void jack_set_info_function (void function(const(char) *)) /* JACK_OPTIONAL_WEAK_EXPORT */; 1405 1406 /*@}*/ 1407 1408 /** 1409 * The free function to be used on memory returned by jack_port_get_connections, 1410 * jack_port_get_all_connections, jack_get_ports and jack_get_internal_client_name functions. 1411 * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur. 1412 * Developers are strongly encouraged to use this function instead of the standard "free" function in new code. 1413 * 1414 */ 1415 void jack_free(void* ptr) /* JACK_OPTIONAL_WEAK_EXPORT */; 1416 1417 1418 }