├── AUTHORS ├── BUILDING-FOR-LINUX-2.4-KERNEL ├── COPYING ├── COPYING.GPL ├── COPYING.LGPL ├── Makefile.am ├── README.developers ├── README.md ├── TODO ├── acinclude.m4 ├── autogen.sh ├── config ├── Makefile.am ├── os │ ├── Makefile.am │ ├── generic │ │ ├── Makefile.am │ │ ├── ipc.h │ │ ├── poll.h │ │ ├── sanitycheck.c │ │ ├── time.c │ │ └── time.h │ ├── gnu-linux │ │ ├── Makefile.am │ │ ├── sanitycheck.c │ │ ├── systemtest.c │ │ ├── time.c │ │ └── time.h │ └── macosx │ │ ├── JACK_LOCATION.h │ │ ├── Jackframework-Info.plist │ │ ├── Makefile.am │ │ ├── README │ │ ├── getopt.h │ │ ├── ipc.h │ │ ├── jack.xcode │ │ └── project.pbxproj │ │ ├── jack.xcodeproj │ │ └── project.pbxproj │ │ ├── mach_port.h │ │ ├── pThreadUtilities.h │ │ ├── poll.h │ │ ├── sanitycheck.c │ │ ├── time.c │ │ └── time.h └── sysdeps │ ├── Makefile.am │ ├── getopt.h │ ├── ipc.h │ ├── mach_port.h │ ├── pThreadUtilities.h │ ├── poll.h │ ├── portaudio.h │ ├── sanitycheck.c │ ├── systemtest.c │ ├── time.c │ └── time.h ├── configure.ac ├── doc ├── Makefile.am ├── fsm.eps ├── fsm.png ├── mainpage.dox ├── porting.dox ├── reference.doxygen.in └── transport.dox ├── drivers ├── Makefile.am ├── alsa │ ├── Makefile.am │ ├── alsa_driver.c │ ├── alsa_driver.h │ ├── generic.h │ ├── generic_hw.c │ ├── hammerfall.c │ ├── hammerfall.h │ ├── hdsp.c │ ├── hdsp.h │ ├── ice1712.c │ ├── ice1712.h │ ├── memops.c │ ├── usx2y.c │ └── usx2y.h ├── alsa_midi │ ├── Makefile.am │ ├── a2j.h │ ├── alsa_midi.c │ ├── alsa_midi_driver.c │ ├── list.c │ ├── list.h │ ├── midi_pack.h │ ├── midi_unpack.h │ ├── port.c │ ├── port.h │ ├── port_hash.c │ ├── port_hash.h │ ├── port_thread.c │ └── port_thread.h ├── am │ ├── Makefile.am │ ├── alsa_midi.h │ ├── alsa_midi_driver.c │ ├── alsa_rawmidi.c │ ├── alsa_seqmidi.c │ ├── midi_pack.h │ └── midi_unpack.h ├── coreaudio │ ├── Makefile.am │ ├── coreaudio_driver.c │ └── coreaudio_driver.h ├── dummy │ ├── Makefile.am │ ├── dummy_driver.c │ └── dummy_driver.h ├── firewire │ ├── Makefile.am │ ├── ffado_driver.c │ └── ffado_driver.h ├── freebob │ ├── Makefile.am │ ├── freebob_driver.c │ └── freebob_driver.h ├── netjack │ ├── Makefile.am │ ├── README │ ├── net_driver.c │ ├── net_driver.h │ ├── netjack.c │ ├── netjack.h │ ├── netjack_packet.c │ └── netjack_packet.h ├── oss │ ├── Makefile.am │ ├── oss_driver.c │ └── oss_driver.h ├── portaudio │ ├── Makefile.am │ ├── portaudio_driver.c │ └── portaudio_driver.h ├── sndio │ ├── Makefile.am │ ├── sndio_driver.c │ └── sndio_driver.h └── sun │ ├── Makefile.am │ ├── sun_driver.c │ └── sun_driver.h ├── include ├── Makefile.am ├── atomicity.h ├── bitset.h ├── driver.h ├── driver_interface.h ├── driver_parse.h ├── engine.h ├── hardware.h ├── internal.h ├── intsimd.h ├── memops.h ├── messagebuffer.h ├── pool.h ├── port.h ├── sanitycheck.h ├── shm.h ├── start.h ├── systemtest.h ├── unlock.h ├── varargs.h └── version.h.in ├── jack.pc.in ├── jack.spec.in ├── jackd ├── ChangeLog ├── Makefile.am ├── clientengine.c ├── clientengine.h ├── controlapi.c ├── engine.c ├── jackd.1.in ├── jackd.c ├── jackstart.1 ├── jackstart.c ├── md5.c ├── md5.h ├── md5_loc.h ├── transengine.c └── transengine.h ├── libjack ├── ChangeLog ├── Makefile.am ├── client.c ├── driver.c ├── intclient.c ├── local.h ├── messagebuffer.c ├── metadata.c ├── midiport.c ├── pool.c ├── port.c ├── ringbuffer.c ├── sanitycheck.c ├── shm.c ├── simd.c ├── systemtest.c ├── thread.c ├── time.c ├── transclient.c ├── unlock.c └── uuid.c ├── man └── Makefile.am └── python ├── Makefile.am ├── jackctl.py ├── jackd.py ├── mygetopt.py └── reserve_audio.py /AUTHORS: -------------------------------------------------------------------------------- 1 | JACK was inspired by and partially designed during discussions on the 2 | Linux Audio Developers mailing list. Particularly significant 3 | contributions to those discussions came from (in alphabetical order): 4 | 5 | Paul Davis 6 | David Olofson 7 | Benno Sennoner 8 | Kai Vehmanen 9 | 10 | Many other members of LAD contributed ideas to JACK, particularly 11 | Richard Guenther. 12 | 13 | CONTRIBUTORS (in rough chronological order) 14 | 15 | Paul Davis 16 | the principal author of the JACK API and of the 17 | implementation contained here. 18 | 19 | Jack O'Quin 20 | frequently acted as the primary maintainer of JACK for long 21 | periods, and has contributed many new interfaces and bug fixes. 22 | 23 | Andy Wingo 24 | Kai Vehmanen 25 | provided many small patches and documentation. 26 | 27 | Fernando Pablo Lopez-Lezcano 28 | contributed the capabilities-based code for Linux 2.4, 29 | and the RPM specfile. 30 | 31 | Jeremy Hall 32 | Steve Harris 33 | Martin Boer 34 | contributed sample clients and utilities. 35 | 36 | Taybin Rutkin 37 | manages releases and patch handling. 38 | 39 | Melanie Thielker 40 | contributed significantly to JACK's interaction with 41 | aspects of both POSIX and System V APIs. 42 | 43 | Stephane Letz 44 | ported JACK to Mac OS X and Windows, reimplemented 45 | JACK in C++ to give Jackdmp/JACK 2, lots of design 46 | work, bug fixes and testing. 47 | 48 | Jussi Laako 49 | wrote the OSS driver interface. 50 | 51 | Tilman Linneweh 52 | ported JACK to FreeBSD. 53 | 54 | Johnny Petrantoni 55 | wrote the Mac OS X CoreAudio driver interface. 56 | 57 | Rui Nuno Capela 58 | designed and implemented JACK improvements to work with his 59 | QJackCtl graphical interface for JACK. 60 | 61 | Karsten Wiese 62 | (with Rui) added US-X2Y USB device support to the 63 | ALSA backend, added read/write lock support. 64 | 65 | Lee Revell 66 | contributed statistical interfaces and much low-latency realtime testing. 67 | 68 | Ian Esten 69 | wrote JACK's MIDI port handling and API, along with example 70 | MIDI clients. 71 | 72 | Frank van der Pol 73 | wrote the COMPLEX_MMAP patch for ALSA, allowing JACK to run 74 | on multi-device PCM configurations. 75 | 76 | Dmitry Baikov 77 | wrote the jackmidi ALSA hardware support. 78 | 79 | Pieter Palmers 80 | wrote the freebob and firewire backends and some bugfixes. 81 | add jack-midi support to netjack 82 | 83 | Nedko Arnaudov 84 | contributed several fixes 85 | 86 | Jacob Meuser 87 | contributed the sun backend. 88 | 89 | Marc-Olivier Barre 90 | help with netjack integration and cleanup 91 | 92 | Torben Hohn 93 | wrote netjack, implemented mixed 64/32 bit support and bug fixes. 94 | 95 | Many others have contributed patches and/or test results, and we thank 96 | them all. 97 | -------------------------------------------------------------------------------- /BUILDING-FOR-LINUX-2.4-KERNEL: -------------------------------------------------------------------------------- 1 | Specific Instructions for a 2.4 Linux kernel 2 | -------------------------------------------- 3 | 4 | Before using JACK in realtime mode with a 2.4 kernel, you may 5 | need or want to take the following steps. A better choice is 6 | to use a 2.6 kernel. 7 | 8 | 1) in /usr/src/linux/include/linux/capability.h find these lines 9 | 10 | #define CAP_INIT_EFF_SET to_cap_t(~0 & ~CAP_TO_MASK(CAP_SETPCAP)) 11 | #define CAP_INIT_INH_SET to_cap_t(0) 12 | 13 | and change them to 14 | 15 | #define CAP_INIT_EFF_SET to_cap_t(~0) 16 | #define CAP_INIT_INH_SET to_cap_t(~0) 17 | 18 | then recompile your kernel and boot it. (Note that the above lines 19 | are from linux 2.4.19; it may be different if you're using a 20 | different version) 21 | 22 | NB: This may expose your system to local denial of service attacks. 23 | If it is a shared system or server, you should assess the impact of 24 | enabling capabilities in the context of your overall system security 25 | requirements. 26 | 27 | 2) install libcap from 28 | ftp://ftp.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.4/ 29 | 30 | 3) if you're using a journalling filesystem, mount some directory with 31 | -t tmpfs and use this with JACK's configure step as the 32 | argument to --with-default-tmpdir. 33 | 34 | 4) use --enable-capabilities with JACK's configure step 35 | 36 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Files in this tree are mainly licensed under the GPL, as noted in the 2 | file headers. However, the libjack/ tree is licensed under the LGPL in 3 | order to allow for proprietary usage of Jack. Please see COPYING.GPL and 4 | COPYING.LGPL for more information on these two licenses. 5 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in \ 2 | stamp-h.in config.log config.cache config.status 3 | 4 | ACLOCAL_AMFLAGS = -I m4 5 | 6 | if HAVE_DOXYGEN 7 | DOC_DIR = doc 8 | dist-check-doxygen: 9 | else 10 | DOC_DIR = 11 | dist-check-doxygen: 12 | @echo 13 | @echo ' ******' You need doxygen installed to make dist.' ******' 14 | @echo 15 | @false 16 | endif 17 | 18 | SUBDIRS = libjack jackd drivers config $(DOC_DIR) man python 19 | DIST_SUBDIRS = config libjack jackd include drivers doc man python 20 | 21 | pkgconfigdir = $(libdir)/pkgconfig 22 | pkgconfig_DATA = jack.pc 23 | 24 | EXTRA_DIST = COPYING COPYING.GPL COPYING.LGPL libjack/simd.c jack.spec 25 | 26 | AUTOMAKE_OPTIONS = foreign 27 | 28 | rpm: dist 29 | rpm -ta $(distdir).tar.gz 30 | 31 | dist-hook: dist-check-doxygen 32 | 33 | libjackincludedir = $(includedir)/jack 34 | 35 | libjackinclude_HEADERS = \ 36 | jack/control.h \ 37 | jack/intclient.h \ 38 | jack/jack.h \ 39 | jack/jslist.h \ 40 | jack/metadata.h \ 41 | jack/midiport.h \ 42 | jack/ringbuffer.h \ 43 | jack/session.h \ 44 | jack/statistics.h \ 45 | jack/systemdeps.h \ 46 | jack/thread.h \ 47 | jack/transport.h \ 48 | jack/types.h \ 49 | jack/uuid.h \ 50 | jack/weakjack.h \ 51 | jack/weakmacros.h 52 | -------------------------------------------------------------------------------- /README.developers: -------------------------------------------------------------------------------- 1 | ======================================================================= 2 | *** README.developers - JACK development practices *** 3 | ======================================================================= 4 | 5 | :Version: $Id$ 6 | :Formatting: restructured text, http://docutils.sourceforge.net/rst.html 7 | 8 | What is this? 9 | ----------------------------------------------------------------------- 10 | 11 | This file is a collection of practices and rules for JACK 12 | development. If you have questions, or would like to make 13 | changes, raise the issue on jackit-devel (see 14 | http://lists.sourceforge.net/lists/listinfo/jackit-devel ). 15 | 16 | 17 | Contents 18 | ----------------------------------------------------------------------- 19 | 20 | - What is this? 21 | - Version numbers 22 | - Important files for developers 23 | - Sending patches 24 | - CVS Access 25 | - Decision Process 26 | 27 | 28 | Important files for developers 29 | ----------------------------------------------------------------------- 30 | 31 | AUTHORS 32 | List of contributors. If you have contributed code, mail Paul 33 | Davis to get your name added to the list, or if you have 34 | CVS-access, help yourself. :) Also remember to update the 35 | per source file copyright statements when committing changes. 36 | 37 | README.developers 38 | This file. 39 | 40 | TODO 41 | A one file mini-bugzilla for JACK developers. Note: this file 42 | is no longer actively updated - please use the Mantis 43 | bugtracker instead, see http://jackit.sourceforge.net/dev/ . 44 | 45 | libjack/ChangeLog 46 | A list of _all_ changes to the public interface! 47 | 48 | 49 | Version numbers 50 | ----------------------------------------------------------------------- 51 | 52 | JACK's package version 53 | ~~~~~~~~~~~~~~~~~~~~~~ 54 | 55 | JACK's package version is set in configure.in, and consists of 56 | major, minor and revision numbers. This version should be 57 | updated whenever a non-trivial set of changes is committed 58 | to CVS: 59 | 60 | major version 61 | ask on jackit-devel :) 62 | 63 | minor version 64 | incremented when any of the public or internal 65 | interfaces are changed 66 | 67 | revision 68 | incremented when implementation-only 69 | changes are made 70 | 71 | Client API versioning 72 | ~~~~~~~~~~~~~~~~~~~~~ 73 | 74 | JACK clients are affected by two interfaces, the JACK Client API (libjack) 75 | and the JACK Client Protocol API (interface between jackd and 76 | libjack). The former one is versioned using libtool interface 77 | versioniong (set in configure.in). This version should be updated 78 | whenever a set of changes affecting the interface is committed 79 | to CVS: 80 | 81 | current 82 | incremented whenever the public libjack API is changed 83 | 84 | revision 85 | incremented when the libjack implementation is changed 86 | 87 | age 88 | current libjack is both source and binary compatible with 89 | libjack interfaces current,current-1,...,current-age 90 | 91 | Note! It was decided in January 2003 that current interface number 92 | will remain as zero until the first stable JACK version 93 | is released. 94 | 95 | JACK Client Protocol is versioned... . 96 | 97 | Note! All changes that affect the libjack API must be documented 98 | in jack/libjack/ChangeLog using the standard ChangeLog style 99 | (see GNU developer docs). 100 | 101 | 102 | Sending patches 103 | --------------------------------------------------------------------- 104 | 105 | People without CVS-access 106 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 107 | 108 | Send your patches to jackit-devel. Normally patches are accepted 109 | by Paul Davis and/or Jack O'Quin. Either the patch is applied right 110 | away, or you get an "ok to me" message, after which other developers 111 | with CVS-access can commit the patch. 112 | 113 | People with CVS-access 114 | ~~~~~~~~~~~~~~~~~~~~~~ 115 | 116 | Trivial changes can be committed without review. For non-trivial 117 | changes, you should first send a proposal to jackit-devel and 118 | wait for comments. There are no strict approval rules so use of 119 | common sense is recommended. ;) 120 | 121 | Tips for making patches 122 | ~~~~~~~~~~~~~~~~~~~~~~~ 123 | 124 | - test your patch on a clean CVS-checkout 125 | - remember to run cvs update before making commits 126 | 127 | 128 | CVS Access 129 | ----------------------------------------------------------------------- 130 | 131 | Contact Paul Davis. 132 | 133 | 134 | Uses of external libraries and other packages 135 | ----------------------------------------------------------------------- 136 | 137 | The main JACK components, jackd and libjack, should only use 138 | standard POSIX and ANSI-C services. If use of other interfaces is 139 | absolutely needed, it should be made optional in the build process (via 140 | a configure switch for example). 141 | 142 | Other components like example clients and drivers, may rely on other 143 | packages, but these dependencies should not affect the main build 144 | process. 145 | 146 | 147 | Decision Process 148 | ----------------------------------------------------------------------- 149 | 150 | All non-trivial changes should be discussed on the jackit-devel 151 | mailing list. It has been agreed that Paul Davis will make 152 | the final decisions based on these discussions. 153 | 154 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Welcome to JACK, the Jack Audio Connection Kit. 2 | 3 | Please see the JACK [website](https://jackaudio.org/) and [wiki](https://github.com/jackaudio/jackaudio.github.com/wiki) for more information. 4 | There are also the #jack and #lad chat channels on [libera.chat IRC](https://web.libera.chat/#jack). 5 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | ======================================================================= 2 | *** TODO - A one file mini-bugzilla for JACK developers *** 3 | ======================================================================= 4 | 5 | Version: $Id$ 6 | 7 | NOTE: web-based bug tracker for JACK was put online in Oct 2003. It is 8 | now the preferred way to report and track bugs and feature 9 | requests. This TODO file is now used only for tracking release 10 | issues (mapping features and other todo-items to release 11 | roadmap, etc). 12 | 13 | The new bug tracker can be found at: 14 | 15 | http://jackit.sourceforge.net/mantis/ 16 | 17 | ----------------------------------------------------------------------- 18 | 19 | You can update this list directly via CVS or alternatively 20 | send a change request to jackit-devel mailing list. 21 | 22 | ----------------------------------------------------------------------- 23 | 24 | TODO for merging Mac OS X support 25 | 26 | - clean up other header files 27 | -- , fakepoll.h, etc. 28 | -- , in shm.c 29 | 30 | TODO before-1.0 31 | 32 | - add explanation of protocol versioning to README.developers (kaiv) 33 | 34 | TODO post-1.0 35 | 36 | - jack session handling (taybin) 37 | - first client run without jackd becomes jackd (joq) 38 | - TBD 39 | 40 | TODO general - no agreed timeline 41 | 42 | - better scheme for handling machine and system dependencies (joq) 43 | - proper handling of client return values in libjack 44 | - pool based malloc for rt client-local mem allocation (paul, moved back here) 45 | 46 | TO BE DECIDED - no agreed timeline 47 | 48 | - dropping the use of CAP_RESOURCE (nando) 49 | - support for on-the-fly sampling rate change 50 | - whether to default to triangular dithering for 16bit output. (swh) 51 | 52 | TO THINK ABOUT - no agreed timeline 53 | 54 | - ensure that UST/MSC pairs work for transport API 55 | - whether we want to support varispeed (resampling and/or changing 56 | the actual rate) 57 | - per-block timestamping against system clock (UST stamps at driver level) 58 | - dynamically increase the total number of ports in the system 59 | 60 | CLOSED (date,who,comment) 61 | 62 | - handle mixed-mode 64bit and 32bit clients (2008/10, done by torben) 63 | - don't build static libraries of drivers and ip-clients (2003/10/07,paul) 64 | - API to change buffer size (joq) (2003/10/07) 65 | - added code to enforce the 'bufsize==2^x' rule (taybin) (2003/8/28) 66 | - make sure that process callbacks always have nframes equal to buffersize (2003/08/27,done,kaiv) 67 | - add Paul's graph/subgraph explanation to the design doc (2003/08/27,done,kaiv) 68 | - add support for custom jackd --tmpdir in libjack (2003/05/06,done,jesse) 69 | - capture_client has pthread_mutex_lock() in its process() (2003/05/30,fixed,joq) 70 | - update at least the user-visible copyrights with year 2003 (2003/04/05,done,paul) 71 | - add a sane way handle situations where the unix sockets already 72 | exist when jackd is started (2003/04/05,sockets removed on startup,paul) 73 | - figure out how to have pools of buffers for ports by type - (2003/04/05, paul, implicit in new shm/port segment system) 74 | - passing args to drivers and clients? (?,done long ago,paul) 75 | - pool based malloc for rt client-local mem allocation (paul) 76 | - getting callbacks and args from dynamically loaded clients? (2003/02/25, paul, see jack/jack.h) 77 | - how do dynamically loaded clients (un)register ports, activate, etc. (2003/02/25, paul, see example-clients/inprocess.c) 78 | - server<->libjack interface version handshake (2003/02/11, trutkin, done) 79 | - alsa-driver parameter parsing patch (2003/02/25, joq, done) 80 | - jack_deactive called unconditionally in jack_client_close (2003/02/05, kaiv, fixed) 81 | - call time client before all others (2003/01/28, kaiv, another solution) 82 | - finalize discussion on transport API, and implement (2003/08/04, joq) 83 | - whether to hide the transport.h structs from clients (2003/08/04, joq) 84 | - define transport info struct contents (2003/08/13, joq) 85 | - resolve helper thread design question? (2003/08/31, joq) 86 | - get portaudio driver working under Linux (2003/10/29, joq) 87 | 88 | ----------------------------------------------------------------------- 89 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) 2 | dnl example 3 | dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) 4 | dnl will set SYSCONFDIR to /usr/local/etc 5 | 6 | dnl written by thomas vander stichele 7 | 8 | AC_DEFUN([AS_AC_EXPAND], 9 | [ 10 | EXP_VAR=[$1] 11 | FROM_VAR=[$2] 12 | 13 | dnl first expand prefix and exec_prefix if necessary 14 | prefix_save=$prefix 15 | if test "x$prefix" = "xNONE"; then 16 | prefix=/usr/local 17 | fi 18 | exec_prefix_save=$exec_prefix 19 | if test "x$exec_prefix" = "xNONE"; then 20 | if test "x$prefix_save" = "xNONE"; then 21 | exec_prefix=/usr/local 22 | else 23 | exec_prefix=$prefix 24 | fi 25 | fi 26 | 27 | full_var="$FROM_VAR" 28 | dnl loop until it doesn't change anymore 29 | while true; do 30 | new_full_var="`eval echo $full_var`" 31 | if test "x$new_full_var" = "x$full_var"; then break; fi 32 | full_var=$new_full_var 33 | done 34 | 35 | dnl clean up 36 | full_var=$new_full_var 37 | [$1]=$full_var 38 | prefix=$prefix_save 39 | exec_prefix=$exec_prefix_save 40 | ]) 41 | 42 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # on OS X, which(1) returns 0 even when it can't find a program 5 | # 6 | 7 | if type libtoolize >/dev/null 2>&1 8 | then 9 | LIBTOOLIZE=libtoolize 10 | else 11 | if which glibtoolize >/dev/null 12 | then 13 | # on the Mac it's called glibtoolize for some reason 14 | LIBTOOLIZE=glibtoolize 15 | else 16 | echo "libtoolize not found" 17 | exit 1 18 | fi 19 | fi 20 | 21 | $LIBTOOLIZE --force --automake 2>&1 | sed '/^You should/d' || { 22 | echo "libtool failed, exiting..." 23 | exit 1 24 | } 25 | 26 | ACLOCAL_FLAGS="-I m4" 27 | aclocal $ACLOCAL_FLAGS || { 28 | echo "aclocal \$ACLOCAL_FLAGS where \$ACLOCAL_FLAGS= failed, exiting..." 29 | exit 1 30 | } 31 | 32 | autoheader || { 33 | echo "autoheader failed, exiting..." 34 | exit 1 35 | } 36 | 37 | automake --add-missing --foreign || { 38 | echo "automake --add-missing --foreign failed, exiting..." 39 | exit 1 40 | } 41 | 42 | autoconf || { 43 | echo "autoconf failed, exiting..." 44 | exit 1 45 | } 46 | 47 | if test x$1 = x--run-conf; then 48 | echo "because of \"$1\" Running ./configure --enable-maintainer-mode $@..." 49 | ./configure --enable-maintainer-mode $@ 50 | fi 51 | -------------------------------------------------------------------------------- /config/Makefile.am: -------------------------------------------------------------------------------- 1 | # We don't actually build anything in the `cpu' and `os' 2 | # subdirectories. 3 | 4 | DIST_SUBDIRS = os sysdeps 5 | 6 | EXTRA_DIST = depcomp 7 | MAINTAINERCLEANFILES = Makefile.in config.guess config.sub \ 8 | install-sh ltmain.sh missing mkinstalldirs 9 | -------------------------------------------------------------------------------- /config/os/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | DIST_SUBDIRS = generic gnu-linux macosx 3 | 4 | -------------------------------------------------------------------------------- /config/os/generic/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | noinst_HEADERS = sanitycheck.c ipc.h poll.h time.c time.h 3 | -------------------------------------------------------------------------------- /config/os/generic/ipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004 Jack O'Quin 3 | 4 | Generic version, overridden by OS-specific defines when needed. 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | #ifndef _jack_sys_ipc 23 | #define _jack_sys_ipc 1 24 | 25 | #include 26 | 27 | #endif /* _jack_sys_ipc */ 28 | -------------------------------------------------------------------------------- /config/os/generic/poll.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004 Jack O'Quin 3 | 4 | Generic version, overridden by OS-specific defines when needed. 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | #ifndef _jack_sys_poll 23 | #define _jack_sys_poll 1 24 | 25 | #include 26 | 27 | #endif /* _jack_sys_poll */ 28 | -------------------------------------------------------------------------------- /config/os/generic/sanitycheck.c: -------------------------------------------------------------------------------- 1 | #include "sanitycheck.h" 2 | 3 | int 4 | sanitycheck (int a, int b) 5 | { 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /config/os/generic/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2004 Paul Davis, Tilman Linneweh 3 | 4 | Generic version, overridden by OS-specific definition when needed. 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | void jack_init_time () 23 | { 24 | /* nothing to do on a generic system - we use the system clock */ 25 | } 26 | void jack_set_clock_source (jack_timer_type_t clocksrc) 27 | { 28 | /* only one clock source on a generic system */ 29 | } 30 | 31 | -------------------------------------------------------------------------------- /config/os/generic/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2004 Paul Davis, Tilman Linneweh 3 | 4 | Generic version, overridden by OS-specific definition when needed. 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | #ifndef __jack_time_h__ 22 | #define __jack_time_h__ 23 | 24 | #include 25 | 26 | extern jack_time_t jack_get_microseconds_from_system(void); 27 | 28 | static inline jack_time_t 29 | jack_get_microseconds (void) 30 | { 31 | return jack_get_microseconds_from_system (); 32 | } 33 | 34 | typedef jack_time_t (*jack_get_microseconds_t)(void); 35 | static inline jack_get_microseconds_t jack_get_microseconds_pointer (void) 36 | { 37 | return jack_get_microseconds_from_system; 38 | } 39 | 40 | #endif /* __jack_time_h__ */ 41 | -------------------------------------------------------------------------------- /config/os/gnu-linux/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | noinst_HEADERS = systemtest.c sanitycheck.c time.c time.h 3 | 4 | -------------------------------------------------------------------------------- /config/os/gnu-linux/sanitycheck.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; either version 2 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | * 17 | * @author Florian Faber 18 | * 19 | **/ 20 | 21 | #include 22 | #include "systemtest.h" 23 | #include "sanitycheck.h" 24 | 25 | int sanitycheck (int care_about_realtime, 26 | int care_about_freqscaling) 27 | { 28 | int errors = 0; 29 | int warnings = 0; 30 | int relogin = 0; 31 | 32 | if (care_about_realtime && !system_user_can_rtprio ()) { 33 | errors++; 34 | relogin++; 35 | fprintf (stderr, "\nJACK is running in realtime mode, but you are not allowed to use realtime scheduling.\n"); 36 | 37 | if (!system_has_rtprio_limits_conf ()) { 38 | errors++; 39 | relogin++; 40 | fprintf (stderr, "Please check your /etc/security/limits.conf for the following line\n"); 41 | fprintf (stderr, "and correct/add it if necessary:\n\n"); 42 | fprintf (stderr, " @audio - rtprio 99\n"); 43 | } else if (!system_has_audiogroup ()) { 44 | errors++; 45 | relogin++; 46 | fprintf (stderr, "\nYour system has no audio group. Please add it by executing (as root):\n"); 47 | fprintf (stderr, " groupadd -r audio\n"); 48 | fprintf (stderr, " usermod -a -G audio %s\n", system_get_username ()); 49 | } else if (!system_user_in_audiogroup ()) { 50 | errors++; 51 | relogin++; 52 | fprintf (stderr, "\nYour system has an audio group, but you are not a member of it.\n"); 53 | fprintf (stderr, "Please add yourself to the audio group by executing (as root):\n"); 54 | fprintf (stderr, " usermod -a -G audio %s\n", system_get_username ()); 55 | } 56 | } 57 | if (care_about_freqscaling && system_has_frequencyscaling () && system_uses_frequencyscaling ()) { 58 | warnings++; 59 | fprintf (stderr, "\n--------------------------------------------------------------------------------\n"); 60 | fprintf (stderr, "WARNING: Your system seems to use frequency scaling.\n\n"); 61 | fprintf (stderr, " This can have a serious impact on audio latency. You have two choices:\n"); 62 | fprintf (stderr, "\t(1)turn it off, e.g. by chosing the 'performance' governor.\n"); 63 | fprintf (stderr, "\t(2)Use the HPET clocksource by passing \"-c h\" to JACK\n"); 64 | fprintf (stderr, "\t (this second option only works on relatively recent computers)\n"); 65 | fprintf (stderr, "--------------------------------------------------------------------------------\n\n"); 66 | } 67 | if (0 == system_memlock_amount ()) { 68 | errors++; 69 | relogin++; 70 | fprintf (stderr, "\nYou are not allowed to lock memory. Please add a line\n"); 71 | fprintf (stderr, " @audio - memlock %llu\n", (system_available_physical_mem () * 3) / 4096); 72 | fprintf (stderr, "in your /etc/limits.conf.\n"); 73 | } 74 | 75 | if (0 < relogin) { 76 | fprintf (stderr, "\nAfter applying these changes, please re-login in order for them to take effect.\n"); 77 | } 78 | 79 | if (0 < errors) { 80 | fprintf (stderr, "\nYou don't appear to have a sane system configuration. It is very likely that you\n"); 81 | fprintf (stderr, "encounter xruns. Please apply all the above mentioned changes and start jack again!\n"); 82 | } 83 | 84 | return errors; 85 | } 86 | -------------------------------------------------------------------------------- /config/os/gnu-linux/time.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "bsd"; -*- */ 2 | /* 3 | Copyright (C) 2001-2003 Paul Davis 4 | Copyright (C) 2005 Jussi Laako 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | 26 | jack_time_t (*_jack_get_microseconds)(void) = 0; 27 | 28 | #if defined(__gnu_linux__) && (defined(__i386__) || defined(__x86_64__)) 29 | #define HPET_SUPPORT 30 | #define HPET_MMAP_SIZE 1024 31 | #define HPET_CAPS 0x000 32 | #define HPET_PERIOD 0x004 33 | #define HPET_COUNTER 0x0f0 34 | #define HPET_CAPS_COUNTER_64BIT (1 << 13) 35 | #if defined(__x86_64__) 36 | typedef uint64_t hpet_counter_t; 37 | #else 38 | typedef uint32_t hpet_counter_t; 39 | #endif 40 | static int hpet_fd; 41 | static unsigned char *hpet_ptr; 42 | static uint32_t hpet_period; /* period length in femto secs */ 43 | static uint64_t hpet_offset = 0; 44 | static uint64_t hpet_wrap; 45 | static hpet_counter_t hpet_previous = 0; 46 | #endif /* defined(__gnu_linux__) && (__i386__ || __x86_64__) */ 47 | 48 | #ifdef HPET_SUPPORT 49 | int 50 | jack_hpet_init () 51 | { 52 | uint32_t hpet_caps; 53 | 54 | hpet_fd = open ("/dev/hpet", O_RDONLY); 55 | if (hpet_fd < 0) { 56 | jack_error ("This system has no accessible HPET device (%s)", strerror (errno)); 57 | return -1; 58 | } 59 | 60 | hpet_ptr = (unsigned char*)mmap (NULL, HPET_MMAP_SIZE, 61 | PROT_READ, MAP_SHARED, hpet_fd, 0); 62 | if (hpet_ptr == MAP_FAILED) { 63 | jack_error ("This system has no mappable HPET device (%s)", strerror (errno)); 64 | close (hpet_fd); 65 | return -1; 66 | } 67 | 68 | /* this assumes period to be constant. if needed, 69 | it can be moved to the clock access function 70 | */ 71 | hpet_period = *((uint32_t*)(hpet_ptr + HPET_PERIOD)); 72 | hpet_caps = *((uint32_t*)(hpet_ptr + HPET_CAPS)); 73 | hpet_wrap = ((hpet_caps & HPET_CAPS_COUNTER_64BIT) && 74 | (sizeof(hpet_counter_t) == sizeof(uint64_t))) ? 75 | 0 : ((uint64_t)1 << 32); 76 | 77 | return 0; 78 | } 79 | 80 | static jack_time_t 81 | jack_get_microseconds_from_hpet (void) 82 | { 83 | hpet_counter_t hpet_counter; 84 | long double hpet_time; 85 | 86 | hpet_counter = *((hpet_counter_t*)(hpet_ptr + HPET_COUNTER)); 87 | if (unlikely (hpet_counter < hpet_previous)) { 88 | hpet_offset += hpet_wrap; 89 | } 90 | hpet_previous = hpet_counter; 91 | hpet_time = (long double)(hpet_offset + hpet_counter) * 92 | (long double)hpet_period * (long double)1e-9; 93 | return (jack_time_t)(hpet_time + 0.5); 94 | } 95 | 96 | #else 97 | 98 | static int 99 | jack_hpet_init () 100 | { 101 | jack_error ("This version of JACK or this computer does not have HPET support.\n" 102 | "Please choose a different clock source."); 103 | return -1; 104 | } 105 | 106 | static jack_time_t 107 | jack_get_microseconds_from_hpet (void) 108 | { 109 | /* never called */ 110 | return 0; 111 | } 112 | 113 | #endif /* HPET_SUPPORT */ 114 | 115 | 116 | void 117 | jack_init_time () 118 | { 119 | /* nothing to do on a generic system - we use the system clock */ 120 | } 121 | 122 | void 123 | jack_set_clock_source (jack_timer_type_t clocksrc) 124 | { 125 | switch (clocksrc) { 126 | case JACK_TIMER_HPET: 127 | if (jack_hpet_init () == 0) { 128 | _jack_get_microseconds = jack_get_microseconds_from_hpet; 129 | } else { 130 | _jack_get_microseconds = jack_get_microseconds_from_system; 131 | } 132 | break; 133 | 134 | case JACK_TIMER_SYSTEM_CLOCK: 135 | default: 136 | _jack_get_microseconds = jack_get_microseconds_from_system; 137 | break; 138 | } 139 | } 140 | 141 | -------------------------------------------------------------------------------- /config/os/gnu-linux/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2003 Paul Davis 3 | Copyright (C) 2005 Jussi Laako 4 | 5 | This is the GNU/Linux version. 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | */ 22 | 23 | #ifndef __jack_time_h__ 24 | #define __jack_time_h__ 25 | 26 | #include 27 | 28 | extern jack_time_t (*_jack_get_microseconds)(void); 29 | 30 | static inline jack_time_t 31 | jack_get_microseconds (void) 32 | { 33 | return _jack_get_microseconds (); 34 | } 35 | 36 | typedef jack_time_t (*jack_get_microseconds_t)(void); 37 | static inline jack_get_microseconds_t jack_get_microseconds_pointer (void) 38 | { 39 | return _jack_get_microseconds; 40 | } 41 | 42 | #endif /* __jack_time_h__ */ 43 | -------------------------------------------------------------------------------- /config/os/macosx/JACK_LOCATION.h: -------------------------------------------------------------------------------- 1 | #define JACK_LOCATION "/usr/local/bin" -------------------------------------------------------------------------------- /config/os/macosx/Jackframework-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | Jackmp 9 | CFBundleGetInfoString 10 | libjack 0.107.5, @03-07 Paul Davis, Grame 11 | CFBundleIdentifier 12 | com.grame.Jackmp 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 0.1 23 | 24 | 25 | -------------------------------------------------------------------------------- /config/os/macosx/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | noinst_HEADERS = sanitycheck.c getopt.h ipc.h JACK_LOCATION.h mach_port.h \ 3 | poll.h pThreadUtilities.h time.c time.h 4 | 5 | EXTRA_DIST = jack.xcode/project.pbxproj 6 | -------------------------------------------------------------------------------- /config/os/macosx/getopt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackaudio/jack1/ab2e7363cacd0bf4b961c0466c13b0b4c1086ed9/config/os/macosx/getopt.h -------------------------------------------------------------------------------- /config/os/macosx/ipc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackaudio/jack1/ab2e7363cacd0bf4b961c0466c13b0b4c1086ed9/config/os/macosx/ipc.h -------------------------------------------------------------------------------- /config/os/macosx/mach_port.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackaudio/jack1/ab2e7363cacd0bf4b961c0466c13b0b4c1086ed9/config/os/macosx/mach_port.h -------------------------------------------------------------------------------- /config/os/macosx/pThreadUtilities.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackaudio/jack1/ab2e7363cacd0bf4b961c0466c13b0b4c1086ed9/config/os/macosx/pThreadUtilities.h -------------------------------------------------------------------------------- /config/os/macosx/poll.h: -------------------------------------------------------------------------------- 1 | 2 | // fakepoll.h 3 | // poll using select 4 | // Warning: a call to this poll() takes about 4K of stack space. 5 | 6 | // Greg Parker gparker-web@sealiesoftware.com December 2000 7 | // This code is in the public domain and may be copied or modified without 8 | // permission. 9 | 10 | // Updated May 2002: 11 | // * fix crash when an fd is less than 0 12 | // * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE 13 | // * don't set POLLIN or POLLOUT in revents if it wasn't requested 14 | // in events (only happens when an fd is in the poll set twice) 15 | 16 | #ifndef _FAKE_POLL_H 17 | #define _FAKE_POLL_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | typedef struct pollfd { 27 | int fd; /* file desc to poll */ 28 | short events; /* events of interest on fd */ 29 | short revents; /* events that occurred on fd */ 30 | } pollfd_t; 31 | 32 | 33 | // poll flags 34 | #define POLLIN 0x0001 35 | #define POLLOUT 0x0004 36 | #define POLLERR 0x0008 37 | 38 | // synonyms 39 | #define POLLNORM POLLIN 40 | #define POLLPRI POLLIN 41 | #define POLLRDNORM POLLIN 42 | #define POLLRDBAND POLLIN 43 | #define POLLWRNORM POLLOUT 44 | #define POLLWRBAND POLLOUT 45 | 46 | // ignored 47 | #define POLLHUP 0x0010 48 | #define POLLNVAL 0x0020 49 | 50 | static inline int 51 | poll (struct pollfd *pollSet, int pollCount, int pollTimeout) 52 | { 53 | struct timeval tv; 54 | struct timeval *tvp; 55 | fd_set readFDs, writeFDs, exceptFDs; 56 | fd_set *readp, *writep, *exceptp; 57 | struct pollfd *pollEnd, *p; 58 | int selected; 59 | int result; 60 | int maxFD; 61 | 62 | if (!pollSet) { 63 | pollEnd = NULL; 64 | readp = NULL; 65 | writep = NULL; 66 | exceptp = NULL; 67 | maxFD = 0; 68 | } else { 69 | pollEnd = pollSet + pollCount; 70 | readp = &readFDs; 71 | writep = &writeFDs; 72 | exceptp = &exceptFDs; 73 | 74 | FD_ZERO (readp); 75 | FD_ZERO (writep); 76 | FD_ZERO (exceptp); 77 | 78 | // Find the biggest fd in the poll set 79 | maxFD = 0; 80 | for (p = pollSet; p < pollEnd; p++) 81 | if (p->fd > maxFD) { 82 | maxFD = p->fd; 83 | } 84 | 85 | if (maxFD >= FD_SETSIZE) { 86 | // At least one fd is too big 87 | errno = EINVAL; 88 | return -1; 89 | } 90 | 91 | // Transcribe flags from the poll set to the fd sets 92 | for (p = pollSet; p < pollEnd; p++) { 93 | if (p->fd < 0) { 94 | // Negative fd checks nothing and always reports zero 95 | } else { 96 | if (p->events & POLLIN) { 97 | FD_SET (p->fd, readp); 98 | } 99 | if (p->events & POLLOUT) { 100 | FD_SET (p->fd, writep); 101 | } 102 | if (p->events != 0) { 103 | FD_SET (p->fd, exceptp); 104 | } 105 | // POLLERR is never set coming in; poll() always reports errors 106 | // But don't report if we're not listening to anything at all. 107 | } 108 | } 109 | } 110 | 111 | // poll timeout is in milliseconds. Convert to struct timeval. 112 | // poll timeout == -1 : wait forever : select timeout of NULL 113 | // poll timeout == 0 : return immediately : select timeout of zero 114 | if (pollTimeout >= 0) { 115 | tv.tv_sec = pollTimeout / 1000; 116 | tv.tv_usec = (pollTimeout % 1000) * 1000; 117 | tvp = &tv; 118 | } else { 119 | tvp = NULL; 120 | } 121 | 122 | selected = select (maxFD + 1, readp, writep, exceptp, tvp); 123 | 124 | if (selected < 0) { 125 | // Error during select 126 | result = -1; 127 | } else if (selected > 0) { 128 | // Select found something 129 | // Transcribe result from fd sets to poll set. 130 | // Also count the number of selected fds. poll returns the 131 | // number of ready fds; select returns the number of bits set. 132 | int polled = 0; 133 | for (p = pollSet; p < pollEnd; p++) { 134 | p->revents = 0; 135 | if (p->fd < 0) { 136 | // Negative fd always reports zero 137 | } else { 138 | if ((p->events & POLLIN) && FD_ISSET (p->fd, readp)) { 139 | p->revents |= POLLIN; 140 | } 141 | if ((p->events & POLLOUT) && FD_ISSET (p->fd, writep)) { 142 | p->revents |= POLLOUT; 143 | } 144 | if ((p->events != 0) && FD_ISSET (p->fd, exceptp)) { 145 | p->revents |= POLLERR; 146 | } 147 | 148 | if (p->revents) { 149 | polled++; 150 | } 151 | } 152 | } 153 | result = polled; 154 | } else { 155 | // selected == 0, select timed out before anything happened 156 | // Clear all result bits and return zero. 157 | for (p = pollSet; p < pollEnd; p++) 158 | p->revents = 0; 159 | result = 0; 160 | } 161 | 162 | return result; 163 | } 164 | 165 | #endif 166 | -------------------------------------------------------------------------------- /config/os/macosx/sanitycheck.c: -------------------------------------------------------------------------------- 1 | #include "sanitycheck.h" 2 | 3 | int 4 | sanitycheck (int a, int b) 5 | { 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /config/os/macosx/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2003 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_time_c__ 21 | #define __jack_time_c__ 22 | 23 | #include 24 | #include 25 | 26 | double __jack_time_ratio; 27 | 28 | void 29 | jack_init_time () 30 | { 31 | mach_timebase_info_data_t info; 32 | 33 | mach_timebase_info (&info); 34 | __jack_time_ratio = ((float)info.numer / info.denom) / 1000; 35 | } 36 | 37 | void jack_set_clock_source (jack_timer_type_t clocksrc) 38 | { 39 | /* only one clock source for os x */ 40 | } 41 | 42 | jack_time_t 43 | jack_get_microseconds_symbol (void) 44 | { 45 | return (jack_time_t)mach_absolute_time () * __jack_time_ratio; 46 | } 47 | #endif /* __jack_time_c__ */ 48 | -------------------------------------------------------------------------------- /config/os/macosx/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2003 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_time_h__ 21 | #define __jack_time_h__ 22 | 23 | #include 24 | #include 25 | 26 | extern double __jack_time_ratio; 27 | 28 | static inline jack_time_t 29 | jack_get_microseconds (void) 30 | { 31 | return (jack_time_t)mach_absolute_time () * __jack_time_ratio; 32 | } 33 | 34 | extern jack_time_t jack_get_microseconds_symbol(void); 35 | 36 | typedef jack_time_t (*jack_get_microseconds_t)(void); 37 | static inline jack_get_microseconds_t jack_get_microseconds_pointer (void) 38 | { 39 | return jack_get_microseconds_symbol; 40 | } 41 | 42 | #endif /* __jack_time_h__ */ 43 | -------------------------------------------------------------------------------- /config/sysdeps/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | 3 | # systemtest.c and sanitycheck.c are not .h file's 4 | # but they behaves like one, and need to be included 5 | # in the tarball. 6 | 7 | noinst_HEADERS = \ 8 | systemtest.c \ 9 | sanitycheck.c \ 10 | getopt.h \ 11 | ipc.h \ 12 | mach_port.h \ 13 | pThreadUtilities.h \ 14 | poll.h \ 15 | portaudio.h \ 16 | time.c \ 17 | time.h 18 | -------------------------------------------------------------------------------- /config/sysdeps/getopt.h: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_getopt_h_ 2 | #define _jack_sysdep_getopt_h_ 3 | 4 | #if defined(__MACH__) && defined(__APPLE__) 5 | #include 6 | #endif 7 | 8 | #endif /* _jack_sysdep_getopt_h_ */ 9 | -------------------------------------------------------------------------------- /config/sysdeps/ipc.h: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_ipc_h_ 2 | #define _jack_sysdep_ipc_h_ 3 | 4 | #if defined(__MACH__) && defined(__APPLE__) 5 | #include 6 | #else 7 | #include 8 | #endif 9 | 10 | #endif /* _jack_sysdep_ipc_h_ */ 11 | -------------------------------------------------------------------------------- /config/sysdeps/mach_port.h: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_mach_port_h_ 2 | #define _jack_sysdep_mach_port_h_ 3 | 4 | #if defined(__MACH__) && defined(__APPLE__) 5 | #include 6 | #endif 7 | 8 | #endif /* _jack_sysdep_mach_port_h_ */ 9 | -------------------------------------------------------------------------------- /config/sysdeps/pThreadUtilities.h: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_pThreadUtilities_h_ 2 | #define _jack_sysdep_pThreadUtilities_h_ 3 | 4 | #if defined(__MACH__) && defined(__APPLE__) 5 | #include 6 | #endif 7 | 8 | #endif /* _jack_sysdep_pThreadUtilities_h_ */ 9 | -------------------------------------------------------------------------------- /config/sysdeps/poll.h: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_poll_h_ 2 | #define _jack_sysdep_poll_h_ 3 | 4 | #if defined(__MACH__) && defined(__APPLE__) 5 | 6 | #include 7 | 8 | #else 9 | 10 | #include 11 | 12 | #endif 13 | 14 | #endif /* _jack_sysdep_poll_h_ */ 15 | -------------------------------------------------------------------------------- /config/sysdeps/portaudio.h: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_portaudio_h_ 2 | #define _jack_sysdep_portaudio_h_ 3 | 4 | #if defined(__MACH__) && defined(__APPLE__) 5 | #include 6 | #endif 7 | 8 | #endif /* _jack_sysdep_portaudio_h_ */ 9 | -------------------------------------------------------------------------------- /config/sysdeps/sanitycheck.c: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_sanitycheck_c_ 2 | #define _jack_sysdep_sanitycheck_c_ 3 | 4 | #if defined(__gnu_linux__) 5 | #include 6 | #elif defined(__MACH__) && defined(__APPLE__) 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #endif /* _jack_sysdep_sanitycheck_c_ */ 13 | -------------------------------------------------------------------------------- /config/sysdeps/systemtest.c: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_systemtest_c_ 2 | #define _jack_sysdep_systemtest_c_ 3 | 4 | #if defined(__gnu_linux__) 5 | #include 6 | #elif defined(__MACH__) && defined(__APPLE__) 7 | /* relax */ 8 | #else 9 | /* relax */ 10 | #endif 11 | 12 | #endif /* _jack_sysdep_systemtest_c_ */ 13 | -------------------------------------------------------------------------------- /config/sysdeps/time.c: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_time_c_ 2 | #define _jack_sysdep_time_c_ 3 | 4 | #if defined(__gnu_linux__) 5 | #include 6 | #elif defined(__MACH__) && defined(__APPLE__) 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #endif /* _jack_sysdep_time_c_ */ 13 | -------------------------------------------------------------------------------- /config/sysdeps/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _jack_sysdep_time_h_ 2 | #define _jack_sysdep_time_h_ 3 | 4 | #if defined(__gnu_linux__) 5 | #include 6 | #elif defined(__MACH__) && defined(__APPLE__) 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #endif /* _jack_sysdep_time_h_ */ 13 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | MAINTAINERCLEANFILES=Makefile.in 3 | 4 | CLEANFILES=doxygen-build.stamp 5 | 6 | DOX=reference.doxygen 7 | DOXSOURCES=mainpage.dox transport.dox porting.dox fsm.png fsm.eps \ 8 | ../jack/control.h \ 9 | ../jack/intclient.h \ 10 | ../jack/jack.h \ 11 | ../jack/jslist.h \ 12 | ../jack/metadata.h \ 13 | ../jack/midiport.h \ 14 | ../jack/ringbuffer.h \ 15 | ../jack/session.h \ 16 | ../jack/statistics.h \ 17 | ../jack/systemdeps.h \ 18 | ../jack/thread.h \ 19 | ../jack/transport.h \ 20 | ../jack/types.h \ 21 | ../jack/uuid.h \ 22 | ../jack/weakjack.h \ 23 | ../jack/weakmacros.h 24 | 25 | EXTRA_DIST=mainpage.dox transport.dox fsm.png fsm.eps porting.dox 26 | 27 | INSTIMAGES=reference/html/doxygen.png reference/html/fsm.png 28 | 29 | DOC_STAMPS=html-build.stamp 30 | 31 | DOC_DIR=$(HTML_DIR) 32 | 33 | all-local: doxygen-build.stamp 34 | 35 | doxygen-build.stamp: $(DOX) $(DOXSOURCES) 36 | @echo '*** Running doxygen ***' 37 | doxygen $(DOX) 38 | touch doxygen-build.stamp 39 | 40 | clean-local: 41 | rm -f *~ *.bak $(DOC_STAMPS) || true 42 | if test -d html; then rm -fr html; fi 43 | if test -d latex; then rm -fr latex; fi 44 | 45 | distclean-local: clean 46 | rm -f *.stamp || true 47 | if test -d reference; then rm -rf reference; fi 48 | 49 | install-data-local: 50 | $(mkinstalldirs) $(DESTDIR)$(DOC_DIR)/reference/html 51 | (installfiles=`echo reference/html/*.html`; \ 52 | if test "$$installfiles" = 'reference/html/*.html'; \ 53 | then echo '-- Nothing to install' ; \ 54 | else \ 55 | for i in $$installfiles $(INSTIMAGES) reference/html/doxygen.css; do \ 56 | echo '-- Installing '$$i ; \ 57 | $(INSTALL_DATA) $$i $(DESTDIR)$(DOC_DIR)/reference/html; \ 58 | done; \ 59 | fi) 60 | 61 | # we need doxygen stuff built so we can know what to uninstall 62 | uninstall-local: doxygen-build.stamp 63 | (installfiles=`echo reference/html/*.html`; \ 64 | if test "$$installfiles" = 'reference/html/*.html'; \ 65 | then echo '-- Nothing to uninstall' ; \ 66 | else \ 67 | for i in $$installfiles $(INSTIMAGES) reference/html/doxygen.css; do \ 68 | echo '-- Unstalling '$$i ; \ 69 | rm $(DESTDIR)$(DOC_DIR)/$$i; \ 70 | done; \ 71 | fi) 72 | 73 | dist-hook: dist-hook-local 74 | mkdir $(distdir)/reference 75 | mkdir $(distdir)/reference/html 76 | -cp reference/html/*.html reference/html/*.css \ 77 | reference/html/*.png $(distdir)/reference/html 78 | 79 | .PHONY : dist-hook-local 80 | -------------------------------------------------------------------------------- /doc/fsm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackaudio/jack1/ab2e7363cacd0bf4b961c0466c13b0b4c1086ed9/doc/fsm.png -------------------------------------------------------------------------------- /doc/porting.dox: -------------------------------------------------------------------------------- 1 | /* 2 | * This file documents the process of porting JACK to new platforms. 3 | * It is part of the JACK reference manual, built using doxygen. 4 | */ 5 | 6 | /** 7 | 8 | @page porting-guide Porting JACK 9 | 10 | The @ref index is designed to be portable to any system supporting the 11 | relevant POSIX and C language standards. It currently works with 12 | GNU/Linux and Mac OS X on several different processor architectures. 13 | This document describes the steps needed to port JACK to another 14 | platform, and the methods used to provide portability. 15 | 16 | - @ref portrequirements 17 | - @ref portoverview 18 | - @ref portopsys 19 | - @ref portcpu 20 | - @ref portissues 21 | 22 | @section portrequirements Requirements 23 | 24 | - Each platform should build directly from CVS or from a tarball 25 | using the GNU @c ./configure tools. Platform-specific toolsets can 26 | by used for development, but the GNU tools should at least work for 27 | basic distribution and configuration. 28 | 29 | - For long-term maintainability we want to minimize the use of 30 | conditional compilation in source files. 31 | 32 | - We should provide generic versions of all system-dependent 33 | headers, so platforms need only provide those they modify. 34 | 35 | - In some cases, operating system-specific information must be able 36 | to override processor-specific data. 37 | 38 | @section portoverview Overview 39 | 40 | JACK relies on two types of platform-specific headers: 41 | 42 | - @ref portopsys 43 | - @ref portcpu 44 | 45 | OS-specific headers take precedence over CPU-specific headers. 46 | 47 | The JACK @c configure.host script and its system-dependent header 48 | directories were adapted from the @c libstdc++-v3 component of the GNU 49 | Compiler Collective, . 50 | 51 | 52 | @section portlang C Language Dependencies 53 | 54 | JACK is written to conform with C99, as defined in International 55 | Standard ISO/IEC 9899:1999. Because many existing compilers do not 56 | fully support this standard, some new features should be avoided for 57 | portablility reasons. For example, variables should not be declared 58 | in the middle of a compound statement, because many compilers still 59 | cannot handle that language extension. 60 | 61 | 62 | @section portopsys Operating System Dependencies 63 | 64 | JACK is written for a POSIX environment compliant with IEEE Std 65 | 1003.1-2001, ISO/IEC 9945:2003, including the POSIX Threads Extension 66 | (1003.1c-1995) and the Realtime and Realtime Threads feature groups. 67 | When some needed POSIX feature is missing on a platform, the preferred 68 | solution is to provide a substitute, as with the @c fakepoll.c 69 | implementation for Mac OS X. 70 | 71 | Whenever possible, OS dependencies should be auto-detected by @c 72 | configure. Sometimes they can be isolated in OS-specific header 73 | files, found in subdirectories of @c config/os and referenced with a 74 | @c name. 75 | 76 | If conditional compilation must be used in mainline 77 | platform-independent code, avoid using the system name. Instead, @c 78 | \#define a descriptive name in @c , and test it like this: 79 | 80 | @code 81 | \#ifdef JACK_USE_MACH_THREADS 82 | allocate_mach_serverport(engine, client); 83 | client->running = FALSE; 84 | \#endif 85 | @endcode 86 | 87 | Be sure to place any generic implementation alternative in the @c 88 | \#else or use an @c \#ifndef, so no other code needs to know your 89 | conditional labels. 90 | 91 | @section portissues Issues Not Addressed 92 | 93 | - Cross-compilation has not been tested, or even thought through in 94 | much detail. The @a host is the system on which JACK will run. 95 | This may differ from the @a build system doing the compilation. 96 | These are selected using the standard @c ./configure options @c 97 | --host and @c --build. Usually, @c ./config.guess can print the 98 | appropriate canonical name for any system on which it runs. 99 | 100 | - Platform-specific build tools like Apple's Project Builder are not 101 | well-supported. 102 | 103 | */ 104 | -------------------------------------------------------------------------------- /drivers/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | 3 | if HAVE_ALSA 4 | ALSA_DIR = alsa 5 | else 6 | ALSA_DIR = 7 | endif 8 | 9 | if HAVE_ALSA_MIDI 10 | ALSA_MIDI_DIR = alsa_midi 11 | else 12 | ALSA_MIDI_DIR = 13 | endif 14 | 15 | if HAVE_OSS 16 | OSS_DIR = oss 17 | else 18 | OSS_DIR = 19 | endif 20 | 21 | if HAVE_SUN 22 | SUN_DIR = sun 23 | else 24 | SUN_DIR = 25 | endif 26 | 27 | if HAVE_PA 28 | PA_DIR = portaudio 29 | else 30 | PA_DIR = 31 | endif 32 | 33 | if HAVE_COREAUDIO 34 | CA_DIR = coreaudio 35 | else 36 | CA_DIR = 37 | endif 38 | 39 | if HAVE_FREEBOB 40 | FREEBOB_DIR = freebob 41 | else 42 | FREEBOB_DIR = 43 | endif 44 | 45 | if HAVE_FIREWIRE 46 | FIREWIRE_DIR = firewire 47 | else 48 | FIREWIRE_DIR = 49 | endif 50 | 51 | if HAVE_SNDIO 52 | SNDIO_DIR = sndio 53 | else 54 | SNDIO_DIR = 55 | endif 56 | 57 | SUBDIRS = $(ALSA_MIDI_DIR) $(ALSA_DIR) dummy $(OSS_DIR) $(SUN_DIR) $(PA_DIR) $(CA_DIR) $(FREEBOB_DIR) $(FIREWIRE_DIR) ${SNDIO_DIR} netjack 58 | DIST_SUBDIRS = alsa alsa_midi dummy oss sun portaudio coreaudio freebob firewire netjack sndio 59 | -------------------------------------------------------------------------------- /drivers/alsa/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES=Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_alsa.la 8 | 9 | jack_alsa_la_LDFLAGS = -module -avoid-version 10 | jack_alsa_la_SOURCES = alsa_driver.c generic_hw.c memops.c \ 11 | hammerfall.c hdsp.c ice1712.c usx2y.c 12 | 13 | noinst_HEADERS = alsa_driver.h \ 14 | generic.h \ 15 | hammerfall.h \ 16 | hdsp.h \ 17 | ice1712.h \ 18 | usx2y.h 19 | 20 | jack_alsa_la_LIBADD = $(ALSA_LIBS) $(top_builddir)/jackd/libjackserver.la 21 | 22 | 23 | noinst_LTLIBRARIES = libmemops.la 24 | 25 | libmemops_la_SOURCES = memops.c 26 | -------------------------------------------------------------------------------- /drivers/alsa/generic.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_generic_h__ 21 | #define __jack_generic_h__ 22 | 23 | jack_hardware_t * 24 | jack_alsa_generic_hw_new(alsa_driver_t *driver); 25 | 26 | #endif /* __jack_generic_h__*/ 27 | -------------------------------------------------------------------------------- /drivers/alsa/generic_hw.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #include "hardware.h" 21 | #include "alsa_driver.h" 22 | 23 | static int generic_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask) 24 | { 25 | return -1; 26 | } 27 | 28 | static int generic_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode) 29 | { 30 | return -1; 31 | } 32 | 33 | static void 34 | generic_release (jack_hardware_t *hw) 35 | { 36 | return; 37 | } 38 | 39 | jack_hardware_t * 40 | jack_alsa_generic_hw_new (alsa_driver_t *driver) 41 | 42 | { 43 | jack_hardware_t *hw; 44 | 45 | hw = (jack_hardware_t*)malloc (sizeof(jack_hardware_t)); 46 | 47 | hw->capabilities = 0; 48 | hw->input_monitor_mask = 0; 49 | 50 | hw->set_input_monitor_mask = generic_set_input_monitor_mask; 51 | hw->change_sample_clock = generic_change_sample_clock; 52 | hw->release = generic_release; 53 | 54 | return hw; 55 | } 56 | -------------------------------------------------------------------------------- /drivers/alsa/hammerfall.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_hammerfall_h__ 21 | #define __jack_hammerfall_h__ 22 | 23 | #include 24 | 25 | typedef struct { 26 | int lock_status[3]; 27 | int sync_status[3]; 28 | int said_that_spdif_is_fine; 29 | pthread_t monitor_thread; 30 | alsa_driver_t *driver; 31 | struct timespec monitor_interval; 32 | } hammerfall_t; 33 | 34 | jack_hardware_t *jack_alsa_hammerfall_hw_new(alsa_driver_t *driver); 35 | 36 | #endif /* __jack_hammerfall_h__*/ 37 | -------------------------------------------------------------------------------- /drivers/alsa/hdsp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_hdsp_h__ 21 | #define __jack_hdsp_h__ 22 | 23 | #include 24 | 25 | typedef struct { 26 | alsa_driver_t *driver; 27 | } hdsp_t; 28 | 29 | jack_hardware_t * 30 | jack_alsa_hdsp_hw_new(alsa_driver_t *driver); 31 | 32 | #endif /* __jack_hdsp_h__*/ 33 | -------------------------------------------------------------------------------- /drivers/alsa/ice1712.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Anthony Van Groningen 3 | 4 | Parts based on source code taken from the 5 | "Env24 chipset (ICE1712) control utility" that is 6 | 7 | Copyright (C) 2000 by Jaroslav Kysela 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | */ 23 | 24 | #include "hardware.h" 25 | #include "alsa_driver.h" 26 | #include "ice1712.h" 27 | #include "internal.h" 28 | 29 | static int 30 | ice1712_hw_monitor_toggle (jack_hardware_t *hw, int idx, int onoff) 31 | 32 | { 33 | ice1712_t *h = (ice1712_t*)hw->private; 34 | snd_ctl_elem_value_t *val; 35 | int err; 36 | 37 | snd_ctl_elem_value_alloca (&val); 38 | snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_MIXER); 39 | if (idx >= 8) { 40 | snd_ctl_elem_value_set_name (val, SPDIF_PLAYBACK_ROUTE_NAME); 41 | snd_ctl_elem_value_set_index (val, idx - 8); 42 | } else { 43 | snd_ctl_elem_value_set_name (val, ANALOG_PLAYBACK_ROUTE_NAME); 44 | snd_ctl_elem_value_set_index (val, idx); 45 | } 46 | if (onoff) { 47 | snd_ctl_elem_value_set_enumerated (val, 0, idx + 1); 48 | } else { 49 | snd_ctl_elem_value_set_enumerated (val, 0, 0); 50 | } 51 | if ((err = snd_ctl_elem_write (h->driver->ctl_handle, val)) != 0) { 52 | jack_error ("ALSA/ICE1712: (%d) cannot set input monitoring (%s)", 53 | idx, snd_strerror (err)); 54 | return -1; 55 | } 56 | 57 | return 0; 58 | } 59 | 60 | static int 61 | ice1712_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask) 62 | 63 | { 64 | int idx; 65 | ice1712_t *h = (ice1712_t*)hw->private; 66 | 67 | for (idx = 0; idx < 10; idx++) { 68 | if (h->active_channels & (1 << idx)) { 69 | ice1712_hw_monitor_toggle (hw, idx, mask & (1 << idx) ? 1 : 0); 70 | } 71 | } 72 | hw->input_monitor_mask = mask; 73 | 74 | return 0; 75 | } 76 | 77 | static int 78 | ice1712_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode) 79 | 80 | { 81 | return -1; 82 | } 83 | 84 | static void 85 | ice1712_release (jack_hardware_t *hw) 86 | { 87 | ice1712_t *h = (ice1712_t*)hw->private; 88 | 89 | if (h == 0) { 90 | return; 91 | } 92 | 93 | if (h->eeprom) { 94 | free (h->eeprom); 95 | } 96 | 97 | free (h); 98 | } 99 | 100 | 101 | jack_hardware_t * 102 | jack_alsa_ice1712_hw_new (alsa_driver_t *driver) 103 | 104 | { 105 | jack_hardware_t *hw; 106 | ice1712_t *h; 107 | snd_ctl_elem_value_t *val; 108 | int err; 109 | 110 | hw = (jack_hardware_t*)malloc (sizeof(jack_hardware_t)); 111 | 112 | hw->capabilities = Cap_HardwareMonitoring; 113 | hw->input_monitor_mask = 0; 114 | hw->private = 0; 115 | 116 | hw->set_input_monitor_mask = ice1712_set_input_monitor_mask; 117 | hw->change_sample_clock = ice1712_change_sample_clock; 118 | hw->release = ice1712_release; 119 | 120 | h = (ice1712_t*)malloc (sizeof(ice1712_t)); 121 | 122 | h->driver = driver; 123 | 124 | /* Get the EEPROM (adopted from envy24control) */ 125 | h->eeprom = (ice1712_eeprom_t*)malloc (sizeof(ice1712_eeprom_t)); 126 | snd_ctl_elem_value_alloca (&val); 127 | snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_CARD); 128 | snd_ctl_elem_value_set_name (val, "ICE1712 EEPROM"); 129 | if ((err = snd_ctl_elem_read (driver->ctl_handle, val)) < 0) { 130 | jack_error ( "ALSA/ICE1712: Unable to read EEPROM contents (%s)\n", snd_strerror (err)); 131 | /* Recover? */ 132 | } 133 | memcpy (h->eeprom, snd_ctl_elem_value_get_bytes (val), 32); 134 | 135 | /* determine number of pro ADC's. We're asumming that there is at least one stereo pair. 136 | Should check this first, but how? */ 137 | switch ((h->eeprom->codec & 0xCU) >> 2) { 138 | case 0: 139 | h->active_channels = 0x3U; 140 | break; 141 | case 1: 142 | h->active_channels = 0xfU; 143 | break; 144 | case 2: 145 | h->active_channels = 0x3fU; 146 | break; 147 | case 3: 148 | h->active_channels = 0xffU; 149 | break; 150 | } 151 | /* check for SPDIF In's */ 152 | if (h->eeprom->spdif & 0x1U) { 153 | h->active_channels |= 0x300U; 154 | } 155 | 156 | hw->private = h; 157 | 158 | return hw; 159 | } 160 | -------------------------------------------------------------------------------- /drivers/alsa/ice1712.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Anthony Van Groningen 3 | 4 | Parts based on source code taken from the 5 | "Env24 chipset (ICE1712) control utility" that is 6 | 7 | Copyright (C) 2000 by Jaroslav Kysela 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | 23 | */ 24 | 25 | #ifndef __jack_ice1712_h__ 26 | #define __jack_ice1712_h__ 27 | 28 | #define ICE1712_SUBDEVICE_DELTA44 0x121433d6 29 | #define ICE1712_SUBDEVICE_DELTA66 0x121432d6 30 | #define ICE1712_SUBDEVICE_DELTA1010 0x121430d6 31 | #define ICE1712_SUBDEVICE_DELTADIO2496 0x121431d6 32 | #define ICE1712_SUBDEVICE_AUDIOPHILE 0x121434d6 33 | 34 | #define SPDIF_PLAYBACK_ROUTE_NAME "IEC958 Playback Route" 35 | #define ANALOG_PLAYBACK_ROUTE_NAME "H/W Playback Route" 36 | #define MULTITRACK_PEAK_NAME "Multi Track Peak" 37 | 38 | typedef struct { 39 | unsigned int subvendor; /* PCI[2c-2f] */ 40 | unsigned char size; /* size of EEPROM image in bytes */ 41 | unsigned char version; /* must be 1 */ 42 | unsigned char codec; /* codec configuration PCI[60] */ 43 | unsigned char aclink; /* ACLink configuration PCI[61] */ 44 | unsigned char i2sID; /* PCI[62] */ 45 | unsigned char spdif; /* S/PDIF configuration PCI[63] */ 46 | unsigned char gpiomask; /* GPIO initial mask, 0 = write, 1 = don't */ 47 | unsigned char gpiostate; /* GPIO initial state */ 48 | unsigned char gpiodir; /* GPIO direction state */ 49 | unsigned short ac97main; 50 | unsigned short ac97pcm; 51 | unsigned short ac97rec; 52 | unsigned char ac97recsrc; 53 | unsigned char dacID[4]; /* I2S IDs for DACs */ 54 | unsigned char adcID[4]; /* I2S IDs for ADCs */ 55 | unsigned char extra[4]; 56 | } ice1712_eeprom_t; 57 | 58 | typedef struct { 59 | alsa_driver_t *driver; 60 | ice1712_eeprom_t *eeprom; 61 | unsigned long active_channels; 62 | } ice1712_t; 63 | 64 | jack_hardware_t *jack_alsa_ice1712_hw_new(alsa_driver_t *driver); 65 | 66 | #endif /* __jack_ice1712_h__*/ 67 | -------------------------------------------------------------------------------- /drivers/alsa/usx2y.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001 Paul Davis 3 | Copyright (C) 2004 Karsten Wiese, Rui Nuno Capela 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 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 General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | */ 20 | 21 | #ifndef __jack_usx2y_h__ 22 | #define __jack_usx2y_h__ 23 | 24 | #define USX2Y_MAXPACK 50 25 | #define USX2Y_MAXBUFFERMS 100 26 | #define USX2Y_MAXSTRIDE 3 27 | 28 | #define USX2Y_SSS (((USX2Y_MAXPACK * USX2Y_MAXBUFFERMS * USX2Y_MAXSTRIDE + 4096) / 4096) * 4096) 29 | 30 | struct snd_usX2Y_hwdep_pcm_shm { 31 | char playback[USX2Y_SSS]; 32 | char capture0x8[USX2Y_SSS]; 33 | char capture0xA[USX2Y_SSS]; 34 | volatile int playback_iso_head; 35 | int playback_iso_start; 36 | struct { 37 | int frame, 38 | offset, 39 | length; 40 | } captured_iso[128]; 41 | volatile int captured_iso_head; 42 | volatile unsigned captured_iso_frames; 43 | int capture_iso_start; 44 | }; 45 | typedef struct snd_usX2Y_hwdep_pcm_shm snd_usX2Y_hwdep_pcm_shm_t; 46 | 47 | typedef struct { 48 | alsa_driver_t *driver; 49 | snd_hwdep_t *hwdep_handle; 50 | struct pollfd pfds; 51 | struct snd_usX2Y_hwdep_pcm_shm *hwdep_pcm_shm; 52 | int playback_iso_start; 53 | int playback_iso_bytes_done; 54 | int capture_iso_start; 55 | int capture_iso_bytes_done; 56 | } usx2y_t; 57 | 58 | jack_hardware_t * 59 | jack_alsa_usx2y_hw_new(alsa_driver_t *driver); 60 | 61 | #endif /* __jack_usx2y_h__*/ 62 | -------------------------------------------------------------------------------- /drivers/alsa_midi/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | 3 | # 4 | # slave driver to bridge to ALSA (sequencer) MIDI 5 | # 6 | 7 | driverdir = $(ADDON_DIR) 8 | 9 | driver_LTLIBRARIES = jack_alsa_midi.la 10 | 11 | jack_alsa_midi_la_LDFLAGS = -module -avoid-version @OS_LDFLAGS@ 12 | jack_alsa_midi_la_SOURCES = alsa_midi.c port.c port_hash.c port_thread.c list.c 13 | jack_alsa_midi_la_LIBADD = $(ALSA_LIBS) 14 | 15 | noinst_HEADERS = a2j.h list.h port.h port_hash.h port_thread.h midi_pack.h midi_unpack.h 16 | 17 | 18 | -------------------------------------------------------------------------------- /drivers/alsa_midi/a2j.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ 2 | /* 3 | * ALSA SEQ < - > JACK MIDI bridge 4 | * 5 | * Copyright (c) 2006,2007 Dmitry S. Baikov 6 | * Copyright (c) 2007,2008,2009 Nedko Arnaudov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; version 2 of the License. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef __jack_alsa_midi_h__ 23 | #define __jack_alsa_midi_h__ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "driver.h" 31 | #include "list.h" 32 | 33 | #define JACK_INVALID_PORT NULL 34 | 35 | #define MAX_PORTS 2048 36 | #define MAX_EVENT_SIZE 1024 37 | 38 | #define PORT_HASH_BITS 4 39 | #define PORT_HASH_SIZE (1 << PORT_HASH_BITS) 40 | 41 | /* Beside enum use, these are indeces for (struct a2j).stream array */ 42 | #define A2J_PORT_CAPTURE 0 // ALSA playback port -> JACK capture port 43 | #define A2J_PORT_PLAYBACK 1 // JACK playback port -> ALSA capture port 44 | 45 | typedef struct a2j_port * a2j_port_hash_t[PORT_HASH_SIZE]; 46 | 47 | struct alsa_midi_driver; 48 | 49 | struct a2j_port { 50 | struct a2j_port * next; /* hash - jack */ 51 | struct list_head siblings; /* list - main loop */ 52 | struct alsa_midi_driver * driver_ptr; 53 | bool is_dead; 54 | char name[64]; 55 | snd_seq_addr_t remote; 56 | jack_port_t * jack_port; 57 | 58 | jack_ringbuffer_t * inbound_events; // alsa_midi_event_t + data 59 | int64_t last_out_time; 60 | 61 | void * jack_buf; 62 | }; 63 | 64 | struct a2j_stream { 65 | snd_midi_event_t *codec; 66 | 67 | jack_ringbuffer_t *new_ports; 68 | 69 | a2j_port_hash_t port_hash; 70 | struct list_head list; 71 | }; 72 | 73 | typedef struct alsa_midi_driver { 74 | JACK_DRIVER_DECL; 75 | 76 | jack_client_t * jack_client; 77 | 78 | snd_seq_t *seq; 79 | pthread_t alsa_input_thread; 80 | pthread_t alsa_output_thread; 81 | int client_id; 82 | int port_id; 83 | int queue; 84 | bool freewheeling; 85 | bool running; 86 | bool finishing; 87 | 88 | jack_ringbuffer_t* port_del; // struct a2j_port* 89 | jack_ringbuffer_t* outbound_events; // struct a2j_delivery_event 90 | jack_nframes_t cycle_start; 91 | 92 | sem_t output_semaphore; 93 | 94 | struct a2j_stream stream[2]; 95 | 96 | } alsa_midi_driver_t; 97 | 98 | #define NSEC_PER_SEC ((int64_t)1000 * 1000 * 1000) 99 | 100 | struct a2j_alsa_midi_event { 101 | int64_t time; 102 | int size; 103 | }; 104 | 105 | #define MAX_JACKMIDI_EV_SIZE 64 106 | 107 | struct a2j_delivery_event { 108 | struct list_head siblings; 109 | 110 | /* a jack MIDI event, plus the port its destined for: everything 111 | the ALSA output thread needs to deliver the event. time is 112 | part of the jack_event. 113 | */ 114 | jack_midi_event_t jack_event; 115 | jack_nframes_t time; /* realtime, not offset time */ 116 | struct a2j_port* port; 117 | char midistring[MAX_JACKMIDI_EV_SIZE]; 118 | }; 119 | 120 | void a2j_error(const char* fmt, ...); 121 | 122 | #define A2J_DEBUG 123 | /*#undef A2J_DEBUG*/ 124 | 125 | #ifdef A2J_DEBUG 126 | extern bool a2j_do_debug; 127 | extern void _a2j_debug(const char* fmt, ...); 128 | #define a2j_debug(fmt, ...) if (a2j_do_debug) { _a2j_debug ((fmt), ## __VA_ARGS__); } 129 | #else 130 | #define a2j_debug(fmt, ...) 131 | #endif 132 | 133 | #endif /* __jack_alsa_midi_h__ */ 134 | -------------------------------------------------------------------------------- /drivers/alsa_midi/alsa_midi_driver.c: -------------------------------------------------------------------------------- 1 | 2 | #include "alsa_midi.h" 3 | #include 4 | 5 | static int 6 | alsa_midi_driver_attach ( alsa_midi_driver_t *driver, jack_engine_t *engine ) 7 | { 8 | return driver->midi->attach (driver->midi); 9 | } 10 | 11 | static int 12 | alsa_midi_driver_detach ( alsa_midi_driver_t *driver, jack_engine_t *engine ) 13 | { 14 | return driver->midi->detach (driver->midi); 15 | } 16 | 17 | static int 18 | alsa_midi_driver_read ( alsa_midi_driver_t *driver, jack_nframes_t nframes ) 19 | { 20 | driver->midi->read (driver->midi, nframes); 21 | return 0; 22 | } 23 | 24 | static int 25 | alsa_midi_driver_write ( alsa_midi_driver_t *driver, jack_nframes_t nframes ) 26 | { 27 | driver->midi->write (driver->midi, nframes); 28 | return 0; 29 | } 30 | 31 | static int 32 | alsa_midi_driver_start ( alsa_midi_driver_t *driver ) 33 | { 34 | return driver->midi->start (driver->midi); 35 | } 36 | 37 | static int 38 | alsa_midi_driver_stop ( alsa_midi_driver_t *driver ) 39 | { 40 | return driver->midi->stop (driver->midi); 41 | } 42 | 43 | static void 44 | alsa_midi_driver_delete ( alsa_midi_driver_t *driver ) 45 | { 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /drivers/alsa_midi/list.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ 2 | /***************************************************************************** 3 | * 4 | * list_sort() adapted from linux kernel. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; version 2 of the License 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 General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 | * 19 | *****************************************************************************/ 20 | 21 | #include 22 | 23 | #include "list.h" 24 | 25 | /* list sort from Mark J Roberts (mjr@znex.org) */ 26 | void 27 | __list_sort ( 28 | struct list_head *head, 29 | int member_offset, 30 | int (*cmp)(void * a, void * b)) 31 | { 32 | struct list_head *p, *q, *e, *list, *tail, *oldhead; 33 | int insize, nmerges, psize, qsize, i; 34 | 35 | list = head->next; 36 | list_del (head); 37 | insize = 1; 38 | for (;; ) { 39 | p = oldhead = list; 40 | list = tail = NULL; 41 | nmerges = 0; 42 | 43 | while (p) { 44 | nmerges++; 45 | q = p; 46 | psize = 0; 47 | for (i = 0; i < insize; i++) { 48 | psize++; 49 | q = q->next == oldhead ? NULL : q->next; 50 | if (!q) { 51 | break; 52 | } 53 | } 54 | 55 | qsize = insize; 56 | while (psize > 0 || (qsize > 0 && q)) { 57 | if (!psize) { 58 | e = q; 59 | q = q->next; 60 | qsize--; 61 | if (q == oldhead) { 62 | q = NULL; 63 | } 64 | } else if (!qsize || !q) { 65 | e = p; 66 | p = p->next; 67 | psize--; 68 | if (p == oldhead) { 69 | p = NULL; 70 | } 71 | } else if (cmp ((void*)p - member_offset, (void*)q - member_offset) <= 0) { 72 | e = p; 73 | p = p->next; 74 | psize--; 75 | if (p == oldhead) { 76 | p = NULL; 77 | } 78 | } else { 79 | e = q; 80 | q = q->next; 81 | qsize--; 82 | if (q == oldhead) { 83 | q = NULL; 84 | } 85 | } 86 | if (tail) { 87 | tail->next = e; 88 | } else { 89 | list = e; 90 | } 91 | e->prev = tail; 92 | tail = e; 93 | } 94 | p = q; 95 | } 96 | 97 | tail->next = list; 98 | list->prev = tail; 99 | 100 | if (nmerges <= 1) { 101 | break; 102 | } 103 | 104 | insize *= 2; 105 | } 106 | 107 | head->next = list; 108 | head->prev = list->prev; 109 | list->prev->next = head; 110 | list->prev = head; 111 | } 112 | 113 | struct test_list_el { 114 | int value; 115 | struct list_head test_list_node; 116 | }; 117 | 118 | int test_list_sort_comparator (struct test_list_el * e1, struct test_list_el * e2) 119 | { 120 | return e1->value - e2->value; 121 | } 122 | 123 | void test_list_sort (void) 124 | { 125 | struct list_head test_list; 126 | struct test_list_el *el, *next; 127 | struct test_list_el te1 = { .value = 1 }; 128 | struct test_list_el te2 = { .value = 2 }; 129 | struct test_list_el te3 = { .value = 3 }; 130 | struct test_list_el te4 = { .value = 4 }; 131 | struct test_list_el te5 = { .value = 5 }; 132 | struct test_list_el te6 = { .value = 6 }; 133 | struct test_list_el te7 = { .value = 7 }; 134 | 135 | const int expected[] = { 1, 2, 3, 4, 5, 6, 7 }; 136 | int i; 137 | 138 | INIT_LIST_HEAD (&test_list); 139 | list_add_tail (&te2.test_list_node, &test_list); 140 | list_add_tail (&te6.test_list_node, &test_list); 141 | list_add_tail (&te4.test_list_node, &test_list); 142 | list_add_tail (&te5.test_list_node, &test_list); 143 | list_add_tail (&te7.test_list_node, &test_list); 144 | list_add_tail (&te1.test_list_node, &test_list); 145 | list_add_tail (&te3.test_list_node, &test_list); 146 | 147 | list_sort (&test_list, struct test_list_el, test_list_node, test_list_sort_comparator); 148 | 149 | i = 0; 150 | list_for_each_entry_safe (el, next, &test_list, test_list_node) { 151 | assert (el->value == expected[i]); 152 | i++; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /drivers/alsa_midi/midi_pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006,2007 Dmitry S. Baikov 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __jack_midi_pack_h__ 20 | #define __jack_midi_pack_h__ 21 | 22 | #include 23 | #include "engine.h" 24 | 25 | typedef struct { 26 | int running_status; 27 | } midi_pack_t; 28 | 29 | static inline 30 | void midi_pack_reset (midi_pack_t *p) 31 | { 32 | p->running_status = 0; 33 | } 34 | 35 | static 36 | void midi_pack_event (midi_pack_t *p, jack_midi_event_t *e) 37 | { 38 | if (e->buffer[0] >= 0x80 && e->buffer[0] < 0xF0) { // Voice Message 39 | if (e->buffer[0] == p->running_status) { 40 | e->buffer++; 41 | e->size--; 42 | } else { 43 | p->running_status = e->buffer[0]; 44 | } 45 | } else if (e->buffer[0] < 0xF8) { // not System Realtime 46 | p->running_status = 0; 47 | } 48 | } 49 | 50 | #endif /* __jack_midi_pack_h__ */ 51 | -------------------------------------------------------------------------------- /drivers/alsa_midi/midi_unpack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006,2007 Dmitry S. Baikov 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __jack_midi_unpack_h__ 20 | #define __jack_midi_unpack_h__ 21 | 22 | #include 23 | #include "engine.h" 24 | 25 | enum { 26 | MIDI_UNPACK_MAX_MSG = 1024 27 | }; 28 | 29 | typedef struct { 30 | int pos, need, size; 31 | unsigned char data[MIDI_UNPACK_MAX_MSG]; 32 | } midi_unpack_t; 33 | 34 | static inline 35 | void midi_unpack_init (midi_unpack_t *u) 36 | { 37 | u->pos = 0; 38 | u->size = sizeof(u->data); 39 | u->need = u->size; 40 | } 41 | 42 | static inline 43 | void midi_unpack_reset (midi_unpack_t *u) 44 | { 45 | u->pos = 0; 46 | u->need = u->size; 47 | } 48 | 49 | static const unsigned char midi_voice_len[] = { 50 | 3, /*0x80 Note Off*/ 51 | 3, /*0x90 Note On*/ 52 | 3, /*0xA0 Aftertouch*/ 53 | 3, /*0xB0 Control Change*/ 54 | 2, /*0xC0 Program Change*/ 55 | 2, /*0xD0 Channel Pressure*/ 56 | 3, /*0xE0 Pitch Wheel*/ 57 | 1 /*0xF0 System*/ 58 | }; 59 | 60 | static const unsigned char midi_system_len[] = { 61 | 0, /*0xF0 System Exclusive Start*/ 62 | 2, /*0xF1 MTC Quarter Frame*/ 63 | 3, /*0xF2 Song Postion*/ 64 | 2, /*0xF3 Song Select*/ 65 | 0, /*0xF4 undefined*/ 66 | 0, /*0xF5 undefined*/ 67 | 1, /*0xF6 Tune Request*/ 68 | 1 /*0xF7 System Exlusive End*/ 69 | }; 70 | 71 | static 72 | int midi_unpack_buf (midi_unpack_t *buf, const unsigned char *data, int len, void *jack_port_buf, jack_nframes_t time) 73 | { 74 | int i; 75 | 76 | for (i = 0; i < len; ++i) { 77 | const unsigned char byte = data[i]; 78 | if (byte >= 0xF8) { // system realtime 79 | jack_midi_event_write (jack_port_buf, time, &data[i], 1); 80 | //jack_error("midi_unpack: written system relatime event\n"); 81 | //midi_input_write(in, &data[i], 1); 82 | } else if (byte < 0x80) { // data 83 | assert (buf->pos < buf->size); 84 | buf->data[buf->pos++] = byte; 85 | } else if (byte < 0xF0) { // voice 86 | assert (byte >= 0x80 && byte < 0xF0); 87 | //buf->need = ((byte|0x0F) == 0xCF || (byte|0x0F)==0xDF) ? 2 : 3; 88 | buf->need = midi_voice_len[(byte - 0x80) >> 4]; 89 | buf->data[0] = byte; 90 | buf->pos = 1; 91 | } else if (byte == 0xF7) { // sysex end 92 | assert (buf->pos < buf->size); 93 | buf->data[buf->pos++] = byte; 94 | buf->need = buf->pos; 95 | } else { 96 | assert (byte >= 0xF0 && byte < 0xF8); 97 | buf->pos = 1; 98 | buf->data[0] = byte; 99 | buf->need = midi_system_len[byte - 0xF0]; 100 | if (!buf->need) { 101 | buf->need = buf->size; 102 | } 103 | } 104 | if (buf->pos == buf->need) { 105 | // TODO: deal with big sysex'es (they are silently dropped for now) 106 | if (buf->data[0] >= 0x80 || (buf->data[0] == 0xF0 && buf->data[buf->pos - 1] == 0xF7)) { 107 | /* convert Note On with velocity 0 to Note Off */ 108 | if ((buf->data[0] & 0xF0) == 0x90 && buf->data[2] == 0) { 109 | // we use temp array here to keep running status in sync 110 | jack_midi_data_t temp[3] = { 0x80, 0, 0x40 }; 111 | temp[0] |= buf->data[0] & 0x0F; 112 | temp[1] = buf->data[1]; 113 | jack_midi_event_write (jack_port_buf, time, temp, 3); 114 | } else { 115 | jack_midi_event_write (jack_port_buf, time, &buf->data[0], buf->pos); 116 | } 117 | //jack_error("midi_unpack: written %d-byte event\n", buf->pos); 118 | //midi_input_write(in, &buf->data[0], buf->pos); 119 | } 120 | /* keep running status */ 121 | if (buf->data[0] >= 0x80 && buf->data[0] < 0xF0) { 122 | buf->pos = 1; 123 | } else { 124 | buf->pos = 0; 125 | buf->need = buf->size; 126 | } 127 | } 128 | } 129 | assert (i == len); 130 | return i; 131 | } 132 | 133 | #endif /* __jack_midi_unpack_h__ */ 134 | -------------------------------------------------------------------------------- /drivers/alsa_midi/port.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ 2 | /* 3 | * ALSA SEQ < - > JACK MIDI bridge 4 | * 5 | * Copyright (c) 2006,2007 Dmitry S. Baikov 6 | * Copyright (c) 2007,2008,2009 Nedko Arnaudov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; version 2 of the License. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef PORT_H__757ADD0F_5E53_41F7_8B7F_8119C5E8A9F1__INCLUDED 23 | #define PORT_H__757ADD0F_5E53_41F7_8B7F_8119C5E8A9F1__INCLUDED 24 | 25 | struct a2j_port* a2j_port_create(alsa_midi_driver_t* driver, int dir, snd_seq_addr_t addr, const snd_seq_port_info_t * info); 26 | void a2j_port_setdead(a2j_port_hash_t hash, snd_seq_addr_t addr); 27 | void a2j_port_free(struct a2j_port * port); 28 | 29 | #endif /* #ifndef PORT_H__757ADD0F_5E53_41F7_8B7F_8119C5E8A9F1__INCLUDED */ 30 | -------------------------------------------------------------------------------- /drivers/alsa_midi/port_hash.c: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ 2 | /* 3 | * ALSA SEQ < - > JACK MIDI bridge 4 | * 5 | * Copyright (c) 2006,2007 Dmitry S. Baikov 6 | * Copyright (c) 2007,2008,2009 Nedko Arnaudov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; version 2 of the License. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "list.h" 29 | #include "a2j.h" 30 | #include "port_hash.h" 31 | 32 | static inline 33 | int 34 | a2j_port_hash ( 35 | snd_seq_addr_t addr) 36 | { 37 | return (addr.client + addr.port) % PORT_HASH_SIZE; 38 | } 39 | 40 | struct a2j_port * 41 | a2j_port_get ( 42 | a2j_port_hash_t hash, 43 | snd_seq_addr_t addr) 44 | { 45 | struct a2j_port **pport = &hash[a2j_port_hash (addr)]; 46 | 47 | while (*pport) { 48 | struct a2j_port *port = *pport; 49 | if (port->remote.client == addr.client && port->remote.port == addr.port) { 50 | return port; 51 | } 52 | pport = &port->next; 53 | } 54 | return NULL; 55 | } 56 | 57 | void 58 | a2j_port_insert ( 59 | a2j_port_hash_t hash, 60 | struct a2j_port * port) 61 | { 62 | struct a2j_port **pport = &hash[a2j_port_hash (port->remote)]; 63 | 64 | port->next = *pport; 65 | *pport = port; 66 | } 67 | -------------------------------------------------------------------------------- /drivers/alsa_midi/port_hash.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ 2 | /* 3 | * ALSA SEQ < - > JACK MIDI bridge 4 | * 5 | * Copyright (c) 2006,2007 Dmitry S. Baikov 6 | * Copyright (c) 2007,2008,2009 Nedko Arnaudov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; version 2 of the License. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef PORT_HASH_H__A44CBCD6_E075_49CB_8F73_DF9772511D55__INCLUDED 23 | #define PORT_HASH_H__A44CBCD6_E075_49CB_8F73_DF9772511D55__INCLUDED 24 | 25 | void 26 | a2j_port_insert( 27 | a2j_port_hash_t hash, 28 | struct a2j_port * port); 29 | 30 | struct a2j_port * 31 | a2j_port_get( 32 | a2j_port_hash_t hash, 33 | snd_seq_addr_t addr); 34 | 35 | #endif /* #ifndef PORT_HASH_H__A44CBCD6_E075_49CB_8F73_DF9772511D55__INCLUDED */ 36 | -------------------------------------------------------------------------------- /drivers/alsa_midi/port_thread.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ 2 | /* 3 | * ALSA SEQ < - > JACK MIDI bridge 4 | * 5 | * Copyright (c) 2006,2007 Dmitry S. Baikov 6 | * Copyright (c) 2007,2008,2009 Nedko Arnaudov 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; version 2 of the License. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef PORT_THREAD_H__1C6B5065_5556_4AC6_AA9F_44C32A9648C6__INCLUDED 23 | #define PORT_THREAD_H__1C6B5065_5556_4AC6_AA9F_44C32A9648C6__INCLUDED 24 | 25 | void a2j_update_port(alsa_midi_driver_t* driver, snd_seq_addr_t addr, const snd_seq_port_info_t* info); 26 | void a2j_update_ports(alsa_midi_driver_t* driver, snd_seq_addr_t addr); 27 | void a2j_new_ports(alsa_midi_driver_t* driver, snd_seq_addr_t addr); 28 | void a2j_free_ports(alsa_midi_driver_t* driver); 29 | struct a2j_port * a2j_find_port_by_addr(struct a2j_stream * stream_ptr, snd_seq_addr_t addr); 30 | struct a2j_port * a2j_find_port_by_jack_port_name(struct a2j_stream * stream_ptr, const char * jack_port); 31 | 32 | #endif /* #ifndef PORT_THREAD_H__1C6B5065_5556_4AC6_AA9F_44C32A9648C6__INCLUDED */ 33 | -------------------------------------------------------------------------------- /drivers/am/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES=Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_alsa_midi.la 8 | 9 | jack_alsa_midi_la_LDFLAGS = -module -avoid-version 10 | jack_alsa_midi_la_SOURCES = alsa_rawmidi.c alsa_seqmidi.c alsa_midi_driver.c 11 | 12 | noinst_HEADERS = alsa_midi.h \ 13 | midi_pack.h \ 14 | midi_unpack.h 15 | 16 | jack_alsa_midi_la_LIBADD = $(ALSA_LIBS) 17 | -------------------------------------------------------------------------------- /drivers/am/alsa_midi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Dmitry S. Baikov 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __jack_alsa_midi_h__ 20 | #define __jack_alsa_midi_h__ 21 | 22 | #include 23 | #include "driver.h" 24 | 25 | typedef struct alsa_midi_t alsa_midi_t; 26 | struct alsa_midi_t { 27 | void (*destroy)(alsa_midi_t *amidi); 28 | int (*attach)(alsa_midi_t *amidi); 29 | int (*detach)(alsa_midi_t *amidi); 30 | int (*start)(alsa_midi_t *amidi); 31 | int (*stop)(alsa_midi_t *amidi); 32 | void (*read)(alsa_midi_t *amidi, jack_nframes_t nframes); 33 | void (*write)(alsa_midi_t *amidi, jack_nframes_t nframes); 34 | }; 35 | 36 | alsa_midi_t* alsa_rawmidi_new(jack_client_t *jack); 37 | alsa_midi_t* alsa_seqmidi_new(jack_client_t *jack, const char* alsa_name); 38 | 39 | typedef struct _alsa_midi_driver { 40 | 41 | JACK_DRIVER_DECL; 42 | 43 | alsa_midi_t *midi; 44 | jack_client_t *client; 45 | 46 | } alsa_midi_driver_t; 47 | 48 | #endif /* __jack_alsa_midi_h__ */ 49 | -------------------------------------------------------------------------------- /drivers/am/alsa_midi_driver.c: -------------------------------------------------------------------------------- 1 | 2 | #include "alsa_midi.h" 3 | #include 4 | 5 | static int 6 | alsa_midi_driver_attach ( alsa_midi_driver_t *driver, jack_engine_t *engine ) 7 | { 8 | return driver->midi->attach (driver->midi); 9 | } 10 | 11 | static int 12 | alsa_midi_driver_detach ( alsa_midi_driver_t *driver, jack_engine_t *engine ) 13 | { 14 | return driver->midi->detach (driver->midi); 15 | } 16 | 17 | static int 18 | alsa_midi_driver_read ( alsa_midi_driver_t *driver, jack_nframes_t nframes ) 19 | { 20 | driver->midi->read (driver->midi, nframes); 21 | return 0; 22 | } 23 | 24 | static int 25 | alsa_midi_driver_write ( alsa_midi_driver_t *driver, jack_nframes_t nframes ) 26 | { 27 | driver->midi->write (driver->midi, nframes); 28 | return 0; 29 | } 30 | 31 | static int 32 | alsa_midi_driver_start ( alsa_midi_driver_t *driver ) 33 | { 34 | return driver->midi->start (driver->midi); 35 | } 36 | 37 | static int 38 | alsa_midi_driver_stop ( alsa_midi_driver_t *driver ) 39 | { 40 | return driver->midi->stop (driver->midi); 41 | } 42 | 43 | static void 44 | alsa_midi_driver_delete ( alsa_midi_driver_t *driver ) 45 | { 46 | if (driver->midi) { 47 | (driver->midi->destroy)(driver->midi); 48 | } 49 | 50 | free (driver); 51 | } 52 | 53 | static jack_driver_t * 54 | alsa_midi_driver_new (jack_client_t *client, const char *name) 55 | { 56 | alsa_midi_driver_t *driver; 57 | 58 | jack_info ("creating alsa_midi driver ..."); 59 | 60 | driver = (alsa_midi_driver_t*)calloc (1, sizeof(alsa_midi_driver_t)); 61 | 62 | jack_driver_init ((jack_driver_t*)driver); 63 | 64 | driver->attach = (JackDriverAttachFunction)alsa_midi_driver_attach; 65 | driver->detach = (JackDriverDetachFunction)alsa_midi_driver_detach; 66 | driver->read = (JackDriverReadFunction)alsa_midi_driver_read; 67 | driver->write = (JackDriverWriteFunction)alsa_midi_driver_write; 68 | driver->start = (JackDriverStartFunction)alsa_midi_driver_start; 69 | driver->stop = (JackDriverStartFunction)alsa_midi_driver_stop; 70 | 71 | 72 | driver->midi = alsa_seqmidi_new (client, NULL); 73 | driver->client = client; 74 | 75 | return (jack_driver_t*)driver; 76 | } 77 | 78 | /* DRIVER "PLUGIN" INTERFACE */ 79 | 80 | const char driver_client_name[] = "alsa_midi"; 81 | 82 | const jack_driver_desc_t * 83 | driver_get_descriptor () 84 | { 85 | jack_driver_desc_t * desc; 86 | jack_driver_param_desc_t * params; 87 | 88 | //unsigned int i; 89 | 90 | desc = calloc (1, sizeof(jack_driver_desc_t)); 91 | 92 | strcpy (desc->name, "alsa_midi"); 93 | desc->nparams = 0; 94 | 95 | params = calloc (desc->nparams, sizeof(jack_driver_param_desc_t)); 96 | 97 | desc->params = params; 98 | 99 | return desc; 100 | } 101 | 102 | jack_driver_t * 103 | driver_initialize (jack_client_t *client, const JSList * params) 104 | { 105 | const JSList * node; 106 | const jack_driver_param_t * param; 107 | 108 | for (node = params; node; node = jack_slist_next (node)) { 109 | param = (const jack_driver_param_t*)node->data; 110 | 111 | switch (param->character) { 112 | default: 113 | break; 114 | } 115 | } 116 | 117 | return alsa_midi_driver_new (client, NULL); 118 | } 119 | 120 | void 121 | driver_finish (jack_driver_t *driver) 122 | { 123 | alsa_midi_driver_delete ((alsa_midi_driver_t*)driver); 124 | } 125 | -------------------------------------------------------------------------------- /drivers/am/midi_pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006,2007 Dmitry S. Baikov 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __jack_midi_pack_h__ 20 | #define __jack_midi_pack_h__ 21 | 22 | #include 23 | #include "engine.h" 24 | 25 | typedef struct { 26 | int running_status; 27 | } midi_pack_t; 28 | 29 | static inline 30 | void midi_pack_reset (midi_pack_t *p) 31 | { 32 | p->running_status = 0; 33 | } 34 | 35 | static 36 | void midi_pack_event (midi_pack_t *p, jack_midi_event_t *e) 37 | { 38 | if (e->buffer[0] >= 0x80 && e->buffer[0] < 0xF0) { // Voice Message 39 | if (e->buffer[0] == p->running_status) { 40 | e->buffer++; 41 | e->size--; 42 | } else { 43 | p->running_status = e->buffer[0]; 44 | } 45 | } else if (e->buffer[0] < 0xF8) { // not System Realtime 46 | p->running_status = 0; 47 | } 48 | } 49 | 50 | #endif /* __jack_midi_pack_h__ */ 51 | -------------------------------------------------------------------------------- /drivers/am/midi_unpack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006,2007 Dmitry S. Baikov 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __jack_midi_unpack_h__ 20 | #define __jack_midi_unpack_h__ 21 | 22 | #include 23 | #include "engine.h" 24 | 25 | enum { 26 | MIDI_UNPACK_MAX_MSG = 1024 27 | }; 28 | 29 | typedef struct { 30 | int pos, need, size; 31 | unsigned char data[MIDI_UNPACK_MAX_MSG]; 32 | } midi_unpack_t; 33 | 34 | static inline 35 | void midi_unpack_init (midi_unpack_t *u) 36 | { 37 | u->pos = 0; 38 | u->size = sizeof(u->data); 39 | u->need = u->size; 40 | } 41 | 42 | static inline 43 | void midi_unpack_reset (midi_unpack_t *u) 44 | { 45 | u->pos = 0; 46 | u->need = u->size; 47 | } 48 | 49 | static const unsigned char midi_voice_len[] = { 50 | 3, /*0x80 Note Off*/ 51 | 3, /*0x90 Note On*/ 52 | 3, /*0xA0 Aftertouch*/ 53 | 3, /*0xB0 Control Change*/ 54 | 2, /*0xC0 Program Change*/ 55 | 2, /*0xD0 Channel Pressure*/ 56 | 3, /*0xE0 Pitch Wheel*/ 57 | 1 /*0xF0 System*/ 58 | }; 59 | 60 | static const unsigned char midi_system_len[] = { 61 | 0, /*0xF0 System Exclusive Start*/ 62 | 2, /*0xF1 MTC Quarter Frame*/ 63 | 3, /*0xF2 Song Postion*/ 64 | 2, /*0xF3 Song Select*/ 65 | 0, /*0xF4 undefined*/ 66 | 0, /*0xF5 undefined*/ 67 | 1, /*0xF6 Tune Request*/ 68 | 1 /*0xF7 System Exlusive End*/ 69 | }; 70 | 71 | static 72 | int midi_unpack_buf (midi_unpack_t *buf, const unsigned char *data, int len, void *jack_port_buf, jack_nframes_t time) 73 | { 74 | int i; 75 | 76 | for (i = 0; i < len; ++i) { 77 | const unsigned char byte = data[i]; 78 | if (byte >= 0xF8) { // system realtime 79 | jack_midi_event_write (jack_port_buf, time, &data[i], 1); 80 | //jack_error("midi_unpack: written system relatime event\n"); 81 | //midi_input_write(in, &data[i], 1); 82 | } else if (byte < 0x80) { // data 83 | assert (buf->pos < buf->size); 84 | buf->data[buf->pos++] = byte; 85 | } else if (byte < 0xF0) { // voice 86 | assert (byte >= 0x80 && byte < 0xF0); 87 | //buf->need = ((byte|0x0F) == 0xCF || (byte|0x0F)==0xDF) ? 2 : 3; 88 | buf->need = midi_voice_len[(byte - 0x80) >> 4]; 89 | buf->data[0] = byte; 90 | buf->pos = 1; 91 | } else if (byte == 0xF7) { // sysex end 92 | assert (buf->pos < buf->size); 93 | buf->data[buf->pos++] = byte; 94 | buf->need = buf->pos; 95 | } else { 96 | assert (byte >= 0xF0 && byte < 0xF8); 97 | buf->pos = 1; 98 | buf->data[0] = byte; 99 | buf->need = midi_system_len[byte - 0xF0]; 100 | if (!buf->need) { 101 | buf->need = buf->size; 102 | } 103 | } 104 | if (buf->pos == buf->need) { 105 | // TODO: deal with big sysex'es (they are silently dropped for now) 106 | if (buf->data[0] >= 0x80 || (buf->data[0] == 0xF0 && buf->data[buf->pos - 1] == 0xF7)) { 107 | /* convert Note On with velocity 0 to Note Off */ 108 | if ((buf->data[0] & 0xF0) == 0x90 && buf->data[2] == 0) { 109 | // we use temp array here to keep running status in sync 110 | jack_midi_data_t temp[3] = { 0x80, 0, 0x40 }; 111 | temp[0] |= buf->data[0] & 0x0F; 112 | temp[1] = buf->data[1]; 113 | jack_midi_event_write (jack_port_buf, time, temp, 3); 114 | } else { 115 | jack_midi_event_write (jack_port_buf, time, &buf->data[0], buf->pos); 116 | } 117 | //jack_error("midi_unpack: written %d-byte event\n", buf->pos); 118 | //midi_input_write(in, &buf->data[0], buf->pos); 119 | } 120 | /* keep running status */ 121 | if (buf->data[0] >= 0x80 && buf->data[0] < 0xF0) { 122 | buf->pos = 1; 123 | } else { 124 | buf->pos = 0; 125 | buf->need = buf->size; 126 | } 127 | } 128 | } 129 | assert (i == len); 130 | return i; 131 | } 132 | 133 | #endif /* __jack_midi_unpack_h__ */ 134 | -------------------------------------------------------------------------------- /drivers/coreaudio/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES=Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) -include /System/Library/Frameworks/Carbon.framework/Headers/Carbon.h 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_coreaudio.la 8 | 9 | jack_coreaudio_la_LDFLAGS = -module -avoid-version @OS_LDFLAGS@ 10 | jack_coreaudio_la_SOURCES = coreaudio_driver.c coreaudio_driver.h 11 | 12 | noinst_HEADERS = coreaudio_driver.h 13 | -------------------------------------------------------------------------------- /drivers/coreaudio/coreaudio_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright � Grame, 2003. 3 | Copyright � Johnny Petrantoni, 2003. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 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 General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | Grame Research Laboratory, 9, rue du Garet 69001 Lyon - France 20 | grame@rd.grame.fr 21 | 22 | Johnny Petrantoni, johnny@lato-b.com - Italy, Rome. 23 | 24 | 30-01-04, Johnny Petrantoni: first code of the coreaudio driver. 25 | 26 | */ 27 | 28 | #ifndef __jack_coreaudio_driver_h__ 29 | #define __jack_coreaudio_driver_h__ 30 | 31 | #include 32 | #if !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 33 | #include 34 | #endif 35 | #include 36 | #include 37 | #include 38 | 39 | #include "hardware.h" 40 | #include "driver.h" 41 | #include "internal.h" 42 | 43 | typedef struct { 44 | 45 | JACK_DRIVER_DECL struct _jack_engine *engine; 46 | 47 | jack_nframes_t frame_rate; 48 | jack_nframes_t frames_per_cycle; 49 | unsigned long user_nperiods; 50 | int capturing; 51 | int playing; 52 | 53 | channel_t playback_nchannels; 54 | channel_t capture_nchannels; 55 | 56 | jack_client_t *client; 57 | JSList *capture_ports; 58 | JSList *playback_ports; 59 | 60 | char capture_driver_name[256]; 61 | char playback_driver_name[256]; 62 | 63 | AudioUnit au_hal; 64 | AudioBufferList* input_list; 65 | AudioDeviceID device_id; 66 | int state; 67 | 68 | jack_nframes_t capture_frame_latency; 69 | jack_nframes_t playback_frame_latency; 70 | 71 | int xrun_detected; 72 | int null_cycle_occured; 73 | 74 | } coreaudio_driver_t; 75 | 76 | #define kVersion 01 77 | 78 | typedef UInt8 CAAudioHardwareDeviceSectionID; 79 | #define kAudioDeviceSectionInput ((CAAudioHardwareDeviceSectionID)0x01) 80 | #define kAudioDeviceSectionOutput ((CAAudioHardwareDeviceSectionID)0x00) 81 | #define kAudioDeviceSectionGlobal ((CAAudioHardwareDeviceSectionID)0x00) 82 | #define kAudioDeviceSectionWildcard ((CAAudioHardwareDeviceSectionID)0xFF) 83 | 84 | #endif /* __jack_coreaudio_driver_h__ */ 85 | -------------------------------------------------------------------------------- /drivers/dummy/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES=Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_dummy.la 8 | 9 | jack_dummy_la_LDFLAGS = -module -avoid-version 10 | jack_dummy_la_SOURCES = dummy_driver.c dummy_driver.h 11 | 12 | noinst_HEADERS = dummy_driver.h 13 | 14 | jack_dummy_la_LIBADD = $(top_builddir)/jackd/libjackserver.la 15 | -------------------------------------------------------------------------------- /drivers/dummy/dummy_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Robert Ham 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | 20 | #ifndef __JACK_DUMMY_DRIVER_H__ 21 | #define __JACK_DUMMY_DRIVER_H__ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include "driver.h" 29 | #include 30 | 31 | // needed for clock_nanosleep 32 | #ifndef _GNU_SOURCE 33 | #define _GNU_SOURCE 34 | #endif 35 | #include 36 | 37 | typedef struct _dummy_driver dummy_driver_t; 38 | 39 | struct _dummy_driver { 40 | JACK_DRIVER_NT_DECL; 41 | 42 | jack_nframes_t sample_rate; 43 | jack_nframes_t period_size; 44 | unsigned long wait_time; 45 | 46 | #if HAVE_CLOCK_GETTIME && HAVE_CLOCK_NANOSLEEP 47 | struct timespec next_wakeup; 48 | #else 49 | jack_time_t next_time; 50 | #endif 51 | 52 | unsigned int capture_channels; 53 | unsigned int playback_channels; 54 | 55 | JSList *capture_ports; 56 | JSList *playback_ports; 57 | 58 | jack_client_t *client; 59 | }; 60 | 61 | #endif /* __JACK_DUMMY_DRIVER_H__ */ 62 | -------------------------------------------------------------------------------- /drivers/firewire/Makefile.am: -------------------------------------------------------------------------------- 1 | # plugin is called 'firewire', 2 | # driver code is called 'ffado*' because it is an implementation 3 | # of a firewire backend 4 | 5 | MAINTAINERCLEANFILES=Makefile.in 6 | 7 | AM_CFLAGS = $(JACK_CFLAGS) $(LIBFFADO_CFLAGS) $(ALSA_CFLAGS) 8 | 9 | plugindir = $(ADDON_DIR) 10 | 11 | plugin_LTLIBRARIES = jack_firewire.la 12 | 13 | jack_firewire_la_SOURCES = ffado_driver.c 14 | 15 | jack_firewire_la_LIBADD = $(LIBFFADO_LIBS) $(ALSA_LIBS) $(top_builddir)/libjack/libjack.la $(top_builddir)/jackd/libjackserver.la 16 | 17 | jack_firewire_la_LDFLAGS = -module -avoid-version 18 | 19 | noinst_HEADERS = ffado_driver.h 20 | 21 | -------------------------------------------------------------------------------- /drivers/freebob/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES=Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) $(LIBFREEBOB_CFLAGS) $(ALSA_CFLAGS) 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_freebob.la 8 | 9 | jack_freebob_la_SOURCES = freebob_driver.c 10 | 11 | jack_freebob_la_LIBADD = $(LIBFREEBOB_LIBS) $(ALSA_LIBS) 12 | 13 | jack_freebob_la_LDFLAGS = -module -avoid-version 14 | 15 | noinst_HEADERS = freebob_driver.h 16 | 17 | -------------------------------------------------------------------------------- /drivers/netjack/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINCLEANFILES = Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) 4 | 5 | 6 | plugindir = $(ADDON_DIR) 7 | 8 | plugin_LTLIBRARIES = jack_net.la 9 | 10 | jack_net_la_LDFLAGS = -module -avoid-version @NETJACK_LIBS@ 11 | jack_net_la_CFLAGS = @NETJACK_CFLAGS@ 12 | jack_net_la_SOURCES = net_driver.c netjack_packet.c netjack.c 13 | jack_net_la_LIBADD = $(top_builddir)/libjack/libjack.la $(top_builddir)/jackd/libjackserver.la 14 | 15 | noinst_HEADERS = netjack.h net_driver.h netjack_packet.h 16 | 17 | noinst_LTLIBRARIES = libnetjack_packet.la 18 | 19 | libnetjack_packet_la_LDFLAGS = @NETJACK_LIBS@ 20 | libnetjack_packet_la_CFLAGS = @NETJACK_CFLAGS@ 21 | libnetjack_packet_la_SOURCES = netjack_packet.c 22 | -------------------------------------------------------------------------------- /drivers/netjack/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | see the updated docs on http://netjack.sf.net please. 5 | 6 | or mail me (torbenh@gmx.de) if you have questions. 7 | this Release has the tightest jack sync ever :) 8 | 9 | --- netJack --- 10 | - v0.5pre1 2005 - 11 | 12 | || AUTHORS(s): 13 | 14 | Torben Hohn 15 | Dan Mills 16 | Robert Jonsson 17 | 18 | 19 | || CHANGES 20 | 21 | cvs -th- 22 | fixed hardcoeded number of channels. 23 | started 24 | 25 | cvs -th- 26 | added packet_hdr 27 | which needs to be htonled.. 28 | 29 | cvs -rj- 30 | added Sconstruct 31 | added htonl() usage for crossplatform communication. 32 | 33 | 0.41 - rj - 34 | added missing Makefile.am 35 | added some configurability to udpsync_source 36 | 37 | 0.4 - rj - 38 | support for stereo 39 | support for duplex 40 | ... older ... lost in time 41 | 42 | || WHAT IS THIS? 43 | 44 | jack_net is a backend driver for Jack that takes on the role of a 45 | sound card. This machine is generally designated as the slave machine. 46 | 47 | jacknet_client is a jack application that shall be run from another 48 | computer with the ip adress of the other machine as argument. This 49 | machine is generalled designated as the master machine. 50 | 51 | 52 | || PREREQUISITES 53 | 54 | Two machines with a _good_ network connection between them. 55 | A Jack (http://jackit.sf.net) source package. 56 | 57 | 58 | || INSTALLATION: 59 | 60 | compile with 61 | scons jack_source_dir='path/to/jack-src' 62 | 63 | this creates jack_net.so. 64 | copy this to /lib/jack/drivers or wherever jack looks for driver.so`s 65 | 66 | it also creates jacknet_client. a normal program. 67 | 68 | if you build on OSX you need to add 69 | 70 | with_alsa=0 71 | 72 | 73 | || USAGE 74 | 75 | The programs will open a bidirectional connection between the two 76 | machines (using UDP). Exposing a stereopair both ways. 77 | 78 | The udpsync_source needs the slave machine as a parameter. 79 | 80 | The alsa-client is a nice thing also, it makes a not jack related 81 | alsa-card available for capturing under jack. 82 | 83 | Best performance is achieved if connecting the machines with an 84 | XOVER cable, omitting switches / hubs / other nasty things. 85 | 86 | || KNOWN ISSUES 87 | 88 | While running with full duplex, utilizing the slave machine as an 89 | outboard effect it seems very hard (atleast with my network with a 90 | cheap switch inbetween) to use buffers below 512. Sometimes 256 91 | is usable for a while. 92 | While connecting ports on the slave side it is very prone to 93 | crash if the buffers are small. 94 | 95 | The jitter of a wlan network is a little too hard for the current 96 | sync code. A delay locked loop might be used soon. 97 | 98 | There is always atleast one buffers delay if a port is routed back 99 | through the connection. This is a design issue that might be hard 100 | to remedy. 101 | 102 | 103 | || LICENSE 104 | 105 | this is free software under the GPL license, see the file COPYING. 106 | 107 | -------------------------------------------------------------------------------- /drivers/netjack/net_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Robert Ham 3 | Copyright (C) 2005 Torben Hohn 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 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 General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | 21 | #ifndef __JACK_NET_DRIVER_H__ 22 | #define __JACK_NET_DRIVER_H__ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "driver.h" 31 | 32 | #include 33 | 34 | #include "netjack.h" 35 | 36 | typedef struct _net_driver net_driver_t; 37 | 38 | struct _net_driver { 39 | JACK_DRIVER_NT_DECL; 40 | 41 | netjack_driver_state_t netj; 42 | }; 43 | 44 | #endif /* __JACK_NET_DRIVER_H__ */ 45 | -------------------------------------------------------------------------------- /drivers/netjack/netjack.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright (C) 2003 Robert Ham 4 | Copyright (C) 2005 Torben Hohn 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __NETJACK_H__ 22 | #define __NETJACK_H__ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "jack/jslist.h" 31 | 32 | #include 33 | 34 | #if HAVE_CELT 35 | #include 36 | #endif 37 | 38 | #ifdef __cplusplus 39 | extern "C" 40 | { 41 | #endif 42 | 43 | struct _packet_cache; 44 | 45 | typedef struct _netjack_driver_state netjack_driver_state_t; 46 | 47 | struct _netjack_driver_state { 48 | jack_nframes_t net_period_up; 49 | jack_nframes_t net_period_down; 50 | 51 | jack_nframes_t sample_rate; 52 | jack_nframes_t bitdepth; 53 | jack_nframes_t period_size; 54 | jack_time_t period_usecs; 55 | int dont_htonl_floats; 56 | int always_deadline; 57 | 58 | jack_nframes_t codec_latency; 59 | 60 | unsigned int listen_port; 61 | 62 | unsigned int capture_channels; 63 | unsigned int playback_channels; 64 | unsigned int capture_channels_audio; 65 | unsigned int playback_channels_audio; 66 | unsigned int capture_channels_midi; 67 | unsigned int playback_channels_midi; 68 | 69 | JSList *capture_ports; 70 | JSList *playback_ports; 71 | JSList *playback_srcs; 72 | JSList *capture_srcs; 73 | 74 | jack_client_t *client; 75 | 76 | #ifdef WIN32 77 | SOCKET sockfd; 78 | SOCKET outsockfd; 79 | #else 80 | int sockfd; 81 | int outsockfd; 82 | #endif 83 | 84 | struct sockaddr_in syncsource_address; 85 | 86 | int reply_port; 87 | int srcaddress_valid; 88 | 89 | int sync_state; 90 | unsigned int handle_transport_sync; 91 | 92 | unsigned int *rx_buf; 93 | unsigned int rx_bufsize; 94 | //unsigned int tx_bufsize; 95 | unsigned int mtu; 96 | unsigned int latency; 97 | unsigned int redundancy; 98 | 99 | jack_nframes_t expected_framecnt; 100 | int expected_framecnt_valid; 101 | unsigned int num_lost_packets; 102 | jack_time_t next_deadline; 103 | jack_time_t deadline_offset; 104 | int next_deadline_valid; 105 | int packet_data_valid; 106 | int resync_threshold; 107 | int running_free; 108 | int deadline_goodness; 109 | jack_time_t time_to_deadline; 110 | unsigned int use_autoconfig; 111 | unsigned int resample_factor; 112 | unsigned int resample_factor_up; 113 | int jitter_val; 114 | struct _packet_cache * packcache; 115 | #if HAVE_CELT 116 | CELTMode *celt_mode; 117 | #endif 118 | }; 119 | 120 | int netjack_wait ( netjack_driver_state_t * netj, jack_time_t (*get_microseconds)(void) ); 121 | void netjack_send_silence( netjack_driver_state_t *netj, int syncstate ); 122 | void netjack_read( netjack_driver_state_t *netj, jack_nframes_t nframes ); 123 | void netjack_write( netjack_driver_state_t *netj, jack_nframes_t nframes, int syncstate ); 124 | void netjack_attach( netjack_driver_state_t *netj ); 125 | void netjack_detach( netjack_driver_state_t *netj ); 126 | 127 | netjack_driver_state_t *netjack_init(netjack_driver_state_t *netj, 128 | jack_client_t * client, 129 | const char *name, 130 | unsigned int capture_ports, 131 | unsigned int playback_ports, 132 | unsigned int capture_ports_midi, 133 | unsigned int playback_ports_midi, 134 | jack_nframes_t sample_rate, 135 | jack_nframes_t period_size, 136 | unsigned int listen_port, 137 | unsigned int transport_sync, 138 | unsigned int resample_factor, 139 | unsigned int resample_factor_up, 140 | unsigned int bitdepth, 141 | unsigned int use_autoconfig, 142 | unsigned int latency, 143 | unsigned int redundancy, 144 | int dont_htonl_floats, 145 | int always_deadline, 146 | int jitter_val ); 147 | 148 | void netjack_release( netjack_driver_state_t *netj ); 149 | int netjack_startup( netjack_driver_state_t *netj ); 150 | 151 | #ifdef __cplusplus 152 | } 153 | #endif 154 | 155 | #endif 156 | -------------------------------------------------------------------------------- /drivers/netjack/netjack_packet.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * NetJack - Packet Handling functions 4 | * 5 | * used by the driver and the jacknet_client 6 | * 7 | * Copyright (C) 2006 Torben Hohn 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * 23 | * $Id: net_driver.c,v 1.16 2006/03/20 19:41:37 torbenh Exp $ 24 | * 25 | */ 26 | 27 | #ifndef __JACK_NET_PACKET_H__ 28 | #define __JACK_NET_PACKET_H__ 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | //#include 42 | // The Packet Header. 43 | 44 | #define CELT_MODE 1000 // Magic bitdepth value that indicates CELT compression 45 | #define MASTER_FREEWHEELS 0x80000000 46 | 47 | typedef struct _jacknet_packet_header jacknet_packet_header; 48 | 49 | struct _jacknet_packet_header { 50 | // General AutoConf Data 51 | jack_nframes_t capture_channels_audio; 52 | jack_nframes_t playback_channels_audio; 53 | jack_nframes_t capture_channels_midi; 54 | jack_nframes_t playback_channels_midi; 55 | jack_nframes_t period_size; 56 | jack_nframes_t sample_rate; 57 | 58 | // Transport Sync 59 | jack_nframes_t sync_state; 60 | jack_nframes_t transport_frame; 61 | jack_nframes_t transport_state; 62 | 63 | // Packet loss Detection, and latency reduction 64 | jack_nframes_t framecnt; 65 | jack_nframes_t latency; 66 | 67 | jack_nframes_t reply_port; 68 | jack_nframes_t mtu; 69 | jack_nframes_t fragment_nr; 70 | }; 71 | 72 | typedef union _int_float int_float_t; 73 | 74 | union _int_float { 75 | uint32_t i; 76 | float f; 77 | }; 78 | 79 | // fragment reorder cache. 80 | typedef struct _cache_packet cache_packet; 81 | 82 | struct _cache_packet { 83 | int valid; 84 | int num_fragments; 85 | int packet_size; 86 | int mtu; 87 | jack_time_t recv_timestamp; 88 | jack_nframes_t framecnt; 89 | char * fragment_array; 90 | char * packet_buf; 91 | }; 92 | 93 | typedef struct _packet_cache packet_cache; 94 | 95 | struct _packet_cache { 96 | int size; 97 | cache_packet *packets; 98 | int mtu; 99 | struct sockaddr_in master_address; 100 | int master_address_valid; 101 | jack_nframes_t last_framecnt_retreived; 102 | int last_framecnt_retreived_valid; 103 | }; 104 | 105 | // fragment cache function prototypes 106 | // XXX: Some of these are private. 107 | packet_cache *packet_cache_new(int num_packets, int pkt_size, int mtu); 108 | void packet_cache_free(packet_cache *pkt_cache); 109 | 110 | cache_packet *packet_cache_get_packet(packet_cache *pkt_cache, jack_nframes_t framecnt); 111 | cache_packet *packet_cache_get_oldest_packet(packet_cache *pkt_cache); 112 | cache_packet *packet_cache_get_free_packet(packet_cache *pkt_cache); 113 | 114 | void cache_packet_reset(cache_packet *pack); 115 | void cache_packet_set_framecnt(cache_packet *pack, jack_nframes_t framecnt); 116 | void cache_packet_add_fragment(cache_packet *pack, char *packet_buf, int rcv_len); 117 | int cache_packet_is_complete(cache_packet *pack); 118 | 119 | void packet_cache_drain_socket ( packet_cache * pcache, int sockfd, jack_time_t (*get_microseconds)(void) ); 120 | void packet_cache_reset_master_address( packet_cache *pcache ); 121 | float packet_cache_get_fill( packet_cache *pcache, jack_nframes_t expected_framecnt ); 122 | int packet_cache_retreive_packet_pointer( packet_cache *pcache, jack_nframes_t framecnt, char **packet_buf, int pkt_size, jack_time_t *timestamp ); 123 | int packet_cache_release_packet( packet_cache *pcache, jack_nframes_t framecnt ); 124 | int packet_cache_get_next_available_framecnt( packet_cache *pcache, jack_nframes_t expected_framecnt, jack_nframes_t *framecnt ); 125 | int packet_cache_get_highest_available_framecnt( packet_cache *pcache, jack_nframes_t *framecnt ); 126 | int packet_cache_find_latency( packet_cache *pcache, jack_nframes_t expected_framecnt, jack_nframes_t *framecnt ); 127 | // Function Prototypes 128 | 129 | int netjack_poll_deadline (int sockfd, jack_time_t deadline, jack_time_t (*get_microseconds)(void)); 130 | 131 | void netjack_sendto(int sockfd, char *packet_buf, int pkt_size, int flags, struct sockaddr *addr, int addr_size, int mtu); 132 | 133 | 134 | int get_sample_size(int bitdepth); 135 | void packet_header_hton(jacknet_packet_header *pkthdr); 136 | 137 | void packet_header_ntoh(jacknet_packet_header *pkthdr); 138 | 139 | void render_payload_to_jack_ports(int bitdepth, void *packet_payload, jack_nframes_t net_period_down, JSList *capture_ports, JSList *capture_srcs, jack_nframes_t nframes, int dont_htonl_floats ); 140 | 141 | void render_jack_ports_to_payload(int bitdepth, JSList *playback_ports, JSList *playback_srcs, jack_nframes_t nframes, void *packet_payload, jack_nframes_t net_period_up, int dont_htonl_floats ); 142 | 143 | 144 | // XXX: This is sort of deprecated: 145 | // This one waits forever. an is not using ppoll 146 | int netjack_poll(int sockfd, int timeout); 147 | 148 | void decode_midi_buffer(uint32_t *buffer_uint32, unsigned int buffer_size_uint32, jack_default_audio_sample_t* buf); 149 | void encode_midi_buffer(uint32_t *buffer_uint32, unsigned int buffer_size_uint32, jack_default_audio_sample_t* buf); 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | #endif 154 | 155 | -------------------------------------------------------------------------------- /drivers/oss/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINCLEANFILES = Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) -I/usr/lib/oss/include 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_oss.la 8 | 9 | jack_oss_la_LDFLAGS = -module -avoid-version 10 | jack_oss_la_SOURCES = oss_driver.c oss_driver.h 11 | jack_oss_la_LIBADD = $(top_builddir)/jackd/libjackserver.la 12 | 13 | noinst_HEADERS = oss_driver.h 14 | -------------------------------------------------------------------------------- /drivers/oss/oss_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | OSS driver for Jack 4 | Copyright (C) 2003-2007 Jussi Laako 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19 | MA 02111-1307 USA 20 | 21 | */ 22 | 23 | 24 | #ifndef __JACK_OSS_DRIVER_H__ 25 | #define __JACK_OSS_DRIVER_H__ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "driver.h" 36 | 37 | 38 | #define OSS_DRIVER_DEF_DEV "/dev/dsp" 39 | #define OSS_DRIVER_DEF_FS 48000 40 | #define OSS_DRIVER_DEF_BLKSIZE 1024 41 | #define OSS_DRIVER_DEF_NPERIODS 2 42 | #define OSS_DRIVER_DEF_BITS 16 43 | #define OSS_DRIVER_DEF_INS 2 44 | #define OSS_DRIVER_DEF_OUTS 2 45 | 46 | 47 | typedef jack_default_audio_sample_t jack_sample_t; 48 | 49 | typedef struct _oss_driver { 50 | JACK_DRIVER_DECL 51 | 52 | jack_nframes_t sample_rate; 53 | jack_nframes_t period_size; 54 | unsigned int nperiods; 55 | int bits; 56 | unsigned int capture_channels; 57 | unsigned int playback_channels; 58 | 59 | char *indev; 60 | char *outdev; 61 | int infd; 62 | int outfd; 63 | int format; 64 | int ignorehwbuf; 65 | int trigger; 66 | 67 | size_t indevbufsize; 68 | size_t outdevbufsize; 69 | size_t portbufsize; 70 | void *indevbuf; 71 | void *outdevbuf; 72 | 73 | float iodelay; 74 | jack_time_t last_periodtime; 75 | jack_time_t next_periodtime; 76 | jack_nframes_t sys_in_latency; 77 | jack_nframes_t sys_out_latency; 78 | 79 | JSList *capture_ports; 80 | JSList *playback_ports; 81 | 82 | jack_engine_t *engine; 83 | jack_client_t *client; 84 | 85 | volatile int run; 86 | volatile int threads; 87 | pthread_t thread_in; 88 | pthread_t thread_out; 89 | pthread_mutex_t mutex_in; 90 | pthread_mutex_t mutex_out; 91 | # ifdef USE_BARRIER 92 | pthread_barrier_t barrier; 93 | # endif 94 | sem_t sem_start; 95 | } oss_driver_t; 96 | 97 | 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /drivers/portaudio/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES=Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_portaudio.la 8 | 9 | jack_portaudio_la_LDFLAGS = -module -avoid-version 10 | jack_portaudio_la_SOURCES = portaudio_driver.c portaudio_driver.h 11 | 12 | noinst_HEADERS = portaudio_driver.h 13 | 14 | jack_portaudio_la_LIBADD = $(PA_LIBS) 15 | -------------------------------------------------------------------------------- /drivers/portaudio/portaudio_driver.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackaudio/jack1/ab2e7363cacd0bf4b961c0466c13b0b4c1086ed9/drivers/portaudio/portaudio_driver.c -------------------------------------------------------------------------------- /drivers/portaudio/portaudio_driver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackaudio/jack1/ab2e7363cacd0bf4b961c0466c13b0b4c1086ed9/drivers/portaudio/portaudio_driver.h -------------------------------------------------------------------------------- /drivers/sndio/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINCLEANFILES = Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_sndio.la 8 | 9 | jack_sndio_la_LDFLAGS = -module -avoid-version 10 | jack_sndio_la_LIBADD = $(SNDIO_LIBS) 11 | jack_sndio_la_SOURCES = sndio_driver.c sndio_driver.h 12 | 13 | noinst_HEADERS = sndio_driver.h 14 | -------------------------------------------------------------------------------- /drivers/sndio/sndio_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Jacob Meuser 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef __JACK_SNDIO_DRIVER_H__ 18 | #define __JACK_SNDIO_DRIVER_H__ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #define SNDIO_DRIVER_DEF_DEV "default" 30 | #define SNDIO_DRIVER_DEF_FS 44100 31 | #define SNDIO_DRIVER_DEF_BLKSIZE 1024 32 | #define SNDIO_DRIVER_DEF_NPERIODS 2 33 | #define SNDIO_DRIVER_DEF_BITS 16 34 | #define SNDIO_DRIVER_DEF_INS 2 35 | #define SNDIO_DRIVER_DEF_OUTS 2 36 | 37 | typedef jack_default_audio_sample_t jack_sample_t; 38 | 39 | typedef struct _sndio_driver 40 | { 41 | JACK_DRIVER_NT_DECL 42 | 43 | jack_nframes_t sample_rate; 44 | jack_nframes_t period_size; 45 | jack_nframes_t orig_period_size; 46 | unsigned int nperiods; 47 | int bits; 48 | unsigned int capture_channels; 49 | unsigned int playback_channels; 50 | jack_nframes_t sys_cap_latency; 51 | jack_nframes_t sys_play_latency; 52 | int ignorehwbuf; 53 | 54 | struct sio_hdl *hdl; 55 | char *dev; 56 | 57 | void *capbuf; 58 | size_t capbufsize; 59 | void *playbuf; 60 | size_t playbufsize; 61 | JSList *capture_ports; 62 | JSList *playback_ports; 63 | 64 | int sample_bytes; 65 | size_t pprime; 66 | 67 | int poll_timeout; 68 | jack_time_t poll_next; 69 | 70 | jack_client_t *client; 71 | 72 | } sndio_driver_t; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /drivers/sun/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINCLEANFILES = Makefile.in 2 | 3 | AM_CFLAGS = $(JACK_CFLAGS) 4 | 5 | plugindir = $(ADDON_DIR) 6 | 7 | plugin_LTLIBRARIES = jack_sun.la 8 | 9 | jack_sun_la_LDFLAGS = -module -avoid-version 10 | jack_sun_la_SOURCES = sun_driver.c sun_driver.h 11 | 12 | noinst_HEADERS = sun_driver.h 13 | -------------------------------------------------------------------------------- /drivers/sun/sun_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Sun Audio API driver for Jack 4 | Copyright (C) 2008 Jacob Meuser 5 | Based heavily on oss_driver.h which came with the following 6 | copyright notice. 7 | 8 | Copyright (C) 2003-2007 Jussi Laako 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program; if not, write to the Free Software 22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 | MA 02111-1307 USA 24 | 25 | */ 26 | 27 | 28 | #ifndef __JACK_SUN_DRIVER_H__ 29 | #define __JACK_SUN_DRIVER_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #include "driver.h" 40 | 41 | #define SUN_DRIVER_DEF_DEV "/dev/audio" 42 | #define SUN_DRIVER_DEF_FS 48000 43 | #define SUN_DRIVER_DEF_BLKSIZE 1024 44 | #define SUN_DRIVER_DEF_NPERIODS 2 45 | #define SUN_DRIVER_DEF_BITS 16 46 | #define SUN_DRIVER_DEF_INS 2 47 | #define SUN_DRIVER_DEF_OUTS 2 48 | 49 | 50 | typedef jack_default_audio_sample_t jack_sample_t; 51 | 52 | typedef struct _sun_driver { 53 | JACK_DRIVER_NT_DECL 54 | 55 | jack_nframes_t sample_rate; 56 | jack_nframes_t period_size; 57 | unsigned int nperiods; 58 | int bits; 59 | int sample_bytes; 60 | unsigned int capture_channels; 61 | unsigned int playback_channels; 62 | 63 | char *indev; 64 | char *outdev; 65 | int infd; 66 | int outfd; 67 | int format; 68 | int ignorehwbuf; 69 | 70 | size_t indevbufsize; 71 | size_t outdevbufsize; 72 | size_t portbufsize; 73 | void *indevbuf; 74 | void *outdevbuf; 75 | 76 | int poll_timeout; 77 | jack_time_t poll_last; 78 | jack_time_t poll_next; 79 | float iodelay; 80 | 81 | jack_nframes_t sys_in_latency; 82 | jack_nframes_t sys_out_latency; 83 | 84 | JSList *capture_ports; 85 | JSList *playback_ports; 86 | 87 | jack_client_t *client; 88 | 89 | int playback_drops; 90 | int capture_drops; 91 | 92 | } sun_driver_t; 93 | 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in version.h 2 | 3 | noinst_HEADERS = \ 4 | atomicity.h \ 5 | bitset.h \ 6 | driver.h \ 7 | driver_interface.h \ 8 | driver_parse.h \ 9 | engine.h \ 10 | hardware.h \ 11 | internal.h \ 12 | intsimd.h \ 13 | memops.h \ 14 | messagebuffer.h \ 15 | pool.h \ 16 | port.h \ 17 | sanitycheck.h \ 18 | shm.h \ 19 | start.h \ 20 | systemtest.h \ 21 | unlock.h \ 22 | varargs.h \ 23 | version.h 24 | -------------------------------------------------------------------------------- /include/atomicity.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004 Jack O'Quin 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_atomicity_h__ 21 | #define __jack_atomicity_h__ 22 | 23 | #if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) 24 | 25 | #include 26 | 27 | typedef atomic_int _Atomic_word; 28 | 29 | static inline int exchange_and_add(volatile _Atomic_word* obj, int value) 30 | { 31 | return atomic_fetch_add_explicit(obj, value, memory_order_relaxed); 32 | } 33 | 34 | #else 35 | 36 | typedef int _Atomic_word; 37 | 38 | static inline int exchange_and_add(volatile _Atomic_word* obj, int value) 39 | { 40 | return __atomic_fetch_add(obj, value, __ATOMIC_RELAXED); 41 | } 42 | 43 | #endif 44 | 45 | #endif /* __jack_atomicity_h__ */ 46 | -------------------------------------------------------------------------------- /include/bitset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bitset.h -- some simple bit vector set operations. 3 | * 4 | * This is useful for sets of small non-negative integers. There are 5 | * some obvious set operations that are not implemented because I 6 | * don't need them right now. 7 | * 8 | * These functions represent sets as arrays of unsigned 32-bit 9 | * integers allocated on the heap. The first entry contains the set 10 | * cardinality (number of elements allowed), followed by one or more 11 | * words containing bit vectors. 12 | * 13 | */ 14 | 15 | /* 16 | * Copyright (C) 2005 Jack O'Quin 17 | * 18 | * This program is free software; you can redistribute it and/or 19 | * modify it under the terms of the GNU General Public License as 20 | * published by the Free Software Foundation; either version 2 of the 21 | * License, or (at your option) any later version. 22 | * 23 | * This program is distributed in the hope that it will be useful, 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program; if not, write to the Free Software 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 31 | */ 32 | 33 | #ifndef __bitset_h__ 34 | #define __bitset_h__ 35 | 36 | #include /* POSIX standard fixed-size types */ 37 | #include /* `#define NDEBUG' to disable */ 38 | 39 | /* On some 64-bit machines, this implementation may be slightly 40 | * inefficient, depending on how compilers allocate space for 41 | * uint32_t. For the set sizes I currently need, this is acceptable. 42 | * It should not be hard to pack the bits better, if that becomes 43 | * worthwhile. 44 | */ 45 | typedef uint32_t _bitset_word_t; 46 | typedef _bitset_word_t *bitset_t; 47 | 48 | #define WORD_SIZE(cardinality) (1 + ((cardinality) + 31) / 32) 49 | #define BYTE_SIZE(cardinality) (WORD_SIZE (cardinality) * sizeof(_bitset_word_t)) 50 | #define WORD_INDEX(element) (1 + (element) / 32) 51 | #define BIT_INDEX(element) ((element) & 037) 52 | 53 | static inline void 54 | bitset_add (bitset_t set, unsigned int element) 55 | { 56 | assert (element < set[0]); 57 | set[WORD_INDEX (element)] |= (1 << BIT_INDEX (element)); 58 | } 59 | 60 | static inline void 61 | bitset_copy (bitset_t to_set, bitset_t from_set) 62 | { 63 | assert (to_set[0] == from_set[0]); 64 | memcpy (to_set, from_set, BYTE_SIZE (to_set[0])); 65 | } 66 | 67 | static inline void 68 | bitset_create (bitset_t *set, unsigned int cardinality) 69 | { 70 | *set = (bitset_t)calloc (WORD_SIZE (cardinality), 71 | sizeof(_bitset_word_t)); 72 | assert (*set); 73 | *set[0] = cardinality; 74 | } 75 | 76 | static inline void 77 | bitset_destroy (bitset_t *set) 78 | { 79 | if (*set) { 80 | free (*set); 81 | *set = (bitset_t)0; 82 | } 83 | } 84 | 85 | static inline int 86 | bitset_empty (bitset_t set) 87 | { 88 | int i; 89 | _bitset_word_t result = 0; 90 | int nwords = WORD_SIZE (set[0]); 91 | 92 | for (i = 1; i < nwords; i++) 93 | result |= set[i]; 94 | return result == 0; 95 | } 96 | 97 | static inline int 98 | bitset_contains (bitset_t set, unsigned int element) 99 | { 100 | assert (element < set[0]); 101 | return 0 != (set[WORD_INDEX (element)] & (1 << BIT_INDEX (element))); 102 | } 103 | 104 | static inline void 105 | bitset_remove (bitset_t set, unsigned int element) 106 | { 107 | assert (element < set[0]); 108 | set[WORD_INDEX (element)] &= ~(1 << BIT_INDEX (element)); 109 | } 110 | 111 | #endif /* __bitset_h__ */ 112 | -------------------------------------------------------------------------------- /include/driver_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Bob Ham 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_driver_interface_h__ 21 | #define __jack_driver_interface_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include 28 | 29 | #include 30 | #include "internal.h" 31 | 32 | #define JACK_DRIVER_NAME_MAX 15 33 | #define JACK_DRIVER_PARAM_NAME_MAX 15 34 | #define JACK_DRIVER_PARAM_STRING_MAX 63 35 | 36 | #define JACK_CONSTRAINT_FLAG_RANGE ((uint32_t)1) /**< if set, constraint is a range (min-max) */ 37 | #define JACK_CONSTRAINT_FLAG_STRICT ((uint32_t)2) /**< if set, constraint is strict, i.e. supplying non-matching value will not work */ 38 | #define JACK_CONSTRAINT_FLAG_FAKE_VALUE ((uint32_t)4) /**< if set, values have no user meaningful meaning */ 39 | 40 | 41 | /** Driver parameter types */ 42 | typedef enum { 43 | JackDriverParamInt = 1, 44 | JackDriverParamUInt, 45 | JackDriverParamChar, 46 | JackDriverParamString, 47 | JackDriverParamBool 48 | 49 | } jack_driver_param_type_t; 50 | 51 | /** Driver parameter value */ 52 | typedef union { 53 | uint32_t ui; 54 | int32_t i; 55 | char c; 56 | char str[JACK_DRIVER_PARAM_STRING_MAX + 1]; 57 | } jack_driver_param_value_t; 58 | 59 | typedef struct { 60 | jack_driver_param_value_t value; 61 | char short_desc[64]; /**< A short (~30 chars) description for the user */ 62 | } jack_driver_param_value_enum_t; 63 | 64 | typedef struct { 65 | uint32_t flags; /**< JACK_CONSTRAINT_FLAG_XXX */ 66 | 67 | union { 68 | struct { 69 | jack_driver_param_value_t min; 70 | jack_driver_param_value_t max; 71 | } range; /**< valid when JACK_CONSTRAINT_FLAG_RANGE flag is set */ 72 | 73 | struct { 74 | uint32_t count; 75 | jack_driver_param_value_enum_t * possible_values_array; 76 | } enumeration; /**< valid when JACK_CONSTRAINT_FLAG_RANGE flag is not set */ 77 | } constraint; 78 | } jack_driver_param_constraint_desc_t; 79 | 80 | 81 | /** A driver parameter descriptor */ 82 | typedef struct { 83 | char name[JACK_DRIVER_NAME_MAX + 1]; /**< The parameter's name */ 84 | char character; /**< The parameter's character (for getopt, etc) */ 85 | jack_driver_param_type_t type; /**< The parameter's type */ 86 | jack_driver_param_value_t value; /**< The parameter's (default) value */ 87 | jack_driver_param_constraint_desc_t * constraint; /**< Pointer to parameter constraint descriptor. NULL if there is no constraint */ 88 | char short_desc[64]; /**< A short (~30 chars) description for the user */ 89 | char long_desc[1024]; /**< A longer description for the user */ 90 | 91 | } jack_driver_param_desc_t; 92 | 93 | /** A driver parameter */ 94 | typedef struct { 95 | char character; 96 | jack_driver_param_value_t value; 97 | } jack_driver_param_t; 98 | 99 | 100 | /** A struct for describing a jack driver */ 101 | typedef struct { 102 | char name[JACK_DRIVER_NAME_MAX + 1]; /**< The driver's canonical name */ 103 | char file[PATH_MAX + 1]; /**< The filename of the driver's shared object file */ 104 | uint32_t nparams; /**< The number of parameters the driver has */ 105 | jack_driver_param_desc_t * params; /**< An array of parameter descriptors */ 106 | 107 | } jack_driver_desc_t; 108 | 109 | 110 | 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif /* __jack_driver_interface_h__ */ 117 | 118 | 119 | -------------------------------------------------------------------------------- /include/hardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_hardware_h__ 21 | #define __jack_hardware_h__ 22 | 23 | #include 24 | 25 | typedef enum { 26 | AutoSync, 27 | WordClock, 28 | ClockMaster 29 | } SampleClockMode; 30 | 31 | typedef enum { 32 | Cap_HardwareMonitoring = 0x1, 33 | Cap_AutoSync = 0x2, 34 | Cap_WordClock = 0x4, 35 | Cap_ClockMaster = 0x8, 36 | Cap_ClockLockReporting = 0x10, 37 | Cap_HardwareMetering = 0x20 38 | } Capabilities; 39 | 40 | struct _jack_hardware; 41 | 42 | typedef void (*JackHardwareReleaseFunction)(struct _jack_hardware *); 43 | typedef int (*JackHardwareSetInputMonitorMaskFunction)(struct _jack_hardware *, unsigned long); 44 | typedef int (*JackHardwareChangeSampleClockFunction)(struct _jack_hardware *, SampleClockMode); 45 | typedef double (*JackHardwareGetHardwarePeak)(jack_port_t *port, jack_nframes_t frames); 46 | typedef double (*JackHardwareGetHardwarePower)(jack_port_t *port, jack_nframes_t frames); 47 | 48 | 49 | typedef struct _jack_hardware { 50 | 51 | unsigned long capabilities; 52 | unsigned long input_monitor_mask; 53 | 54 | JackHardwareChangeSampleClockFunction change_sample_clock; 55 | JackHardwareSetInputMonitorMaskFunction set_input_monitor_mask; 56 | JackHardwareReleaseFunction release; 57 | JackHardwareGetHardwarePeak get_hardware_peak; 58 | JackHardwareGetHardwarePower get_hardware_power; 59 | void *private; 60 | 61 | } jack_hardware_t; 62 | 63 | jack_hardware_t * jack_hardware_new(); 64 | 65 | #endif /* __jack_hardware_h__ */ 66 | -------------------------------------------------------------------------------- /include/intsimd.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2007 Jussi Laako 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_intsimd_h__ 21 | #define __jack_intsimd_h__ 22 | 23 | #ifdef USE_DYNSIMD 24 | #if (defined(__i386__) || defined(__x86_64__)) 25 | #define ARCH_X86 26 | #endif /* __i386__ || __x86_64__ */ 27 | #endif /* USE_DYNSIMD */ 28 | 29 | #ifdef ARCH_X86 30 | #define ARCH_X86_SSE(x) ((x) & 0xff) 31 | #define ARCH_X86_HAVE_SSE2(x) (ARCH_X86_SSE (x) >= 2) 32 | #define ARCH_X86_3DNOW(x) ((x) >> 8) 33 | #define ARCH_X86_HAVE_3DNOW(x) (ARCH_X86_3DNOW (x)) 34 | 35 | typedef float v2sf __attribute__((vector_size (8))); 36 | typedef float v4sf __attribute__((vector_size (16))); 37 | typedef v2sf * pv2sf; 38 | typedef v4sf * pv4sf; 39 | 40 | extern int cpu_type; 41 | 42 | int have_3dnow(void); 43 | int have_sse(void); 44 | void x86_3dnow_copyf(float *, const float *, int); 45 | void x86_3dnow_add2f(float *, const float *, int); 46 | void x86_sse_copyf(float *, const float *, int); 47 | void x86_sse_add2f(float *, const float *, int); 48 | void x86_sse_f2i(int *, const float *, int, float); 49 | void x86_sse_i2f(float *, const int *, int, float); 50 | 51 | #endif /* ARCH_X86 */ 52 | 53 | void jack_port_set_funcs(void); 54 | 55 | #endif /* __jack_intsimd_h__ */ 56 | 57 | -------------------------------------------------------------------------------- /include/messagebuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * messagebuffer.h -- realtime-safe message interface for jackd. 3 | * 4 | * This function is included in libjack so backend drivers can use 5 | * it, *not* for external client processes. The VERBOSE() and 6 | * MESSAGE() macros are realtime-safe. 7 | */ 8 | 9 | /* 10 | * Copyright (C) 2004 Rui Nuno Capela, Steve Harris 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU Lesser General Public License as published by 14 | * the Free Software Foundation; either version 2.1 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public License 23 | * along with this program; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25 | * 26 | */ 27 | 28 | #ifndef __jack_messagebuffer_h__ 29 | #define __jack_messagebuffer_h__ 30 | 31 | #define MESSAGE(fmt, args ...) jack_messagebuffer_add (fmt, ## args) 32 | #define VERBOSE(engine, fmt, args ...) \ 33 | if ((engine)->verbose) \ 34 | jack_messagebuffer_add (fmt, ## args) 35 | 36 | void jack_messagebuffer_init(); 37 | void jack_messagebuffer_exit(); 38 | void jack_message_buffer_thread_init(void (*cb)(void*), void*); 39 | 40 | void jack_messagebuffer_add(const char *fmt, ...); 41 | 42 | void jack_messagebuffer_thread_init(void (*cb)(void*), void* arg); 43 | 44 | #endif /* __jack_messagebuffer_h__ */ 45 | -------------------------------------------------------------------------------- /include/pool.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #ifndef __jack_pool_h__ 21 | #define __jack_pool_h__ 22 | 23 | #include 24 | 25 | void * jack_pool_alloc(size_t bytes); 26 | void jack_pool_release(void *); 27 | 28 | #endif /* __jack_pool_h__ */ 29 | -------------------------------------------------------------------------------- /include/sanitycheck.h: -------------------------------------------------------------------------------- 1 | #ifndef __jack_sanitycheck_h__ 2 | #define __jack_sanitycheck_h__ 3 | 4 | /** 5 | * GPL etc. 6 | * 7 | * @author Florian Faber 8 | * 9 | * @version 0.1 (2009-01-17) [FF] 10 | * - initial version 11 | **/ 12 | 13 | /** 14 | * Performs a range of sanity checks on the system. The number of 15 | * found problems is returned. 16 | * 17 | **/ 18 | 19 | int sanitycheck(int do_realtime_check, 20 | int do_freqscaling_check); 21 | 22 | #endif /* __jack_sanitycheck_h__ */ 23 | -------------------------------------------------------------------------------- /include/shm.h: -------------------------------------------------------------------------------- 1 | #ifndef __jack_shm_h__ 2 | #define __jack_shm_h__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define MAX_SERVERS 8 /* maximum concurrent servers */ 9 | #define MAX_SHM_ID 256 /* generally about 16 per server */ 10 | #define JACK_SERVER_NAME_SIZE 256 /* maximum length of server name */ 11 | #define JACK_SHM_MAGIC 0x4a41434b /* shm magic number: "JACK" */ 12 | #define JACK_SHM_NULL_INDEX -1 /* NULL SHM index */ 13 | #define JACK_SHM_REGISTRY_INDEX -2 /* pseudo SHM index for registry */ 14 | 15 | 16 | /* On Mac OS X, SHM_NAME_MAX is the maximum length of a shared memory 17 | * segment name (instead of NAME_MAX or PATH_MAX as defined by the 18 | * standard). 19 | */ 20 | #ifdef USE_POSIX_SHM 21 | #ifndef SHM_NAME_MAX 22 | #define SHM_NAME_MAX NAME_MAX 23 | #endif 24 | typedef char shm_name_t[SHM_NAME_MAX]; 25 | typedef shm_name_t jack_shm_id_t; 26 | #else /* System V SHM */ 27 | typedef int jack_shm_id_t; 28 | #endif /* SHM type */ 29 | 30 | /* shared memory type */ 31 | typedef enum { 32 | shm_POSIX = 1, /* POSIX shared memory */ 33 | shm_SYSV = 2 /* System V shared memory */ 34 | } jack_shmtype_t; 35 | 36 | typedef int16_t jack_shm_registry_index_t; 37 | 38 | /** 39 | * A structure holding information about shared memory allocated by 40 | * JACK. this persists across invocations of JACK, and can be used by 41 | * multiple JACK servers. It contains no pointers and is valid across 42 | * address spaces. 43 | * 44 | * The registry consists of two parts: a header including an array of 45 | * server names, followed by an array of segment registry entries. 46 | */ 47 | typedef struct _jack_shm_server { 48 | pid_t pid; /* process ID */ 49 | char name[JACK_SERVER_NAME_SIZE]; 50 | } jack_shm_server_t; 51 | 52 | typedef struct _jack_shm_header { 53 | uint32_t magic; /* magic number */ 54 | uint16_t protocol; /* JACK protocol version */ 55 | jack_shmtype_t type; /* shm type */ 56 | jack_shmsize_t size; /* total registry segment size */ 57 | jack_shmsize_t hdr_len; /* size of header */ 58 | jack_shmsize_t entry_len; /* size of registry entry */ 59 | jack_shm_server_t server[MAX_SERVERS]; /* current server array */ 60 | } jack_shm_header_t; 61 | 62 | typedef struct _jack_shm_registry { 63 | jack_shm_registry_index_t index; /* offset into the registry */ 64 | pid_t allocator; /* PID that created shm segment */ 65 | jack_shmsize_t size; /* for POSIX unattach */ 66 | jack_shm_id_t id; /* API specific, see above */ 67 | } jack_shm_registry_t; 68 | 69 | #define JACK_SHM_REGISTRY_SIZE (sizeof(jack_shm_header_t) \ 70 | + sizeof(jack_shm_registry_t) * MAX_SHM_ID) 71 | 72 | /** 73 | * a structure holding information about shared memory 74 | * allocated by JACK. this version is valid only 75 | * for a given address space. It contains a pointer 76 | * indicating where the shared memory has been 77 | * attached to the address space. 78 | */ 79 | typedef struct _jack_shm_info { 80 | jack_shm_registry_index_t index; /* offset into the registry */ 81 | void *attached_at; /* address where attached */ 82 | } jack_shm_info_t; 83 | 84 | /* utility functions used only within JACK */ 85 | 86 | extern void jack_shm_copy_from_registry (jack_shm_info_t *, 87 | jack_shm_registry_index_t); 88 | extern void jack_shm_copy_to_registry(jack_shm_info_t*, 89 | jack_shm_registry_index_t*); 90 | extern void jack_release_shm_info (jack_shm_registry_index_t); 91 | 92 | static inline char* jack_shm_addr (jack_shm_info_t* si) 93 | { 94 | return si->attached_at; 95 | } 96 | 97 | /* here beginneth the API */ 98 | 99 | extern int jack_register_server(const char *server_name, int new_registry); 100 | extern void jack_unregister_server(const char *server_name); 101 | 102 | extern int jack_initialize_shm(const char *server_name); 103 | extern int jack_cleanup_shm(void); 104 | 105 | extern int jack_shmalloc(jack_shmsize_t size, jack_shm_info_t* result); 106 | extern void jack_release_shm(jack_shm_info_t*); 107 | extern void jack_destroy_shm(jack_shm_info_t*); 108 | extern int jack_attach_shm(jack_shm_info_t*); 109 | extern int jack_resize_shm(jack_shm_info_t*, jack_shmsize_t size); 110 | 111 | #endif /* __jack_shm_h__ */ 112 | -------------------------------------------------------------------------------- /include/start.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Fernando Lopez-Lezcano 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | */ 19 | 20 | #define PIPE_READ_FD (3) 21 | #define PIPE_WRITE_FD (4) 22 | -------------------------------------------------------------------------------- /include/systemtest.h: -------------------------------------------------------------------------------- 1 | #ifndef __jack_systemtest_h__ 2 | #define __jack_systemtest_h__ 3 | 4 | /** 5 | * GPL, yabbadabba 6 | * 7 | * Set of functions to gather system information for the jack setup wizard. 8 | * 9 | * @author Florian Faber, faber@faberman.de 10 | * 11 | * @version 0.1 (2009-01-15) [FF] 12 | * - initial version 13 | * 14 | **/ 15 | 16 | 17 | /** 18 | * This function checks for the existence of known frequency scaling mechanisms 19 | * in this system. 20 | * 21 | * @returns 0 if the system has no frequency scaling capabilities non-0 otherwise. 22 | **/ 23 | int system_has_frequencyscaling(); 24 | 25 | 26 | /** 27 | * This function determines wether the CPU has a variable clock speed if frequency 28 | * scaling is available. 29 | * 30 | * @returns 0 if system doesn't use frequency scaling at the moment, non-0 otherwise 31 | **/ 32 | int system_uses_frequencyscaling(); 33 | 34 | 35 | /*** 36 | * Checks for a definition in /etc/security/limits.conf that looks 37 | * as if it allows RT scheduling priority. 38 | * 39 | * @returns 1 if there appears to be such a line 40 | **/ 41 | int system_has_rtprio_limits_conf(); 42 | 43 | /** 44 | * Checks for the existence of the 'audio' group on this system 45 | * 46 | * @returns 0 is there is no 'audio' group, non-0 otherwise 47 | **/ 48 | int system_has_audiogroup(); 49 | 50 | 51 | /** 52 | * Tests wether the owner of this process is in the 'audio' group. 53 | * 54 | * @returns 0 if the owner of this process is not in the audio group, non-0 otherwise 55 | **/ 56 | int system_user_in_audiogroup(); 57 | 58 | 59 | /** 60 | * Determines wether the owner of this process can enable rt priority. 61 | * 62 | * @returns 0 if this process can not be switched to rt prio, non-0 otherwise 63 | **/ 64 | int system_user_can_rtprio(); 65 | 66 | 67 | long long unsigned int system_memlock_amount(); 68 | 69 | 70 | /** 71 | * Checks wether the memlock limit is unlimited 72 | * 73 | * @returns 0 if the memlock limit is limited, non-0 otherwise 74 | **/ 75 | int system_memlock_is_unlimited(); 76 | 77 | 78 | long long unsigned int system_available_physical_mem(); 79 | 80 | 81 | /** 82 | * Gets the version of the currently running kernel 83 | * 84 | * @returns String with the full version of the kernel 85 | **/ 86 | char* system_kernel_version(); 87 | 88 | 89 | /** 90 | * Returns the username. The caller is in charge of disposal of 91 | * the returned name. 92 | * 93 | * @returns Pointer to a username or NULL 94 | **/ 95 | char* system_get_username(); 96 | 97 | #endif /* __jack_systemtest_h__ */ 98 | -------------------------------------------------------------------------------- /include/unlock.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "bsd"; -*- */ 2 | /* 3 | Copyright (C) 2001-2003 Paul Davis 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 | #ifndef __jack_mlock_h__ 22 | #define __jack_mlock_h__ 23 | 24 | extern void cleanup_mlock(void); 25 | 26 | #endif /* __jack_mlock_h__ */ 27 | -------------------------------------------------------------------------------- /include/varargs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Jack O'Quin 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2.1 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | * 18 | */ 19 | 20 | #ifndef __jack_varargs_h__ 21 | #define __jack_varargs_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* variable argument structure */ 28 | typedef struct { 29 | char *server_name; /* server name */ 30 | char *load_name; /* load module name */ 31 | char *load_init; /* initialization string */ 32 | char *sess_uuid; 33 | } jack_varargs_t; 34 | 35 | static inline void 36 | jack_varargs_init (jack_varargs_t *va) 37 | { 38 | memset (va, 0, sizeof(jack_varargs_t)); 39 | va->server_name = jack_default_server_name (); 40 | } 41 | 42 | static inline void 43 | jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va) 44 | { 45 | /* initialize default settings */ 46 | jack_varargs_init (va); 47 | 48 | if ((options & JackServerName)) { 49 | char *sn = va_arg (ap, char *); 50 | if (sn) { 51 | va->server_name = sn; 52 | } 53 | } 54 | if ((options & JackLoadName)) { 55 | va->load_name = va_arg (ap, char *); 56 | } 57 | if ((options & JackLoadInit)) { 58 | va->load_init = va_arg (ap, char *); 59 | } 60 | if ((options & JackSessionID)) { 61 | va->sess_uuid = va_arg (ap, char *); 62 | } 63 | } 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __jack_varargs_h__ */ 70 | -------------------------------------------------------------------------------- /include/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Paul Davis 3 | 4 | @configure_input@ 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | #define jack_protocol_version @JACK_PROTOCOL_VERSION@ 21 | -------------------------------------------------------------------------------- /jack.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | jack_implementation=jack1 6 | 7 | Name: jack 8 | Description: the Jack Audio Connection Kit: a low-latency synchronous callback-based media server 9 | Version: @JACK_VERSION@ 10 | Libs: -L${libdir} -ljack -lpthread @OS_LDFLAGS@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /jackd/ChangeLog: -------------------------------------------------------------------------------- 1 | 2004-09-08 Taybin Rutkin 2 | * jackd.c: Better error reporting if/when dlopen() fails. 3 | 4 | 2003-03-05 Taybin Rutkin 5 | * jackd.c: added version flag. -V and --version are accepted. 6 | 7 | 2003-02-21 Paul Davis 8 | * jackd.c: modified signal catching design to actually follow 9 | sigwait() specifications (ie. install handlers for all blocked 10 | signals). also removed some dead code from benchmarking/debugging. 11 | 12 | 2003-2-10 Taybin Rutkin 13 | * Initial Changelog 14 | * engine.c (handle_new_client): Returns protocol version for checking. 15 | -------------------------------------------------------------------------------- /jackd/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | 3 | MAINTAINERCLEANFILES = Makefile.in jackd.1 jack_md5.h 4 | 5 | if USE_CAPABILITIES 6 | CAP_PROGS = jackstart 7 | CAP_LIBS = -lcap 8 | install-exec-hook: 9 | if [ "`id -u`" = "0" ]; \ 10 | then chown root.root $(DESTDIR)$(bindir)/jackd; \ 11 | chmod 555 $(DESTDIR)$(bindir)/jackd; \ 12 | chown root.root $(DESTDIR)$(bindir)/jackstart; \ 13 | chmod 4555 $(DESTDIR)$(bindir)/jackstart; \ 14 | else echo "You must be root to set ownership and permissions"; \ 15 | echo " for jackd and jackstart."; \ 16 | fi 17 | else 18 | CAP_PROGS = 19 | CAP_LIBS = 20 | install-exec-hook: 21 | @echo "Nothing to make for $@." 22 | endif 23 | 24 | bin_PROGRAMS = jackd $(CAP_PROGS) 25 | 26 | AM_CFLAGS = $(JACK_CFLAGS) -DJACK_LOCATION=\"$(bindir)\" 27 | 28 | jackd_SOURCES = jackd.c 29 | jackd_LDADD = libjackserver.la $(CAP_LIBS) @OS_LDFLAGS@ 30 | 31 | noinst_HEADERS = jack_md5.h md5.h md5_loc.h \ 32 | clientengine.h transengine.h 33 | 34 | BUILT_SOURCES = jack_md5.h 35 | 36 | jack_md5.h: jackd 37 | if STRIPPED_JACKD 38 | strip -R .note -R .comment .libs/jackd 39 | endif 40 | if USE_MD5SUM 41 | echo "#define JACKD_MD5_SUM \"`md5sum .libs/jackd | awk '{print $$1}'`\"" > jack_md5.h 42 | else 43 | echo "#define JACKD_MD5_SUM \"`md5 -q .libs/jackd | awk '{print $$1}'`\"" > jack_md5.h 44 | endif 45 | 46 | jackstart_SOURCES = jackstart.c md5.c 47 | jackstart_LDFLAGS = -lcap 48 | 49 | lib_LTLIBRARIES = libjackserver.la 50 | 51 | libjackserver_la_CFLAGS = $(AM_CFLAGS) 52 | 53 | libjackserver_la_SOURCES = engine.c clientengine.c transengine.c controlapi.c 54 | libjackserver_la_LIBADD = $(top_builddir)/libjack/simd.lo $(top_builddir)/libjack/libjackcommon.la $(top_builddir)/libjack/libjackdaemon.la -ldb @OS_LDFLAGS@ 55 | libjackserver_la_LDFLAGS = -export-dynamic -version-info @JACK_SO_VERSION@ 56 | 57 | man_MANS = jackd.1 jackstart.1 58 | EXTRA_DIST = $(man_MANS) 59 | 60 | dist-hook: 61 | rm -f $(distdir)/jack_md5.h 62 | distclean-local: 63 | rm -f $(top_builddir)/jackd/jack_md5.h 64 | -------------------------------------------------------------------------------- /jackd/clientengine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Client creation and destruction interfaces for JACK engine. 3 | * 4 | * Copyright (C) 2001-2003 Paul Davis 5 | * Copyright (C) 2004 Jack O'Quin 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License as 9 | * published by the Free Software Foundation; either version 2 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | * 21 | */ 22 | 23 | static inline int 24 | jack_client_is_internal (jack_client_internal_t *client) 25 | { 26 | return (client->control->type == ClientInternal) || 27 | (client->control->type == ClientDriver); 28 | } 29 | 30 | static inline char * 31 | jack_client_state_name (jack_client_internal_t *client) 32 | { 33 | static char *client_state_names[] = { 34 | "Not triggered", 35 | "Triggered", 36 | "Running", 37 | "Finished" 38 | }; 39 | 40 | return client_state_names[client->control->state]; 41 | } 42 | 43 | #define JACK_ERROR_WITH_SOCKETS 10000000 44 | 45 | int jack_client_activate(jack_engine_t *engine, jack_uuid_t id); 46 | int jack_client_deactivate(jack_engine_t *engine, jack_uuid_t id); 47 | int jack_client_create(jack_engine_t *engine, int client_fd); 48 | void jack_client_delete(jack_engine_t *engine, 49 | jack_client_internal_t *client); 50 | int jack_mark_client_socket_error(jack_engine_t *engine, int fd); 51 | jack_client_internal_t * 52 | jack_create_driver_client(jack_engine_t *engine, char *name); 53 | void jack_intclient_handle_request(jack_engine_t *engine, 54 | jack_request_t *req); 55 | void jack_intclient_load_request(jack_engine_t *engine, 56 | jack_request_t *req); 57 | void jack_intclient_name_request(jack_engine_t *engine, 58 | jack_request_t *req); 59 | void jack_intclient_unload_request(jack_engine_t *engine, 60 | jack_request_t *req); 61 | int jack_check_clients(jack_engine_t* engine, int with_timeout_check); 62 | void jack_remove_clients(jack_engine_t* engine, int* exit_freewheeling); 63 | void jack_client_registration_notify(jack_engine_t *engine, 64 | const char* name, int yn); 65 | void jack_property_change_notify(jack_engine_t *engine, jack_property_change_t change, jack_uuid_t uuid, const char* key); 66 | 67 | void jack_remove_client(jack_engine_t *engine, jack_client_internal_t *client); 68 | -------------------------------------------------------------------------------- /jackd/jackstart.1: -------------------------------------------------------------------------------- 1 | .so man1/jackd.1 2 | -------------------------------------------------------------------------------- /jackd/md5_loc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Local defines for the md5 functions. 3 | * 4 | */ 5 | 6 | /* 7 | * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 8 | * rights reserved. 9 | * 10 | * License to copy and use this software is granted provided that it is 11 | * identified as the "RSA Data Security, Inc. MD5 Message-Digest 12 | * Algorithm" in all material mentioning or referencing this software 13 | * or this function. 14 | * 15 | * License is also granted to make and use derivative works provided that 16 | * such works are identified as "derived from the RSA Data Security, 17 | * Inc. MD5 Message-Digest Algorithm" in all material mentioning or 18 | * referencing the derived work. 19 | * 20 | * RSA Data Security, Inc. makes no representations concerning either the 21 | * merchantability of this software or the suitability of this 22 | * software for any particular purpose. It is provided "as is" without 23 | * express or implied warranty of any kind. 24 | * 25 | * These notices must be retained in any copies of any part of this 26 | * documentation and/or software. 27 | */ 28 | 29 | #ifndef __MD5_LOC_H__ 30 | #define __MD5_LOC_H__ 31 | 32 | #define HEX_STRING "0123456789abcdef" /* to convert to hex */ 33 | #define BLOCK_SIZE_MASK (MD5_BLOCK_SIZE - 1) 34 | 35 | 36 | #include 37 | 38 | /* 39 | * Define my endian-ness. Could not do in a portable manner using the 40 | * include files -- grumble. 41 | */ 42 | #ifdef WORDS_BIGENDIAN 43 | /* 44 | * big endian - big is better 45 | */ 46 | #define SWAP(n) \ 47 | (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) 48 | #else 49 | /* 50 | + * little endian 51 | + */ 52 | #define SWAP(n) (n) 53 | #endif 54 | 55 | /* 56 | * These are the four functions used in the four steps of the MD5 57 | * algorithm and defined in the RFC 1321. The first function is a 58 | * little bit optimized (as found in Colin Plumbs public domain 59 | * implementation). 60 | */ 61 | /* #define FF(b, c, d) ((b & c) | (~b & d)) */ 62 | #define FF(b, c, d) (d ^ (b & (c ^ d))) 63 | #define FG(b, c, d) FF (d, b, c) 64 | #define FH(b, c, d) (b ^ c ^ d) 65 | #define FI(b, c, d) (c ^ (b | ~d)) 66 | 67 | /* 68 | * It is unfortunate that C does not provide an operator for cyclic 69 | * rotation. Hope the C compiler is smart enough. -- Modified to 70 | * remove the w = at the front - Gray 2/97 71 | */ 72 | #define CYCLIC(w, s) ((w << s) | (w >> (32 - s))) 73 | 74 | /* 75 | * First Round: using the given function, the context and a constant 76 | * the next context is computed. Because the algorithms processing 77 | * unit is a 32-bit word and it is determined to work on words in 78 | * little endian byte order we perhaps have to change the byte order 79 | * before the computation. To reduce the work for the next steps we 80 | * store the swapped words in the array CORRECT_WORDS. -- Modified to 81 | * fix the handling of unaligned buffer spaces - Gray 7/97 82 | */ 83 | #define OP1(a, b, c, d, b_p, c_p, s, T) \ 84 | do { \ 85 | memcpy (c_p, b_p, sizeof(md5_uint32)); \ 86 | *c_p = SWAP (*c_p); \ 87 | a += FF (b, c, d) + *c_p + T; \ 88 | a = CYCLIC (a, s); \ 89 | a += b; \ 90 | b_p = (char*)b_p + sizeof(md5_uint32); \ 91 | c_p++; \ 92 | } while (0) 93 | 94 | /* 95 | * Second to Fourth Round: we have the possibly swapped words in 96 | * CORRECT_WORDS. Redefine the macro to take an additional first 97 | * argument specifying the function to use. 98 | */ 99 | #define OP234(FUNC, a, b, c, d, k, s, T) \ 100 | do { \ 101 | a += FUNC (b, c, d) + k + T; \ 102 | a = CYCLIC (a, s); \ 103 | a += b; \ 104 | } while (0) 105 | 106 | #endif /* ! __MD5_LOC_H__ */ 107 | -------------------------------------------------------------------------------- /jackd/transengine.h: -------------------------------------------------------------------------------- 1 | /* 2 | Internal interfaces for JACK transport engine. 3 | 4 | Copyright (C) 2003 Jack O'Quin 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License as 8 | published by the Free Software Foundation; either version 2 of the 9 | License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | int jack_set_sample_rate(jack_engine_t *engine, jack_nframes_t nframes); 22 | int jack_timebase_reset(jack_engine_t *engine, 23 | jack_uuid_t client_id); 24 | int jack_timebase_set(jack_engine_t *engine, 25 | jack_uuid_t client_id, int conditional); 26 | void jack_transport_activate(jack_engine_t *engine, 27 | jack_client_internal_t *client); 28 | void jack_transport_init(jack_engine_t *engine); 29 | void jack_transport_client_exit(jack_engine_t *engine, 30 | jack_client_internal_t *client); 31 | void jack_transport_client_new(jack_client_internal_t *client); 32 | int jack_transport_client_reset_sync(jack_engine_t *engine, 33 | jack_uuid_t client_id); 34 | int jack_transport_client_set_sync(jack_engine_t *engine, 35 | jack_uuid_t client_id); 36 | void jack_transport_cycle_end(jack_engine_t *engine); 37 | void jack_transport_cycle_start(jack_engine_t *engine, jack_time_t time); 38 | int jack_transport_set_sync_timeout(jack_engine_t *engine, 39 | jack_time_t usecs); 40 | -------------------------------------------------------------------------------- /libjack/ChangeLog: -------------------------------------------------------------------------------- 1 | 2005-04-15 Paul Davis 2 | 3 | * change the way threads get RT scheduling. it is now requested by 4 | the thread rather than assigned by the thread's parent. in cases 5 | where capabilities are used, the child is also given capabilities 6 | so that it can release + re-acquire RT scheduling as needed. 7 | 8 | * prevent watchdog from killing anything is JACK is freewheeling. 9 | 10 | 2004-12-31 Jack O'Quin 11 | 12 | * new header file: 13 | 14 | 2004-12-27 Jack O'Quin 15 | 16 | * new API functions jack_get_max_delayed_usecs() and 17 | jack_reset_max_delayed_usecs() 18 | 19 | * add US-X2Y USB device support to ALSA backend 20 | 21 | 2004-11-28 Jack O'Quin 22 | 23 | * removed deprecated function jack_set_server_dir(). 24 | 25 | 2004-11-27 Jack O'Quin 26 | 27 | * new API functions: jack_internal_client_handle(), 28 | jack_internal_client_load(), jack_get_internal_client_name(), 29 | jack_internal_client_unload(). See: . 30 | 31 | 2004-10-14 Jack O'Quin 32 | 33 | * new API function: jack_get_xrun_delayed_usecs() 34 | 35 | 2004-10-08 Jack O'Quin 36 | 37 | * new API functions: jack_client_open(), jack_get_client_name() 38 | 39 | 2004-09-15 Jack O'Quin 40 | 41 | * new API functions from 42 | 43 | 2004-07-08 Jack O'Quin 44 | 45 | * add jack_ringbuffer_peek() 46 | 47 | 2004-02-19 Jack O'Quin 48 | 49 | * new API functions: 50 | 51 | int jack_client_name_size(void); 52 | int jack_port_name_size(void); 53 | int jack_port_type_size(void); 54 | 55 | 2004-02-16 Jack O'Quin 56 | 57 | * Changed JACK_PORT_NAME_SIZE from 32 to 256 58 | 59 | This could affect some client that defines its own value. 60 | 61 | 2003-10-15 Paul Davis 62 | 63 | * new ring buffer interface: 64 | 65 | 2003-10-07 Paul Davis 66 | 67 | * new function jack_set_freewheel(). 68 | 69 | No compatibility issues: this introduces new functionality to 70 | JACK and doesn't alter any existing functionality. 71 | 72 | 2003-09-18 Jack O'Quin 73 | 74 | * new function jack_set_buffer_size(). 75 | 76 | Compatibility issues: programs that rely on the buffer size but do 77 | not register a callback will fail. Cached output buffer addresses 78 | are not valid after the buffer size changes. These rules existed 79 | before, but were never enforced. 80 | 81 | 2003-08-26 Jack O'Quin 82 | 83 | * typedefs are now defined using the C99 standard 84 | fixed-size integer typedefs. These new typedefs are binary 85 | compatible with 32-bit platforms, but not 64-bit machines. 86 | 87 | Programs using printf on these values will get GCC compiler 88 | warnings. To suppress the warnings, use the corresponding C99 89 | printf specifications defined in . That header is 90 | already implicitly included by , but can also be 91 | included explicitly to maintain compatibility with older versions 92 | of JACK without messy #ifdef's. Adding explicit casts will also 93 | work, but may suppress future warnings you might want to see. 94 | 95 | * jack_get_sample_rate() now returns jack_nframes_t rather than 96 | unsigned long. These are the same on 32-bit machines, but not on 97 | 64-bit platforms. 98 | 99 | 2003-08-13 Jack O'Quin 100 | 101 | * Many new transport interfaces. It would be silly to list them 102 | all here. Please see the new transport control section in the 103 | JACK reference manual. 104 | 105 | * jack_set_transport_info() and jack_engine_takeover_timebase(), 106 | (the old timebase master interfaces) now do nothing. Instead, use 107 | jack_set_timebase_callback(). 108 | 109 | 2003-05-09 Jack O'Quin 110 | 111 | * Added new jack_is_realtime() function. 112 | 113 | 2003-02-23 Paul Davis 114 | 115 | * client.c: 116 | 117 | added deliver_request(). 118 | removed all use of strncpy(). 119 | changed ClientDynamic to ClientInProcess. 120 | 121 | 2003-02-10 Taybin Rutkin 122 | 123 | * client.c (jack_client_new): Checks jack_protocol_version returned 124 | from jackd. 125 | 126 | 2003-02-05 Kai Vehmanen 127 | 128 | * client.c (jack_set_buffer_size_callback): This function is now 129 | deprecated. 130 | 131 | 2002-12-20 Paul Davis 132 | 133 | * error.h (jack_set_error_function): added 134 | 135 | 2002-12-16 Paul Davis 136 | 137 | * jack.h: added inclusion of pthread.h 138 | 139 | 2002-12-09 Paul Davis 140 | 141 | * jack.h (jack_client_new_inprocess): prototype for in-process client creation (not implemented) 142 | 143 | * jack.h (jack_client_thread_id): added so that clients can easily 144 | find out the pthread_t that is running the JACK client code. this 145 | turns out to be critical to handling the SIGHUP. 146 | 147 | 2002-11-15 Paul Davis 148 | 149 | * client.c: added port alias functions. untested. 150 | 151 | 2002-11-05 Kai Vehmanen 152 | 153 | * Created this file. Current JACK version is 154 | 0.39.0 and libjack interface 0:5:0. See 155 | jack/README.developers for details on how to 156 | use this file. 157 | -------------------------------------------------------------------------------- /libjack/Makefile.am: -------------------------------------------------------------------------------- 1 | MAINTAINERCLEANFILES = Makefile.in 2 | 3 | if USE_POSIX_SHM 4 | install-exec-hook: 5 | @echo "Nothing to make for $@." 6 | else 7 | install-exec-hook: 8 | @echo "Removing JACK shared memory registry key " $(JACK_SEMAPHORE_KEY) 9 | -ipcrm -M $(JACK_SEMAPHORE_KEY) 10 | endif 11 | 12 | SOURCE_FILES = \ 13 | client.c \ 14 | intclient.c \ 15 | messagebuffer.c \ 16 | metadata.c \ 17 | midiport.c \ 18 | pool.c \ 19 | port.c \ 20 | ringbuffer.c \ 21 | shm.c \ 22 | thread.c \ 23 | time.c \ 24 | transclient.c \ 25 | unlock.c \ 26 | uuid.c 27 | 28 | simd.lo: $(srcdir)/simd.c 29 | $(LIBTOOL) --mode=compile $(CC) -I$(top_builddir) $(JACK_CORE_CFLAGS) $(SIMD_CFLAGS) -c -o simd.lo $(srcdir)/simd.c 30 | 31 | lib_LTLIBRARIES = libjack.la 32 | 33 | noinst_HEADERS = local.h 34 | 35 | AM_CFLAGS = $(JACK_CFLAGS) -DJACK_LOCATION=\"$(bindir)\" 36 | AM_CXXFLAGS = $(JACK_CFLAGS) 37 | 38 | libjack_la_SOURCES = 39 | libjack_la_LIBADD = libjackcommon.la simd.lo -ldb @OS_LDFLAGS@ 40 | libjack_la_LDFLAGS = -export-dynamic -version-info @JACK_SO_VERSION@ 41 | 42 | noinst_LTLIBRARIES = libjackcommon.la libjackdaemon.la 43 | 44 | libjackcommon_la_CFLAGS = $(AM_CFLAGS) 45 | libjackcommon_la_SOURCES = \ 46 | client.c \ 47 | intclient.c \ 48 | messagebuffer.c \ 49 | metadata.c \ 50 | midiport.c \ 51 | pool.c \ 52 | port.c \ 53 | ringbuffer.c \ 54 | shm.c \ 55 | thread.c \ 56 | time.c \ 57 | transclient.c \ 58 | unlock.c \ 59 | uuid.c 60 | 61 | libjackdaemon_la_CFLAGS = $(AM_CFLAGS) 62 | libjackdaemon_la_SOURCES = \ 63 | driver.c \ 64 | systemtest.c \ 65 | sanitycheck.c 66 | -------------------------------------------------------------------------------- /libjack/local.h: -------------------------------------------------------------------------------- 1 | #ifndef __jack_libjack_local_h__ 2 | #define __jack_libjack_local_h__ 3 | 4 | /* Client data structure, in the client address space. */ 5 | struct _jack_client { 6 | 7 | jack_control_t *engine; 8 | jack_client_control_t *control; 9 | jack_shm_info_t engine_shm; 10 | jack_shm_info_t control_shm; 11 | 12 | struct pollfd* pollfd; 13 | int pollmax; 14 | int graph_next_fd; 15 | int request_fd; 16 | int upstream_is_jackd; 17 | 18 | /* these two are copied from the engine when the 19 | * client is created. 20 | */ 21 | 22 | jack_port_type_id_t n_port_types; 23 | jack_shm_info_t* port_segment; 24 | 25 | JSList *ports; 26 | JSList *ports_ext; 27 | 28 | pthread_t thread; 29 | char fifo_prefix[PATH_MAX + 1]; 30 | void (*on_shutdown)(void *arg); 31 | void *on_shutdown_arg; 32 | void (*on_info_shutdown)(jack_status_t, const char*, void *arg); 33 | void *on_info_shutdown_arg; 34 | char thread_ok : 1; 35 | char first_active : 1; 36 | pthread_t thread_id; 37 | char name[JACK_CLIENT_NAME_SIZE]; 38 | int session_cb_immediate_reply; 39 | 40 | #ifdef JACK_USE_MACH_THREADS 41 | /* specific ressources for server/client real-time thread communication */ 42 | mach_port_t clienttask, bp, serverport, replyport; 43 | trivial_message message; 44 | pthread_t process_thread; 45 | char rt_thread_ok : 1; 46 | #endif 47 | 48 | /* callbacks 49 | */ 50 | JackProcessCallback process; 51 | void *process_arg; 52 | JackThreadInitCallback thread_init; 53 | void *thread_init_arg; 54 | JackBufferSizeCallback bufsize; 55 | void *bufsize_arg; 56 | JackSampleRateCallback srate; 57 | void *srate_arg; 58 | JackPortRegistrationCallback port_register; 59 | void *port_register_arg; 60 | JackPortConnectCallback port_connect; 61 | void *port_connect_arg; 62 | JackGraphOrderCallback graph_order; 63 | void *graph_order_arg; 64 | JackXRunCallback xrun; 65 | void *xrun_arg; 66 | JackSyncCallback sync_cb; 67 | void *sync_arg; 68 | JackTimebaseCallback timebase_cb; 69 | void *timebase_arg; 70 | JackFreewheelCallback freewheel_cb; 71 | void *freewheel_arg; 72 | JackClientRegistrationCallback client_register; 73 | void *client_register_arg; 74 | JackThreadCallback thread_cb; 75 | void *thread_cb_arg; 76 | JackSessionCallback session_cb; 77 | void *session_cb_arg; 78 | JackLatencyCallback latency_cb; 79 | void *latency_cb_arg; 80 | JackPropertyChangeCallback property_cb; 81 | void *property_cb_arg; 82 | JackPortRenameCallback port_rename_cb; 83 | void *port_rename_arg; 84 | 85 | /* external clients: set by libjack 86 | * internal clients: set by engine */ 87 | int (*deliver_request)(void*, jack_request_t*); /* JOQ: 64/32 bug! */ 88 | void *deliver_arg; 89 | 90 | }; 91 | 92 | extern int jack_client_deliver_request(const jack_client_t *client, 93 | jack_request_t *req); 94 | extern jack_port_t *jack_port_new(const jack_client_t *client, 95 | jack_port_id_t port_id, 96 | jack_control_t *control); 97 | 98 | extern void *jack_zero_filled_buffer; 99 | 100 | extern void jack_set_clock_source (jack_timer_type_t); 101 | extern char* jack_server_dir(const char* server_name, char* server_dir); 102 | 103 | #endif /* __jack_libjack_local_h__ */ 104 | -------------------------------------------------------------------------------- /libjack/messagebuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * messagebuffer.c -- realtime-safe message handling for jackd. 3 | * 4 | * This interface is included in libjack so backend drivers can use 5 | * it, *not* for external client processes. It implements the 6 | * VERBOSE() and MESSAGE() macros in a realtime-safe manner. 7 | */ 8 | 9 | /* 10 | * Copyright (C) 2004 Rui Nuno Capela, Steve Harris 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU Lesser General Public License as published by 14 | * the Free Software Foundation; either version 2.1 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public License 23 | * along with this program; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25 | * 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "messagebuffer.h" 35 | #include "atomicity.h" 36 | #include "internal.h" 37 | 38 | /* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */ 39 | #define MB_BUFFERS 128 40 | #define MB_NEXT(index) ((index + 1) & (MB_BUFFERS - 1)) 41 | #define MB_BUFFERSIZE 256 /* message length limit */ 42 | 43 | static char mb_buffers[MB_BUFFERS][MB_BUFFERSIZE]; 44 | static volatile unsigned int mb_initialized = 0; 45 | static volatile unsigned int mb_inbuffer = 0; 46 | static volatile unsigned int mb_outbuffer = 0; 47 | static volatile _Atomic_word mb_overruns = 0; 48 | static pthread_t mb_writer_thread; 49 | static pthread_mutex_t mb_write_lock; 50 | static pthread_cond_t mb_ready_cond; 51 | static void (*mb_thread_init_callback)(void*) = 0; 52 | static void* mb_thread_init_callback_arg = 0; 53 | 54 | static void 55 | mb_flush () 56 | { 57 | /* called WITHOUT the mb_write_lock */ 58 | while (mb_outbuffer != mb_inbuffer) { 59 | jack_info (mb_buffers[mb_outbuffer]); 60 | mb_outbuffer = MB_NEXT (mb_outbuffer); 61 | } 62 | } 63 | 64 | static void * 65 | mb_thread_func (void *arg) 66 | { 67 | /* The mutex is only to eliminate collisions between multiple 68 | * writer threads and protect the condition variable. */ 69 | pthread_mutex_lock (&mb_write_lock); 70 | 71 | while (mb_initialized) { 72 | pthread_cond_wait (&mb_ready_cond, &mb_write_lock); 73 | 74 | if (mb_thread_init_callback) { 75 | /* the client asked for all threads to run a thread 76 | initialization callback, which includes us. 77 | */ 78 | mb_thread_init_callback (mb_thread_init_callback_arg); 79 | mb_thread_init_callback = 0; 80 | 81 | /* note that we've done it */ 82 | pthread_cond_signal (&mb_ready_cond); 83 | } 84 | 85 | /* releasing the mutex reduces contention */ 86 | pthread_mutex_unlock (&mb_write_lock); 87 | mb_flush (); 88 | pthread_mutex_lock (&mb_write_lock); 89 | } 90 | 91 | pthread_mutex_unlock (&mb_write_lock); 92 | 93 | return NULL; 94 | } 95 | 96 | void 97 | jack_messagebuffer_init () 98 | { 99 | if (mb_initialized) { 100 | return; 101 | } 102 | 103 | pthread_mutex_init (&mb_write_lock, NULL); 104 | pthread_cond_init (&mb_ready_cond, NULL); 105 | 106 | mb_overruns = 0; 107 | mb_initialized = 1; 108 | 109 | if (jack_thread_creator (&mb_writer_thread, NULL, &mb_thread_func, NULL) != 0) { 110 | mb_initialized = 0; 111 | } 112 | } 113 | 114 | void 115 | jack_messagebuffer_exit () 116 | { 117 | if (!mb_initialized) { 118 | return; 119 | } 120 | 121 | pthread_mutex_lock (&mb_write_lock); 122 | mb_initialized = 0; 123 | pthread_cond_signal (&mb_ready_cond); 124 | pthread_mutex_unlock (&mb_write_lock); 125 | 126 | pthread_join (mb_writer_thread, NULL); 127 | mb_flush (); 128 | 129 | if (mb_overruns) { 130 | jack_error ("WARNING: %d message buffer overruns!", 131 | mb_overruns); 132 | } 133 | 134 | pthread_mutex_destroy (&mb_write_lock); 135 | pthread_cond_destroy (&mb_ready_cond); 136 | } 137 | 138 | 139 | void 140 | jack_messagebuffer_add (const char *fmt, ...) 141 | { 142 | char msg[MB_BUFFERSIZE]; 143 | va_list ap; 144 | 145 | /* format the message first, to reduce lock contention */ 146 | va_start (ap, fmt); 147 | vsnprintf (msg, MB_BUFFERSIZE, fmt, ap); 148 | va_end (ap); 149 | 150 | if (!mb_initialized) { 151 | /* Unable to print message with realtime safety. 152 | * Complain and print it anyway. */ 153 | fprintf (stderr, "ERROR: messagebuffer not initialized: %s", 154 | msg); 155 | return; 156 | } 157 | 158 | if (pthread_mutex_trylock (&mb_write_lock) == 0) { 159 | strncpy (mb_buffers[mb_inbuffer], msg, MB_BUFFERSIZE); 160 | mb_inbuffer = MB_NEXT (mb_inbuffer); 161 | pthread_cond_signal (&mb_ready_cond); 162 | pthread_mutex_unlock (&mb_write_lock); 163 | } else { /* lock collision */ 164 | exchange_and_add (&mb_overruns, 1); 165 | } 166 | } 167 | 168 | void 169 | jack_messagebuffer_thread_init (void (*cb)(void*), void* arg) 170 | { 171 | pthread_mutex_lock (&mb_write_lock); 172 | 173 | /* set up the callback */ 174 | mb_thread_init_callback_arg = arg; 175 | mb_thread_init_callback = cb; 176 | 177 | /* wake msg buffer thread */ 178 | pthread_cond_signal (&mb_ready_cond); 179 | 180 | /* wait for it to be done */ 181 | pthread_cond_wait (&mb_ready_cond, &mb_write_lock); 182 | 183 | /* and we're done */ 184 | pthread_mutex_unlock (&mb_write_lock); 185 | } 186 | -------------------------------------------------------------------------------- /libjack/pool.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2003 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #include 21 | 22 | #ifdef HAVE_POSIX_MEMALIGN 23 | #define _XOPEN_SOURCE 600 24 | #endif 25 | #include 26 | #include 27 | 28 | #include "pool.h" 29 | 30 | /* XXX need RT-pool based allocator here */ 31 | void * 32 | jack_pool_alloc (size_t bytes) 33 | { 34 | #ifdef HAVE_POSIX_MEMALIGN 35 | void* m; 36 | int err = posix_memalign (&m, 64, bytes); 37 | return (!err) ? m : 0; 38 | #else 39 | return malloc (bytes); 40 | #endif /* HAVE_POSIX_MEMALIGN */ 41 | } 42 | 43 | void 44 | jack_pool_release (void *ptr) 45 | { 46 | free (ptr); 47 | } 48 | -------------------------------------------------------------------------------- /libjack/sanitycheck.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2003 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #include 21 | -------------------------------------------------------------------------------- /libjack/systemtest.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2001-2003 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #include 21 | -------------------------------------------------------------------------------- /libjack/time.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "bsd"; -*- */ 2 | /* 3 | Copyright (C) 2001-2003 Paul Davis 4 | Copyright (C) 2005 Jussi Laako 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 2.1 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #ifdef HAVE_STDINT_H 28 | #include 29 | #endif 30 | #include 31 | #include 32 | #include 33 | 34 | #include "internal.h" 35 | #include "engine.h" 36 | 37 | #include 38 | 39 | #include 40 | 41 | #include "local.h" 42 | 43 | const char* 44 | jack_clock_source_name (jack_timer_type_t src) 45 | { 46 | switch (src) { 47 | case JACK_TIMER_HPET: 48 | return "hpet"; 49 | case JACK_TIMER_SYSTEM_CLOCK: 50 | #if HAVE_CLOCK_GETTIME 51 | return "system clock via clock_gettime"; 52 | #else 53 | return "system clock via gettimeofday"; 54 | #endif 55 | } 56 | 57 | /* what is wrong with gcc ? */ 58 | 59 | return "unknown"; 60 | } 61 | 62 | #if HAVE_CLOCK_GETTIME 63 | 64 | jack_time_t 65 | jack_get_microseconds_from_system (void) 66 | { 67 | jack_time_t jackTime; 68 | struct timespec time; 69 | 70 | clock_gettime (CLOCK_MONOTONIC, &time); 71 | jackTime = (jack_time_t)time.tv_sec * 1e6 + 72 | (jack_time_t)time.tv_nsec / 1e3; 73 | return jackTime; 74 | } 75 | 76 | #else 77 | 78 | jack_time_t 79 | jack_get_microseconds_from_system (void) 80 | { 81 | jack_time_t jackTime; 82 | struct timeval tv; 83 | 84 | gettimeofday (&tv, NULL); 85 | jackTime = (jack_time_t)tv.tv_sec * 1000000 + (jack_time_t)tv.tv_usec; 86 | return jackTime; 87 | } 88 | 89 | #endif /* HAVE_CLOCK_GETTIME */ 90 | 91 | /* everything below here should be system-dependent */ 92 | 93 | #include 94 | 95 | 96 | -------------------------------------------------------------------------------- /libjack/unlock.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "bsd"; -*- */ 2 | /* 3 | Copyright (C) 2004 Paul Davis 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 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "unlock.h" 28 | #include "internal.h" 29 | 30 | static char* blacklist[] = { 31 | "/libgtk", 32 | "/libqt", 33 | "/libfltk", 34 | "/wine/", 35 | NULL 36 | }; 37 | 38 | static char* whitelist[] = { 39 | "/libc-", 40 | "/libardour", 41 | NULL 42 | }; 43 | 44 | static char* library_roots[] = { 45 | "/lib", 46 | "/usr/lib", 47 | "/usr/local/lib", 48 | "/usr/X11R6/lib", 49 | "/opt/lib", /* solaris-y */ 50 | "/opt/local/lib", /* common on OS X */ 51 | NULL 52 | }; 53 | 54 | void 55 | cleanup_mlock () 56 | { 57 | FILE* map; 58 | size_t start; 59 | size_t end; 60 | char path[PATH_MAX + 1]; 61 | int unlock; 62 | int i; 63 | int whoknows; 64 | int looks_like_library; 65 | 66 | snprintf (path, sizeof(path), "/proc/%d/maps", getpid ()); 67 | 68 | if ((map = fopen (path, "r")) == NULL) { 69 | jack_error ("can't open map file"); 70 | return; 71 | } 72 | 73 | while (!feof (map)) { 74 | 75 | unlock = 0; 76 | 77 | if (fscanf (map, "%zx-%zx %*s %*x %*d:%*d %d", 78 | &start, &end, &whoknows) != 3) { 79 | break; 80 | } 81 | 82 | if (!whoknows) { 83 | continue; 84 | } 85 | 86 | fscanf (map, " %[^\n]", path); 87 | 88 | /* if it doesn't look like a library, forget it */ 89 | 90 | looks_like_library = 0; 91 | 92 | for (i = 0; library_roots[i]; ++i) { 93 | if ((looks_like_library = (strstr (path, library_roots[i]) == path))) { 94 | break; 95 | } 96 | } 97 | 98 | if (!looks_like_library) { 99 | continue; 100 | } 101 | 102 | for (i = 0; blacklist[i]; ++i) { 103 | if (strstr (path, blacklist[i])) { 104 | unlock = 1; 105 | break; 106 | } 107 | } 108 | 109 | if (end - start > 1048576) { 110 | unlock = 1; 111 | } 112 | 113 | for (i = 0; whitelist[i]; ++i) { 114 | if (strstr (path, whitelist[i])) { 115 | unlock = 0; 116 | break; 117 | } 118 | } 119 | 120 | if (unlock) { 121 | jack_info ("unlocking %s", path); 122 | munlock ((char*)start, end - start); 123 | } 124 | } 125 | 126 | fclose (map); 127 | } 128 | 129 | 130 | -------------------------------------------------------------------------------- /libjack/uuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2013 Paul Davis 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "internal.h" 27 | 28 | static pthread_mutex_t uuid_lock = PTHREAD_MUTEX_INITIALIZER; 29 | static uint32_t uuid_cnt = 0; 30 | 31 | enum JackUUIDType { 32 | JackUUIDPort = 0x1, 33 | JackUUIDClient = 0x2 34 | }; 35 | 36 | jack_uuid_t 37 | jack_client_uuid_generate () 38 | { 39 | jack_uuid_t uuid = JackUUIDClient; 40 | 41 | pthread_mutex_lock (&uuid_lock); 42 | uuid = (uuid << 32) | ++uuid_cnt; 43 | pthread_mutex_unlock (&uuid_lock); 44 | return uuid; 45 | } 46 | 47 | jack_uuid_t 48 | jack_port_uuid_generate (uint32_t port_id) 49 | { 50 | jack_uuid_t uuid = JackUUIDPort; 51 | 52 | uuid = (uuid << 32) | (port_id + 1); 53 | return uuid; 54 | } 55 | 56 | uint32_t 57 | jack_uuid_to_index (jack_uuid_t u) 58 | { 59 | return (u & 0xffff) - 1; 60 | } 61 | 62 | int 63 | jack_uuid_empty (jack_uuid_t u) 64 | { 65 | return u == 0; 66 | } 67 | 68 | int 69 | jack_uuid_compare (jack_uuid_t a, jack_uuid_t b) 70 | { 71 | if (a == b) { 72 | return 0; 73 | } 74 | 75 | if (a < b) { 76 | return -1; 77 | } 78 | 79 | return 1; 80 | } 81 | 82 | void 83 | jack_uuid_copy (jack_uuid_t* dst, jack_uuid_t src) 84 | { 85 | *dst = src; 86 | } 87 | 88 | void 89 | jack_uuid_clear (jack_uuid_t* u) 90 | { 91 | *u = 0; 92 | } 93 | 94 | void 95 | jack_uuid_unparse (jack_uuid_t u, char b[JACK_UUID_STRING_SIZE]) 96 | { 97 | snprintf (b, JACK_UUID_STRING_SIZE, "%" PRIu64, u); 98 | } 99 | 100 | int 101 | jack_uuid_parse (const char *b, jack_uuid_t* u) 102 | { 103 | if (sscanf (b, "%" PRIu64, u) == 1) { 104 | 105 | if (*u < (0x1LL << 32)) { 106 | /* has not type bits set - not legal */ 107 | return -1; 108 | } 109 | 110 | return 0; 111 | } 112 | 113 | return -1; 114 | } 115 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | .0.1: 2 | @[ -z "$$SOURCE_DATE_EPOCH" ] || d=--date=@$$SOURCE_DATE_EPOCH ; sed -e "s/!VERSION!/@JACK_RELEASE@/g" -e "s/!DATE!/`LC_ALL=C date $$d '+%B %Y'`/g" < $*.0 > $@ 3 | @echo Built $*.1 from template 4 | 5 | manpages = $(patsubst %.0,%.1,$(wildcard *.0)) 6 | 7 | clean-local: 8 | -rm -rf $(manpages) 9 | 10 | man1_MANS = $(manpages) 11 | 12 | BUILT_SOURCES = $(manpages) 13 | 14 | #dist_man_MANS = $(manpages) 15 | -------------------------------------------------------------------------------- /python/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_SCRIPTS = jackd.py 2 | EXTRA_DIST = jackd.py jackctl.py mygetopt.py reserve_audio.py 3 | 4 | -------------------------------------------------------------------------------- /python/jackd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | from pyjackd.mygetopt import my_getopt 5 | from pyjackd import jackctl 6 | import readline 7 | import time 8 | 9 | import reserve_audio 10 | 11 | argv = sys.argv[1:] 12 | 13 | 14 | 15 | def server_parse_ags( srv, argv ): 16 | shortopts = "" 17 | longopts = [] 18 | shortmap = {} 19 | driver = None 20 | 21 | for param in srv.params: 22 | p = srv.params[param] 23 | shortopts += p.id 24 | if p.param_type != 5: 25 | shortopts += ":" 26 | longopts.append (p.name + "=") 27 | else: 28 | longopts.append (p.name) 29 | 30 | shortmap[p.id] = p 31 | 32 | while not driver: 33 | opts, argv = my_getopt( argv, shortopts+"d:" ) 34 | if not opts: 35 | break 36 | for opt,optarg in opts: 37 | if opt == "-d": 38 | driver = srv.drivers[optarg] 39 | elif opt.startswith("--"): 40 | pass 41 | elif opt.startswith("-"): 42 | p = shortmap[opt[1]] 43 | if p.param_type == 5: 44 | p.value = True 45 | else: 46 | p.value = optarg 47 | 48 | return driver, argv 49 | 50 | def driver_parse_args( drv, argv ): 51 | shortopts = "" 52 | longopts = [] 53 | shortmap = {} 54 | 55 | for param in drv.params: 56 | p = drv.params[param] 57 | shortopts += p.id 58 | if p.param_type != 5: 59 | shortopts += ":" 60 | longopts.append (p.name + "=") 61 | else: 62 | longopts.append (p.name) 63 | 64 | shortmap[p.id] = p 65 | 66 | while True: 67 | opts, argv = my_getopt( argv, shortopts+"d:" ) 68 | if not opts: 69 | break 70 | for opt,optarg in opts: 71 | if opt.startswith("--"): 72 | pass 73 | elif opt.startswith("-"): 74 | p = shortmap[opt[1]] 75 | if p.param_type == 5: 76 | p.value = True 77 | else: 78 | p.value = optarg 79 | 80 | def acquire_dev(cardname): 81 | reserve_audio.reserve_dev(cardname,20,None) 82 | time.sleep(0.1) 83 | return True 84 | 85 | def release_dev(cardname): 86 | reserve_audio.rr.unreserve() 87 | reserve_audio.rr = None 88 | 89 | srv = jackctl.Server() 90 | srv.acquire_card_cb = acquire_dev 91 | srv.release_card_cb = release_dev 92 | 93 | drv, argv = server_parse_ags( srv, argv ) 94 | driver_parse_args( drv, argv ) 95 | 96 | #for p in srv.params.values(): 97 | # print p.name, "-> ", p.value 98 | # 99 | #print "----------------" 100 | #print "driver ", drv.name 101 | # 102 | #for p in drv.params.values(): 103 | # print p.name, "-> ", p.value 104 | 105 | started = srv.start( drv ) 106 | 107 | if not started: 108 | print "failed to start with driver " + drv.name 109 | print "trying to start with dummy driver, switch to the right master yourself" 110 | 111 | started = srv.start( srv.drivers["dummy"] ) 112 | 113 | if not started: 114 | sys.exit(20) 115 | 116 | quit = False 117 | while not quit: 118 | try: 119 | cmd = raw_input("jack> ") 120 | except EOFError: 121 | break 122 | 123 | cmdv = cmd.split() 124 | 125 | if len(cmdv) == 0: 126 | continue 127 | 128 | if cmdv[0] == "quit": 129 | quit = True 130 | elif cmdv[0] == "switch": 131 | if len(cmdv) > 1: 132 | drv = srv.drivers[cmdv[1]] 133 | driver_parse_args( drv, cmdv[2:] ) 134 | srv.switch_master( drv ) 135 | 136 | print "\nshutting down" 137 | srv.stop() 138 | -------------------------------------------------------------------------------- /python/mygetopt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import getopt 4 | 5 | def my_getopt(args, shortopts, longopts = []): 6 | """getopt(args, options[, long_options]) -> opts, args 7 | 8 | Parses command line options and parameter list. args is the 9 | argument list to be parsed, without the leading reference to the 10 | running program. Typically, this means "sys.argv[1:]". shortopts 11 | is the string of option letters that the script wants to 12 | recognize, with options that require an argument followed by a 13 | colon (i.e., the same format that Unix getopt() uses). If 14 | specified, longopts is a list of strings with the names of the 15 | long options which should be supported. The leading '--' 16 | characters should not be included in the option name. Options 17 | which require an argument should be followed by an equal sign 18 | ('='). 19 | 20 | The return value consists of two elements: the first is a list of 21 | (option, value) pairs; the second is the list of program arguments 22 | left after the option list was stripped (this is a trailing slice 23 | of the first argument). Each option-and-value pair returned has 24 | the option as its first element, prefixed with a hyphen (e.g., 25 | '-x'), and the option argument as its second element, or an empty 26 | string if the option has no argument. The options occur in the 27 | list in the same order in which they were found, thus allowing 28 | multiple occurrences. Long and short options may be mixed. 29 | 30 | """ 31 | 32 | opts = [] 33 | if type(longopts) == type(""): 34 | longopts = [longopts] 35 | else: 36 | longopts = list(longopts) 37 | if args and args[0].startswith('-') and args[0] != '-': 38 | if args[0] == '--': 39 | args = args[1:] 40 | if args[0].startswith('--'): 41 | opts, args = getopt.do_longs(opts, args[0][2:], longopts, args[1:]) 42 | else: 43 | opts, args = getopt.do_shorts(opts, args[0][1:], shortopts, args[1:]) 44 | 45 | return opts, args 46 | else: 47 | return None, args 48 | 49 | -------------------------------------------------------------------------------- /python/reserve_audio.py: -------------------------------------------------------------------------------- 1 | 2 | import dbus.service 3 | import gobject 4 | import dbus.mainloop.glib 5 | 6 | rr = None 7 | 8 | class reservation_t( dbus.service.Object ): 9 | def __init__( self, device_name, prio, override_cb=None ): 10 | 11 | self.dev_name = device_name 12 | self.prio = prio 13 | self.override_cb = override_cb 14 | 15 | self.bus = dbus.SessionBus() 16 | 17 | dbus.service.Object.__init__( self, None, 18 | "/org/freedesktop/ReserveDevice1/" + self.dev_name, 19 | dbus.service.BusName( "org.freedesktop.ReserveDevice1." + self.dev_name, bus=self.bus, allow_replacement=True, replace_existing=True, do_not_queue=True ) ) 20 | 21 | @dbus.service.method( dbus_interface="org.freedesktop.ReserveDevice1", in_signature="i", out_signature="b" ) 22 | def RequestRelease( self, prio ): 23 | if prio < self.prio: 24 | return False 25 | 26 | if self.override_cb: 27 | if self.override_cb( self.device_name ): 28 | self.connection.release_name( 'org.freedesktop.ReserveDevice1.' + self.dev_name ) 29 | return True 30 | 31 | return False 32 | 33 | 34 | def unreserve (self): 35 | self.connection.release_name( 'org.freedesktop.ReserveDevice1.' + self.dev_name ) 36 | rr.remove_from_connection() 37 | 38 | 39 | def reserve_dev( dev_name, prio, override_cb ): 40 | global rr 41 | try: 42 | session_bus = dbus.SessionBus() 43 | except Exception: 44 | return 45 | 46 | try: 47 | r_proxy = session_bus.get_object( "org.freedesktop.ReserveDevice1." + dev_name, "/org/freedesktop/ReserveDevice1/" + dev_name ) 48 | r_iface = dbus.Interface( r_proxy, "org.freedesktop.ReserveDevice1" ) 49 | except Exception: 50 | print "no other reservation exists. taking the name" 51 | rr = reservation_t( dev_name, prio, override_cb ) 52 | return 53 | 54 | if not r_iface.RequestRelease( prio ): 55 | raise Exception 56 | 57 | rr = reservation_t( dev_name, prio, override_cb ) 58 | 59 | 60 | 61 | dbus.mainloop.glib.threads_init() 62 | dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) 63 | 64 | def run_main(): 65 | loop = gobject.MainLoop() 66 | loop.run() 67 | 68 | 69 | --------------------------------------------------------------------------------