If you have ever used JACK before, you will know it’s a low-latency sound server daemon. It uses ALSA (or OSS, etc) as a backend, and allows you to do sound in realtime. It also handles communication between ‘jackified’ applications differently. You pretty much set them up in a similar way you would in a studio, plugging outputs into inputs, etc.
Anyway, JACK is used for sound production in Linux because ALSA, Pulseaudio, etc are far too slow. This is excellent, but there is a problem. Not all applications support JACK. Adobe Flash for example, does not.
For a long time this was a limiting factor for me, and the reason I only started JACK when I needed it. Not anymore! Here are a few simple steps to get JACK running all the time and not notice! (under Gentoo!)
You must add ‘jack’ to your USE flags, to get JACK support in all applications you have installed. Go ahead and update that.
emerge --ask --deep --newuse world |
Things that will work without a problem are mpd, mplayer.
Next configure wine, by running winecfg and ticking JACK under sound. Untick ALSA.
Finally, the next step is to trick ALSA enabled applications into using JACK. Add the following lines to /etc/asound.conf
pcm.!default {
type plug
slave { pcm "jack" }
}
pcm.jack {
type jack
playback_ports {
0 alsa_pcm:playback_1
1 alsa_pcm:playback_2
}
capture_ports {
0 alsa_pcm:capture_1
1 alsa_pcm:capture_2
}
}
ctl.mixer0 {
type hw
card 0
} |
That’s it! Now Adobe Flash will work in Firefox! Go ahead and test it out! (you must have jackd running of course!)
It is useful to note that mpd will pick up JACK and ALSA when it starts, so if you only configure JACK in ~/.mpdconf it will work fine. Otherwise you will hear everything twice.
audio_output {
type "jack"
name "MPD JACK output"
} |
This is great, but you will notice you must start jackd manually. This is tedious. Here’s how to set up an /etc/init.d script.
/etc/init.d/jackd
#!/sbin/runscript
# This programm will be used by init in order to launch jackd with the privileges
# and id of the user defined into /etc/conf.d/jackd
depend() {
need alsasound
}
start() {
if ! test -f "${JACKDHOME}/.jackdrc"; then
eerror "You must start and configure jackd before launch it. Sorry."
eerror "You can use qjackctl for that."
return 1
else JACKDOPTS=$(cat "${JACKDHOME}/.jackdrc"|sed -e 's\/usr/bin/jackd \\')
fi
if [ -e /var/run/jackd.pid ]; then
rm /var/run/jackd.pid
fi
ebegin "Starting JACK Daemon"
env HOME="${JACKDHOME}" start-stop-daemon --start \
--quiet --background \
--make-pidfile --pidfile /var/run/jackd.pid \
-c ${JACKDUSER} \
-x /usr/bin/jackd -- ${JACKDOPTS} >${LOG}
sleep 2
if ! pgrep -u ${JACKDUSER} jackd > /dev/null; then
eerror "JACK daemon can't be started! Check logfile: ${LOG}"
fi
eend $?
}
stop() {
ebegin "Stopping JACK daemon -- please wait"
start-stop-daemon --stop --pidfile /var/run/jackd.pid &>/dev/null
eend $?
}
restart() {
svc_stop
while `pgrep -u ${JACKDUSER} jackd >/dev/null`; do
sleep 1
done
svc_start
} |
/etc/conf.d/jackd
# owner of jackd process (Must be an existing user.)
JACKDUSER="<user>"
# .jackdrc location for that user (Must be existing, JACKDUSER can use
# qjackctl in order to create it.)
JACKDHOME="/home/${JACKDUSER}"
# logfile (/dev/null for nowhere)
LOG=/var/log/jackd.log |
~/.jackdrc
/usr/bin/jackd -R -d alsa |
This is just the arguments you would usually use to start jackd. You don’t need to install qjackctl if you know what you’re doing!
Finally add /etc/init.d/jackd to startup!
# rc-update add jackd default |
And you’re done!