| 1 |
|
| 2 |
Darwin/MacOSX port for Jack : architecture changes in the implementation |
| 3 |
======================================================================== |
| 4 |
|
| 5 |
Build Dependencies |
| 6 |
================== |
| 7 |
|
| 8 |
Apple Developer Tools |
| 9 |
gcc 2.95.x or 3.x, the standard OSX 10.3 gcc-3.3 compiler works fine |
| 10 |
MacOSX10.3 SDK package |
| 11 |
|
| 12 |
GNU tools |
| 13 |
autoconf >= 2.57 |
| 14 |
automake >= 1.6.3 |
| 15 |
|
| 16 |
optional tools |
| 17 |
libtool >= 1.5 (to build from CVS) |
| 18 |
pkg-config >= 0.15.0 (to build from CVS) |
| 19 |
doxygen (to build documentation) |
| 20 |
|
| 21 |
All non-Apple tools are available from `fink' or `darwinports'. |
| 22 |
|
| 23 |
Since fink is not well-integrated with OS X, you must define a bunch |
| 24 |
of environment variables... |
| 25 |
|
| 26 |
export ACLOCAL_FLAGS="-I /sw/share/aclocal" |
| 27 |
export CFLAGS="-I/sw/include" |
| 28 |
export CPPFLAGS=$CFLAGS |
| 29 |
export LDFLAGS="-L/sw/lib" |
| 30 |
export PKG_CONFIG_PATH="/sw/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig" |
| 31 |
|
| 32 |
|
| 33 |
Shared memory |
| 34 |
============= |
| 35 |
|
| 36 |
The system V shared memory is not very reliable on Darwin/MacOSX, so |
| 37 |
POSIX shared memory API is the preferred default. To override, use... |
| 38 |
|
| 39 |
./configure --disable-posix-shm |
| 40 |
|
| 41 |
|
| 42 |
Jack server audio cycle |
| 43 |
======================== |
| 44 |
|
| 45 |
On Linux, the jack server audio cycle (jack_run_cycle function) is |
| 46 |
called in a real-time SCHED_FIFO thread. On Darwin/MacOSX, the |
| 47 |
jack_run_cycle is directly called inside the CoreAudio audio callback. |
| 48 |
|
| 49 |
|
| 50 |
External client activation |
| 51 |
=========================== |
| 52 |
|
| 53 |
Jack Linux implementation use system fifo/pipe to trigger the clients |
| 54 |
real-time callback from the server : the first client of an external |
| 55 |
subgraph is triggered, does it's job and wakes up the next one in the |
| 56 |
list, and so on until the last client that wakes up the Jack |
| 57 |
server. This avoid uneeded context switches between the server and |
| 58 |
clients and thus is more efficient. |
| 59 |
|
| 60 |
This Linux implementation works also on Darwin/MacOSX but is not very |
| 61 |
efficient : audio gliches occur quite frequently. |
| 62 |
|
| 63 |
A more efficient system for external client activation has been |
| 64 |
developed. It use low-level mach messages system to implement fast IPC |
| 65 |
between the Jack server and the running clients. The Darwin/MacOSX has |
| 66 |
a very efficient Remote Procedure Call (RPC) implementation that can |
| 67 |
be used: the Jack server activate each external client in turn in a |
| 68 |
loop. |
| 69 |
|
| 70 |
On the client side, each client uses an additionnal thread only used |
| 71 |
for the real-time process callback, that will be triggered by the Jack |
| 72 |
server using this fast RPC mechanism. |
| 73 |
|
| 74 |
|
| 75 |
Real-time threads |
| 76 |
================== |
| 77 |
|
| 78 |
The Darwin/MacOSX system use a special class of scheduling for |
| 79 |
real-time threads. |
| 80 |
|
| 81 |
Since the server audio cycle is called directly from the CoreAudio |
| 82 |
callback, there is nothing special to do on the server side. On the |
| 83 |
client side, the thread used to call the "process" callback from the |
| 84 |
server is made real-time, using the mach thread API. |
| 85 |
|
| 86 |
|
| 87 |
Compilation and installation |
| 88 |
============================= |
| 89 |
|
| 90 |
- In the jack/jack folder, you'll have to produce the version.h |
| 91 |
manually from the version.h.in file ): Edit the version.h.in, replace |
| 92 |
the JACK_PROTOCOL_VERSION value with the one found in configure.in and |
| 93 |
save as a new version.h file. You should get something like "#define |
| 94 |
jack_protocol_version 6" in the file. |
| 95 |
|
| 96 |
Several packages need to be installed before compiling Jack : |
| 97 |
|
| 98 |
- Fink dlcompat (fink.sourceforge.net) : this package define the |
| 99 |
dlopen, dlsym... API used in Jack to load drivers and internal |
| 100 |
clients. The package has to be installed before compiling Jack. |
| 101 |
|
| 102 |
- fakepoll is a implementation of the poll function using select. The |
| 103 |
Fink version of poll does not work correctly, thus the public domain |
| 104 |
"fakepoll" code has been used instead. It is directly included in the |
| 105 |
Jack Darwin/MacOSX port. |
| 106 |
|
| 107 |
- PortAudio (www.portaudio.com) : PortAudio is a free, cross platform, |
| 108 |
open-source, audio I/O library. The Jack CoreAudio driver actually is |
| 109 |
implemented using PortAudio. The PortAudio source code for MacOSX has |
| 110 |
to be installed and compiled to produce a framework called |
| 111 |
"PortAudio.framework" that will be used in the Jack link phase. |
| 112 |
|
| 113 |
|
| 114 |
Several targets are available in the Project Builder project : |
| 115 |
|
| 116 |
- jackd : build the Jack server ("jackd" executable) |
| 117 |
- jack framework : build the "Jack.framework" library. |
| 118 |
- driver : build the PortAudio driver as a "jack_portaudio.so" shared library. |
| 119 |
- jack_metro : build the "jack_metro" executable. |
| 120 |
- jack_lsp : build the "jack_lsp" executable. |
| 121 |
- jack_connect : build the "jack_connect" executable. |
| 122 |
- jack_disconnect : build the "jack_disconnect" executable. |
| 123 |
|
| 124 |
Server, driver and library installation : |
| 125 |
----------------------------------------- |
| 126 |
|
| 127 |
First copy the Jack.framework in /Library/Framework. Then as root : |
| 128 |
|
| 129 |
# cp jack_portaudio /usr/local/lib |
| 130 |
# cp jackd /usr/local/bin |
| 131 |
|
| 132 |
Launching Jack server : |
| 133 |
----------------------- |
| 134 |
|
| 135 |
By default buffer size is 128 frames and sample rate is 44100. |
| 136 |
|
| 137 |
$ jackd -v -R -d coreaudio |
| 138 |
|
| 139 |
To setup a 32 frames buffer and a 4800 Hz sample rate : |
| 140 |
|
| 141 |
$ jackd -v -R -d coreaudio -p 32 -r 48000 |
| 142 |
|
| 143 |
Performances |
| 144 |
============= |
| 145 |
|
| 146 |
The Darwin/MacOSX implementation is quite efficient: on a G4/867 Mhz, |
| 147 |
the Jack server can run with a 32 frames buffer size without noticable |
| 148 |
problems. |
| 149 |
|
| 150 |
|
| 151 |
Known problems or unimplemented features |
| 152 |
========================================= |
| 153 |
|
| 154 |
- thread cancellation : the pthread API pthread_cancel is not |
| 155 |
completely available on Darwin/MacOSX. Thread cannot be cancelled in |
| 156 |
the general case: they must use explicit cancelation points like |
| 157 |
"pthread_testcancel" (see the "jack_client_thread" function) |
| 158 |
|
| 159 |
- xruns detection and report: not implemented. |
| 160 |
|
| 161 |
|
| 162 |
Possible improvements |
| 163 |
====================== |
| 164 |
|
| 165 |
- The audio driver is built on top of PortAudio. It may be more |
| 166 |
efficient to directly use the CoreAudio API in order to avoid |
| 167 |
additional buffer copy and interleaving/disinterleaving operations. |
| 168 |
|
| 169 |
- The project uses Project Builder. It would be helpful to work on |
| 170 |
the autoconf and automake tools as the Linux version. In this case, |
| 171 |
the macosx/config.h file would have to be removed and generated by |
| 172 |
configure, and jack/version.h will be generated automatically from |
| 173 |
jack/version.h.in |
| 174 |
|
| 175 |
- Better separation of Linux and Darwin/MacOSX only code. |
| 176 |
|
| 177 |
The Jack port for Darwin/MacOSX version has be done by: |
| 178 |
|
| 179 |
Grame Research Laboratory |
| 180 |
9, rue du Garet 69001 Lyon - France |
| 181 |
Mail : [email protected] |