jack.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2001 Paul Davis
00003     Copyright (C) 2004 Jack O'Quin
00004     
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU Lesser General Public License as published by
00007     the Free Software Foundation; either version 2.1 of the License, or
00008     (at your option) any later version.
00009     
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU Lesser General Public License for more details.
00014     
00015     You should have received a copy of the GNU Lesser General Public License
00016     along with this program; if not, write to the Free Software 
00017     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 
00019 */
00020 
00021 #ifndef __jack_h__
00022 #define __jack_h__
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 #include <pthread.h>
00029 
00030 #include <jack/types.h>
00031 #include <jack/transport.h>
00032 
00038 /*************************************************************
00039  * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function
00040  * added to the JACK API after the 0.116.2 release.
00041  *************************************************************/
00042 
00043 #ifndef JACK_WEAK_EXPORT
00044 #ifdef __GNUC__
00045 /* JACK_WEAK_EXPORT needs to be a macro which
00046    expands into a compiler directive. If non-null, the directive 
00047    must tell the compiler to arrange for weak linkage of 
00048    the symbol it used with. For this to work full may
00049    require linker arguments in the client as well.
00050 */
00051 #define JACK_WEAK_EXPORT __attribute__((weak))
00052 #else
00053 /* Add other things here for non-gcc platforms */
00054 #endif
00055 #endif
00056 
00057 
00096 jack_client_t *jack_client_open (const char *client_name,
00097                                  jack_options_t options,
00098                                  jack_status_t *status, ...);
00099 
00105 jack_client_t *jack_client_new (const char *client_name);
00106 
00112 int jack_client_close (jack_client_t *client);
00113 
00118 int jack_client_name_size (void);
00119 
00126 char *jack_get_client_name (jack_client_t *client);
00127 
00149 int jack_internal_client_new (const char *client_name,
00150                               const char *load_name,
00151                               const char *load_init);
00152 
00158 void jack_internal_client_close (const char *client_name);
00159 
00166 int jack_activate (jack_client_t *client);
00167 
00175 int jack_deactivate (jack_client_t *client);
00176 
00181 pthread_t jack_client_thread_id (jack_client_t *);
00182 
00192 int jack_is_realtime (jack_client_t *client);
00193 
00206 jack_nframes_t jack_thread_wait (jack_client_t*, int status);
00207 
00215 jack_nframes_t jack_cycle_wait (jack_client_t* client);
00216         
00223 void jack_cycle_signal (jack_client_t* client, int status);
00224         
00236 int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg);
00237 
00256 int jack_set_thread_init_callback (jack_client_t *client,
00257                                    JackThreadInitCallback thread_init_callback,
00258                                    void *arg);
00259 
00283 void jack_on_shutdown (jack_client_t *client,
00284                        JackShutdownCallback function, void *arg);
00285 
00309 void jack_on_info_shutdown (jack_client_t *client,
00310                             JackInfoShutdownCallback function, void *arg) JACK_WEAK_EXPORT;
00311 
00325 int jack_set_process_callback (jack_client_t *client,
00326                                JackProcessCallback process_callback,
00327                                void *arg);
00328 
00338 int jack_set_freewheel_callback (jack_client_t *client,
00339                                  JackFreewheelCallback freewheel_callback,
00340                                  void *arg);
00341 
00354 int jack_set_buffer_size_callback (jack_client_t *client,
00355                                    JackBufferSizeCallback bufsize_callback,
00356                                    void *arg);
00357 
00364 int jack_set_sample_rate_callback (jack_client_t *client,
00365                                    JackSampleRateCallback srate_callback,
00366                                    void *arg);
00367 
00374 int jack_set_client_registration_callback (jack_client_t *,
00375                                            JackClientRegistrationCallback
00376                                            registration_callback, void *arg);
00377         
00384 int jack_set_port_registration_callback (jack_client_t *,
00385                                          JackPortRegistrationCallback
00386                                          registration_callback, void *arg);
00387 
00394 int jack_set_port_connect_callback (jack_client_t *,
00395                                     JackPortConnectCallback
00396                                     connect_callback, void *arg);
00403 int jack_set_graph_order_callback (jack_client_t *,
00404                                    JackGraphOrderCallback graph_callback,
00405                                    void *);
00406 
00413 int jack_set_xrun_callback (jack_client_t *,
00414                             JackXRunCallback xrun_callback, void *arg);
00415 
00447 int jack_set_freewheel(jack_client_t* client, int onoff);
00448 
00464 int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
00465 
00470 jack_nframes_t jack_get_sample_rate (jack_client_t *);
00471 
00481 jack_nframes_t jack_get_buffer_size (jack_client_t *);
00482 
00493 int  jack_engine_takeover_timebase (jack_client_t *);
00494 
00501 float jack_cpu_load (jack_client_t *client);
00502         
00503 
00537 jack_port_t *jack_port_register (jack_client_t *client,
00538                                  const char *port_name,
00539                                  const char *port_type,
00540                                  unsigned long flags,
00541                                  unsigned long buffer_size);
00542 
00549 int jack_port_unregister (jack_client_t *, jack_port_t *);
00550 
00562 void *jack_port_get_buffer (jack_port_t *, jack_nframes_t);
00563 
00570 const char *jack_port_name (const jack_port_t *port);
00571 
00578 const char *jack_port_short_name (const jack_port_t *port);
00579 
00583 int jack_port_flags (const jack_port_t *port);
00584 
00589 const char *jack_port_type (const jack_port_t *port);
00590 
00594 int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
00595 
00601 int jack_port_connected (const jack_port_t *port);
00602 
00609 int jack_port_connected_to (const jack_port_t *port,
00610                             const char *port_name);
00611 
00623 const char **jack_port_get_connections (const jack_port_t *port);
00624 
00644 const char **jack_port_get_all_connections (const jack_client_t *client,
00645                                             const jack_port_t *port);
00646 
00654 int  jack_port_tie (jack_port_t *src, jack_port_t *dst);
00655 
00663 int  jack_port_untie (jack_port_t *port);
00664 
00675 jack_nframes_t jack_port_get_latency (jack_port_t *port);
00676 
00682 jack_nframes_t jack_port_get_total_latency (jack_client_t *,
00683                                             jack_port_t *port);
00684 
00695 void jack_port_set_latency (jack_port_t *, jack_nframes_t);
00696         
00708 int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
00709 
00723 int jack_recompute_total_latencies (jack_client_t*);
00724 
00732 int jack_port_set_name (jack_port_t *port, const char *port_name);
00733 
00747 int jack_port_set_alias (jack_port_t *port, const char *alias);
00748 
00757 int jack_port_unset_alias (jack_port_t *port, const char *alias);
00758 
00759 /*
00760  * Get any aliases known for @port.
00761  *
00762  * @return the number of aliases discovered for the port
00763  */
00764 int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
00765 
00770 int jack_port_request_monitor (jack_port_t *port, int onoff);
00771 
00780 int jack_port_request_monitor_by_name (jack_client_t *client,
00781                                        const char *port_name, int onoff);
00782 
00790 int jack_port_ensure_monitor (jack_port_t *port, int onoff);
00791 
00795 int jack_port_monitoring_input (jack_port_t *port);
00796 
00814 int jack_connect (jack_client_t *,
00815                   const char *source_port,
00816                   const char *destination_port);
00817 
00831 int jack_disconnect (jack_client_t *,
00832                      const char *source_port,
00833                      const char *destination_port);
00834 
00844 int jack_port_disconnect (jack_client_t *, jack_port_t *);
00845 
00854 int jack_port_name_size(void);
00855 
00860 int jack_port_type_size(void);
00884 const char **jack_get_ports (jack_client_t *, 
00885                              const char *port_name_pattern, 
00886                              const char *type_name_pattern, 
00887                              unsigned long flags);
00888 
00894 jack_port_t *jack_port_by_name (jack_client_t *, const char *port_name);
00895 
00899 jack_port_t *jack_port_by_id (jack_client_t *client,
00900                               jack_port_id_t port_id);
00901 
00918 jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
00919 
00926 jack_nframes_t jack_frame_time (const jack_client_t *);
00927 
00942 jack_nframes_t jack_last_frame_time (const jack_client_t *client);
00943 
00947 jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t);
00948 
00952 jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t);
00953 
00960 jack_time_t jack_get_time();
00961 
00968 
00977 extern void (*jack_error_callback)(const char *msg);
00978 
00985 void jack_set_error_function (void (*func)(const char *));
00986 
00995 extern void (*jack_info_callback)(const char *msg);
00996 
01000 void jack_set_info_function (void (*func)(const char *));
01010 void jack_free(void* ptr);
01011 
01012 #ifdef __cplusplus
01013 }
01014 #endif
01015 
01016 #endif /* __jack_h__ */
01017