arch detail

arch detail

Saturday, November 06, 2010

Pulseaudio -> JACK2 on Ubuntu 10.04

So, I'm running Ubuntu 10.04 and decided I wanted to run PulseAudio into Jack. Turns out you can do this now! Hurrah!

First, Pulseaudio must be able to write to create a JACK sink. You can add that functionality with:

sudo apt-get install pulseaudio-module-jack


Oddly, this does not automatically enable the module in PulseAudio. So to get it auto-loaded into PulseAudio, I dutifully follow instructions HERE and I do the following:

I edit /etc/pulse/default.pa and change:

### Load audio drivers statically (it is probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Alternatively use the static hardware detection module (for systems that
### lack udev support)
load-module module-detect
.endif


to:

### Load audio drivers statically (it is probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink
load-module module-jack-source
load-module module-jack-sink

### Automatically load driver modules depending on the hardware available
#.ifexists module-udev-detect.so
#load-module module-udev-detect
#.else
### Alternatively use the static hardware detection module (for systems that
### lack udev support)
#load-module module-detect
#.endif


Of course, I also add back up my default.pa and add some comments in there announcing to myself when I changed it, why, and where the backup is. Tutorials should tell you to do that, but they never do, for some reason.

Next, I kill off pulse and restart it, which should force it to load the new modules:

 pulseaudio -k ; pulseaudio 


For some unholy reason Ubuntu is respawning pulseaudio if it is killed, so sometimes the above doesn't work; sometimes inbetween the "pulseaudio -k" to kill and "pulseaudio" to restart, the system reboots pulseaudio. I suck at Gnome and have no idea how to fix this but whatever.

At this point, I make sure JACK is running and use System -> Preferences -> PulseAudio Preferences (that's paprefs, you may need to install it) to make sure the JACK sink is my default output.

I then try opening Movie Player to test. Failure! I get a weird error from Movie Player and my terminal running PulseAudio now says:

W: module-jack-sink.c: JACK error >zombified - calling shutdown handler< 


Then it seg faults. Whoooo!

I do some Googling. It seems that there is a problem with the interface between PulseAudio and JACK but the PulseAudio folks claim that this is now stabilized in newer versions of JACK: "There was some breakage in this area in JACK a while ago. I assume that this problem does not exist anymore. If it does feel free to reopen."

So, it seems that the version of JACK shipping with Ubuntu 10.04 is not compatible with the version of PulseAudio and/or pulseaudio-module-jack. So it's time to install JACK2, the current version of which is (oddly) 1.9.6. You can download the source here.

I download and untar the file:

$ mkdir ~/builds
$ cd ~/builds
$ cp ~/Downloads/jack-1.9.6.tar.bz2
$ bunzip2 jack-1.9.6.tar.bz2
$ tar -xvf jack-1.9.6.tar
$ cd jack-1.9.6


I read the README file and discover I'll need the ALSA and Freebob headers, so:

apt-get install libasound2-dev libfreebob0-dev


Now I have to configure and build. The README instructs me to use ./waf, but they don't really warn me about the options I need on ./waf configure. I used ./waf configure --help and determined that we need --alsa to build with ALSA support and --freebob to configure with Freebob support. Also, since I'm a cautious dude and don't want to hose my system, I also specify --prefix=$HOME and when I install, I use "./waf install" instead of "sudo ./waf install" to get a per-user, locally-installed JACK2 rather than overwrite the old JACK which is installed by Ubuntu.

So in total, do this in the jack source directory you untarred:
 $ ./waf configure --prefix=$HOME --alsa --frebob
(Check that that goes okay.)
$ ./waf build
$ ./waf install


Done! Now you should have jackd in your ~/bin/ and libraries in your ~/lib.

You'll now need to set up your LD_LIBRARY_PATH to use ~/lib/ before the system libraries in /usr/, etc. so that the correct libjack is loaded; you may also wish to modify your PATH variable. For me:

$ echo 'LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH' >> ~/.bashrc
$ echo 'PATH=$HOME/bin:$PATH >> ~/.bashrc
$ source ~/.bashrc


This will mean that apps you launch from a terminal should now use the new JACK2, but Ubuntu's launch buttons don't seem to pick it up. I'm working on that.

1 comment:

MeGodzillaUDead said...

THANK YOU SO MUCH for this post! I would've spent probably 8 hours trying to figure out all the dependencies for compiling JACK with alsa support and all that good stuff. Rock on!