Colin.Guthr.ie Illegitimi non carborundum

26Sep/1038

Compiling and running PulseAudio from git

A few budding developers have asked me recently about this and to make life easy, I decided to write up this guide! There are some gotchas to look out for so please read carefully!

Are we ready? OK, lets being!

The shell output shown below will include my machine's name, "jimmy". My bash prompt also shows the current git branch thanks to the git-prompt package in Mandriva (you can enable it manually by following this guide). Note that for various reasons I wont go into in this guide, the development version of PA is currently 0.9.19, this is despite the current released version being 0.9.21. Its due to how the git tree is organised, and I'm hoping to fix this soon. Edit: Git master is now tracking PA 1.0 (not for any specific milestone of 1.0, but just because a 3-point version number is kinda annoying. Essential the version policy is now decided and all should be working fine now. There may still be a 0.9.23 based of the current stable-queue branch, but the next release from master will be 1.0.

May the Source Be With You

The first job is to clone our code repository. You first have to pick where you want to keep your development version. In the example below I've decided to use a folder under my home directory called "padev"

[colin@jimmy ~]$ git clone git://anongit.freedesktop.org/git/pulseaudio/pulseaudio padev
Cloning into padev...
remote: Counting objects: 39578, done.
remote: Compressing objects: 100% (6760/6760), done.
remote: Total 39578 (delta 32779), reused 39578 (delta 32779)
Receiving objects: 100% (39578/39578), 14.56 MiB | 1.97 MiB/s, done.
Resolving deltas: 100% (32779/32779), done.
[colin@jimmy ~]$

Now you should have a ~/padev/ folder containing the code.

Compile Time

Now it's time to compile the code, but before we do this, we have to prepare the checkout for compilation. Handily there is a script provided to make this easy for us.

[colin@jimmy ~]$ cd padev/
[colin@jimmy padev (master)]$ ./bootstrap.sh -V
+ case $(uname) in
++ uname
...
+ make clean
make: *** No rule to make target `clean'.  Stop.
[colin@jimmy padev (master)]$

There is an error about not being able to "make clean" here but you can safely ignore that.

Next we'll create a build directory. This is not mandatory, but it helps keep temporary build files etc. separate from the code in the checkout (there are special git commands to delete such files but all the same, I feel this is cleaner). After creating the build directory, we change to it and run the configure script.

[colin@jimmy padev (master)]$ mkdir build
[colin@jimmy padev (master)]$ cd build/
[colin@jimmy build (master)]$ ../configure --prefix=$(pwd)
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
...
config.status: executing po/stamp-it commands

---{ pulseaudio 0.9.19-562-g395da }---

prefix:                        /home/colin/padev/build
sysconfdir:                    ${prefix}/etc
localstatedir:                 ${prefix}/var
System Runtime Path:           ${prefix}/var/run/pulse
System State Path:             ${prefix}/var/lib/pulse
System Config Path:            ${prefix}/var/lib/pulse
Compiler:                      gcc -std=gnu99
CFLAGS:                        -g -O2 -Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include

Have X11:                      yes
Enable OSS Output:             yes
Enable OSS Wrapper:            yes
Enable CoreAudio:              no
Enable Alsa:                   yes
Enable Solaris:                no
Enable GLib 2.0:               yes
Enable Gtk+ 2.0:               yes
Enable GConf:                  yes
Enable Avahi:                  yes
Enable Jack:                   yes
Enable Async DNS:              yes
Enable LIRC:                   yes
Enable DBUS:                   yes
Enable HAL:                    yes
Enable udev:                   yes
Enable HAL->udev compat:       no
Enable BlueZ:                  yes
Enable TCP Wrappers:           yes
Enable libsamplerate:          yes
Enable IPv6:                   yes
Enable OpenSSL (for Airtunes): yes
Enable tdb:                    yes
Enable gdbm:                   no
Enable simple database:        no
Enable fftw:                   yes

System User:                   pulse
System Group:                  pulse
Access Group:                  pulse-access
Enable per-user EsounD socket: yes
Force preopen:                 no
Preopened modules:             all
[colin@jimmy build (master)]$

You should pay particular attention to the --prefix argument passed to configure. Rather than "installing" this version of PulseAudio, we'll just run it from the source tree. This is both quicker and saves any potential conflict with your system-installed PulseAudio packages.

You should also pay attention to the table at the end which lists the available support. In order for automatic card detection to work properly with your build, you really should ensure that udev support in particular is available. If it does not print a "yes" line in the output then you probably do not have the "udev-devel" package for your distro installed.

Let's Build

OK, so you're ready to build! But not quite. Due to an upstream bug, the translations for .desktop files are not written if the destination folder does not exist, so let's create it manually

[colin@jimmy build (master)]$ mkdir -p src/daemon
[colin@jimmy build (master)]$

OK, with all the prep work done, we really do build it.

[colin@jimmy build (master)]$ make
echo 0.9.19-562-g395da > ../.version-t && mv ../.version-t ../.version
make  all-recursive
...
file=`echo zh_TW | sed 's,.*/,,'`.gmo \
 && rm -f $file && /usr/bin/msgfmt -o $file ../../po/zh_TW.po
make[2]: Leaving directory `/home/colin/padev/build/po'
make[2]: Entering directory `/home/colin/padev/build'
make[2]: Leaving directory `/home/colin/padev/build'
make[1]: Leaving directory `/home/colin/padev/build'
[colin@jimmy build (master)]$

Now that it's built successfully we can run it, but we'll do a little bit of preparation first. As ALSA currently lacks UCM (Use Case Management) (although this is due to be added soon), PulseAudio supports a fairly robust "probing" system to determine how your sound hardware works. In order to run these probes it has to know where to look for the "mixer profile" definitions. As we are running from the build tree, we'll cheat a little and use a symlink so that our development build can find the files.

[colin@jimmy build (master)]$ mkdir -p share/pulseaudio
[colin@jimmy build (master)]$ ln -s ../../../src/modules/alsa/mixer share/pulseaudio/alsa-mixer
[colin@jimmy build (master)]$

In order to run some test tools, we also need to manually create some symlinks that are normally done as part of the install process.

[colin@jimmy build (master)]$ ln -s pacat src/paplay
[colin@jimmy build (master)]$ ln -s pacat src/parec
[colin@jimmy build (master)]$

Run, Forest, Run!

Now that things are built and some symlinks are in place, we can run our nice shiny development version. You should first ensure that the system-installed PulseAudio daemon is not running. In order to do this, you should disable autospawn by doing:

echo "autospawn=no" >> ~/.pulse/client.conf

Once this is done, you should reboot. PulseAudio will likely still start when you log in to X11 by virtue of the start-pulseaudio-x11 script that is run at login, but some systems that rely on PA autospawn may not initialise correctly (e.g. under KDE knotify and kmix may start in 'ALSA mode'. This is generally not a problem, but you should be aware of the consequences.

So if your system PA has been run, simply execute:

pulseaudio -k

To kill the currently running daemon. You can then start your development version via:

[colin@jimmy build (master)]$ src/pulseaudio -n -F src/default.pa -p $(pwd)/src/.libs/ -vvvv
W: main.c: Couldn't canonicalize binary path, cannot self execute.
I: main.c: setrlimit(RLIMIT_NICE, (31, 31)) failed: Operation not permitted
I: main.c: setrlimit(RLIMIT_RTPRIO, (9, 9)) failed: Operation not permitted
D: core-rtclock.c: Timer slack is set to 50 us.
D: core-util.c: RealtimeKit worked.
I: core-util.c: Successfully gained nice level -11.
I: main.c: This is PulseAudio 0.9.19-562-g395da
...

This will produce a lot of debug output, so you should leave that terminal running. The command line arguments are as follows: "-n" says "do not process the (system) default.pa". This is generally only needed if you have a ~/.pulse/default.pa file, but it does no harm to include it always. "-F src/default.pa" says to "process the script src/default.pa" and "-p $(pwd)/src/.libs" tells PA where to look for it's modules (i.e. from your build tree).

Note that the state files saved by PulseAudio in ~/.pulse/ folder will very likely NOT conflict with your system PA's files. This is because our development PA build does not know the right path to look for /var/lib/dbus/machine-id. Because of this, the prefix used on files will default to the host name of your machine, not the string of apparently random numbers and letters that you may see in there already. If you cross reference, the output from cat /var/lib/dbus/machine-id will show the same number as used here. We do this to ensure we can have separate preferences for different machines when your home directory is shared over e.g. NFS - the machine-id is more stable than the hostname which is why we prefer that as a prefix.

Running a Client App

So now that everything is running, you should be able to run a client application. As the build tree comes with some utilities you can run them directly from there:

[colin@jimmy build (master)]$ src/paplay -vv /usr/share/sounds/ia_ora-startup.wav
Opening a playback stream with sample specification 's16le 2ch 22050Hz' and channel map 'front-left,front-right'.
Connection established.
Stream successfully created.
Buffer metrics: maxlength=4194304, tlength=176400, prebuf=174640, minreq=1764
Using sample spec 's16le 2ch 22050Hz', channel map 'front-left,front-right'.
Connected to device alsa_output.pci-0000_00_1b.0.analog-stereo (0, not suspended).
Stream started.
Stream underrun.
Playback stream drained.: 1007045 usec.
Draining connection to server.

If, however you want to run a more advanced client application, then you need to employ a little hack to tell your system to use your development version of libpulse. This is quite trivial:

[colin@jimmy build (master)]$ export LD_LIBRARY_PATH=$(pwd)/src/.libs
[colin@jimmy build (master)]$ mplayer /path/to/your/fav.mp3
...

Easy eh? That's all you need to do to run PulseAudio from git. You can now easily try out patches, write your own modules and help contribute! Happy hacking.

Some notes on Overlinking

So, just before I sign off, I thought it was best to mention overlinking. PulseAudio itself uses a shared library that is used by both client and server. This library is "libpulsecommon-0.9.x.so". Client applications should NOT link to this file directly - instead libpulse will load it in for you. This can lead to some strange results. e.g. consider the following output:

[colin@jimmy ~]$ ldd `which paplay` | grep pulse
	libpulse.so.0 => /usr/lib64/libpulse.so.0 (0x00007f5bd9fc7000)
	libpulsecommon-0.9.21.so => /usr/lib64/libpulsecommon-0.9.21.so (0x00007f5bd9d76000)
[colin@jimmy ~]$ ldd `which mplayer` | grep pulse
	libpulse.so.0 => /usr/lib64/libpulse.so.0 (0x00007f617c1f4000)
	libpulsecommon-0.9.21.so => /usr/lib64/libpulsecommon-0.9.21.so (0x00007f6175f08000)

This looks more or less the same right? Not quite. Compare this to:

[colin@jimmy ~]$ objdump -p `which paplay` | grep pulse
  NEEDED               libpulse.so.0
  NEEDED               libpulsecommon-0.9.21.so
  required from libpulse.so.0:
[colin@jimmy ~]$ objdump -p `which mplayer` | grep pulse
  NEEDED               libpulse.so.0
  required from libpulse.so.0:

So what you can see here is that my paplay really does need both, but mplayer actually only does not directly need libpulsecommon-0.9.21.so. But what does this mean to you when running things? Well, due to the fact that PulseAudio has this kind of circular dependancy internally, we cannot use the --no-undefined or --as-needed build options. This means that the PulseAudio package is Over linked. This is why the paplay utility needs libpulsecommond-0.9.21.so directly, unlike mplayer, which does not.

So if you try and use the above guide and ultimately run the system provided paplay utility, you'll find you run into problems. This is because the system libpulsecommon-0.9.21.so will be used, not your freshly compiled version (which could have a completely different version number - e.g. libpulsecommon-0.9.19.so!).

While we don't need to run the system paplay (as we have built our own version), it's easy to forget this quirk and break things. If you want to be sure, you can place a symlink in your build folder to fool the system into loading your libpulsecommon, even when the versions don't "match". As this is an overlinking problem, there is little danger in doing this hack:

[colin@jimmy build (master)]$ ln -s libpulsecommon-0.9.19.so src/.libs/libpulsecommon-0.9.21.so
[colin@jimmy build (master)]$

This puts the necessary symlink in place to make my dev build (0.9.19) replace the system build (0.9.21). This only has effect with the LD_LIBRARY_PATH variable set, so it wont interfere with anything on your system.

Depending on your your distro packages things, the problems of overlinking may be present in more than just the paplay utility. So check this out and use objdump -p to confirm the client application you want to run is linked correctly and use the symlink hack if needed.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Identi.ca
  • Slashdot
Comments (38) Trackbacks (4)
  1. Thank you for the great guide! That was just what I needed.

  2. it is great, If you can give out it several days early. It take me some efforts to figure out it myself. :-)

  3. Since its initial release, people have had issues with PulseAudio and audio playback. The developers often had said that Distro Suchnsuch weren’t building and incorporating Pulse properly, that the software would work fine if Distro Suchnsuch knew what they were doing.

    The pulse debate lives on, and now you’re showing users how to build their own Pulse, when supposedly their distro maintainers cannot get it correct? Or have things finally been resolved in Pulse and I missed it?

    • I’m afraid you’re being far too vague for me to give any kind of reasonable answer here.

      Besides I think you totally trivialise the problems down to a simple “compilation” issue. I mean do you really believe that distro X *compiles* PA incorrectly? These are not the issues at play in a properly defined PA deployment. It relates to ALSA configuration, various different backends to audio libraries (i.e. gstreamer, vlc, libao, portaudio, SDL etc.), the support compiled into various system components (i.e. in GNOME, KDE etc.) and the default configuration of many individual applications. It not just a simple matter of compiling one package correctly and everything works fine.

      My Advice here is how to run the code from git so you can hack on it. Various issues regarding how the rest of your distro and/or user configuration works with PA are not covered in this article.

      Most distros still default to PA and even more KDE focused distros are doing the same now that I’ve written the majority of the integration code.

      So please rephrase your question to ask about specific details so I can address them specifically if the above reply doesn’t answer your questions.

      • Thank you for the response. I am not familiar at all with Pulse and I am not using it, I am just curious if many of the issues had been ironed out or not. If sound integration doesn’t work due to configuration of files, not the compilation of code, then yes that would answer my question.

        I don’t have a specific distro to point at, I’ve just read a lot of back-and-forth over the years about Pulse being great and Pulse being broken.

  4. Thanks, this is really useful! Now I’m looking forward to the next guide: “Debugging PulseAudio with gdb” – just adding “gdb –args” in front of the argument won’t work as that will go to the autotools wrapper script, etc…

    • Yeah I’ll try and sort something out about that. (I’ve not tried but I think there are two options – one is to use the wrapper script once, then call the binary directly after that – the first run will relink via the wrapper script and the second run it should be OK…. the other is to run gdb and attach to the running PA instance: this is how I prefer to do it, but it obviously doesn’t help if PA is crashing on startup!)

  5. Hi, I follow your instruction to download the pulseaudio package but failed to find the “configure” script to configure my source code. I cannot see this file in git tree either. Can you tell me how to fix this? Thanks.

    • Hello! You missed the “bootstrap” stage, which generates the configure script. Sadly when double checking the article, I realised I’d said to run “./bootstrap -V” but in actual fact you need to run “./bootstrap.sh -V” (I had missed out the .sh extension!) Sorry about that. I’ve fixed it now!

      • Hi again, my actual situation is that system just gets stuck after “./bootstrap -V” is executed. Here is the traces for your reference. Much appreciate if you can help. Thanks!!

        —————————————————————————–
        s2chang@s2chang-desktop:~/temp/pulseaudio$ ./bootstrap.sh -V
        + case $(uname) in
        ++ uname
        + ‘[' -f .git/hooks/pre-commit.sample -a '!' -f .git/hooks/pre-commit ']‘
        + ‘[' -f .tarball-version ']‘
        + pkg-config –version
        + type -p colorgcc
        + ‘[' x-V = xam ']‘
        + rm -rf autom4te.cache
        + rm -f config.cache
        + rm -f Makefile.am~ configure.ac~
        + bash -s — –copy –force
        ++ which gettextize
        + sed ‘s/read dummy/\#/’

        —————————————————————————–

        • Hmm, not too sure why it would bail out… I guess there is some kind of missing file needed for building there? Perhaps if you try rebuilding your distro’s package for pulseaudio first? It will make it easy to install all the required development libraries and headers needed.

          Just as a guess from the 2nd last line, does “which gettextize” actually return a path on your system? I have it in /usr/bin.

          • Thanks for reminding me to check it. It turned out several libraries were missing including gettext. Everything works now.

  6. I tried this in my Atom system with MeeGO OS. I am using pulseaudio-0.9.21-15.3
    The steps worked fine before pulseaudio -k

    [root@localhost build]# pulseaudio -k
    E: main.c: Failed to kill daemon: No such process

    Thought it might be a privilege issue. So changed the owner and group permission to root of pulse-xxx (random number) directories in /tmp
    But still the pulseaudio -k not working

    Now when I run the next command
    [root@localhost build]$ src/pulseaudio -n -F src/default.pa -p $(pwd)/src/.libs/ -vvvv

    I get the following ..

    E: module-gconf.c: Unable to read or parse data from client.
    E: module.c: Failed to load module “module-gconf” (argument: “”): initialization failed.
    ………..

    E: main.c: Module load failed.
    W: main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.Spawn.ExecFailed: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
    I: main.c: Daemon startup complete.
    D: module-udev-detect.c: /dev/snd/controlC0 is accessible: yes
    I: module-suspend-on-idle.c: Source alsa_input.pci-0000_00_1b.0.analog-stereo idle for too long, suspending …
    D: source.c: Suspend cause of source alsa_input.pci-0000_00_1b.0.analog-stereo is 0×0004, suspending
    I: alsa-source.c: Device suspended…
    I: module-suspend-on-idle.c: Sink alsa_output.pci-0000_00_1b.0.analog-stereo idle for too long, suspending …
    D: sink.c: Suspend cause of sink alsa_output.pci-0000_00_1b.0.analog-stereo is 0×0004, suspending
    I: alsa-sink.c: Device suspended…
    D: module-udev-detect.c: /dev/snd/controlC0 is accessible: yes

    and then its STUCK. The command runs forever!!

    Any workaround?

    • I think the main problem is you’re running things as root. You should always just use your normal user account. Check which user is running the current PA process and just stick with using that user and pulseaudio -k should work fine.

      I also suspect that the other problems also relate to running the daemon as root.

      But at the end you say the process is stuck and runs forever….. well this is what is expected. You can of course put it into the background and use it as a normal install but this guide was written with a debugging and development perspective, so I run it in the foregroud. If you were running it as a background process, it wouldn’t really make sense to pass -vvvv argument which enables the verbose debug output.

      Hope this explains things.

      • Thanks Colin. Worked as non-root, passed through pulseaudio -k step. But while running

        [root@localhost build]$src/pulseaudio -n -F src/default.pa -p $(pwd)/src/.libs/ -vvvv

        I get the following

        W: main.c: Couldn’t canonicalize binary path, cannot self execute.
        D: core-rtclock.c: Timer slack is set to 1000 us.
        D: core-rtclock.c: Setting timer slack to 500 us.
        D: core-util.c: setpriority() worked.
        I: core-util.c: Successfully gained nice level -11.
        I: main.c: This is PulseAudio 1.0-dev-33-g95cc

        …………………….

        W: module.c: module-detect is deprecated: Please use module-udev-detect instead of module-detect!

        ………………….

        E: module.c: Failed to open module “module-console-kit”: file not found
        E: main.c: Module load failed.
        E: main.c: Failed to initialize daemon.

        …….

        I: module.c: Unloaded “module-alsa-source” (index: #5).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-detect” (index: #6).
        I: module.c: Unloaded “module-detect” (index: #6).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-esound-protocol-unix” (index: #7).
        I: module.c: Unloaded “module-esound-protocol-unix” (index: #7).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-native-protocol-unix” (index: #8).
        I: module.c: Unloaded “module-native-protocol-unix” (index: #8).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-default-device-restore” (index: #9).
        I: module.c: Unloaded “module-default-device-restore” (index: #9).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-rescue-streams” (index: #10).
        I: module.c: Unloaded “module-rescue-streams” (index: #10).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-always-sink” (index: #11).
        I: module.c: Unloaded “module-always-sink” (index: #11).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-intended-roles” (index: #12).
        I: module.c: Unloaded “module-intended-roles” (index: #12).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: module.c: Unloading “module-suspend-on-idle” (index: #13).
        I: module.c: Unloaded “module-suspend-on-idle” (index: #13).
        D: core-subscribe.c: Dropped redundant event due to remove event.
        I: main.c: Daemon terminated.

        As expected, this is not a working state. I got the following while trying to run a sample file

        [meego@localhost build]$ src/paplay -vv /usr/share/sounds/alsa/Front_Center.wav
        Opening a playback stream with sample specification ‘s16le 2ch 44100Hz’ and channel map ‘front-left,front-right’.
        Connection failure: Connection refused
        pa_context_connect() failed: Connection refused

        Please suggest.

        • Yes if the “Daemon terminated” line is shown, the paplay will certainly generate a “Connection refused” error (as there is no daemon to connect to).

          What was the output from the configure stage? It should print a summary of what is and is not going to be compiled. Do you have all the necessary build dependencies to build console kit support?

          I grant you that if you do not enable console kit in configure, that the default.pa should work – I’ll add some ifexists around that to protect it from this.

          But the fact you are using module-detect makes me thing you do not have udev support compiled in either. As I mentioned in the article, pay particular attention to the summary at the end of the configure stage. Make sure you include all the bits you really want (and you really do want udev and consolekit support!!).

          HTHs

          • (I should clarify that consolekit is dependant on dbus – so if the line “Enable DBUS: no” appears in your configure output, this is the problem!; ensure that you have udev and dbus support – you really want both!)

          • FWIW, I’ve just pushed some changes to git that should highlight missing deps (where they are important ones) a little more obviously.

  7. I have dbus, udev enabled, but other discrepancies with your config output. Here it is.

    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes

    ……………………….

    config.status: executing po/stamp-it commands

    —{ pulseaudio 1.0-dev-33-g95cc }—

    prefix: /home/meego/padev/build
    sysconfdir: ${prefix}/etc
    localstatedir: ${prefix}/var
    System Runtime Path: ${prefix}/var/run/pulse
    System State Path: ${prefix}/var/lib/pulse
    System Config Path: ${prefix}/var/lib/pulse
    Compiler: gcc -std=gnu99
    CFLAGS: -O2 -g -march=core2 -mssse3 -mtune=atom -mfpmath=sse -Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option

    Have X11: no
    Enable OSS Output: yes
    Enable OSS Wrapper: yes
    Enable CoreAudio: no
    Enable Alsa: yes
    Enable Solaris: no
    Enable GLib 2.0: yes
    Enable Gtk+ 2.0: no
    Enable GConf: no
    Enable Avahi: no
    Enable Jack: no
    Enable Async DNS: no
    Enable LIRC: no
    Enable DBUS: no
    Enable HAL: no
    Enable udev: no
    Enable HAL->udev compat: no
    Enable BlueZ: no
    Enable TCP Wrappers: no
    Enable libsamplerate: no
    Enable IPv6: yes
    Enable OpenSSL (for Airtunes): no
    Enable tdb: no
    Enable gdbm: no
    Enable simple database: yes
    Enable fftw: no
    Enable orc: no

    System User: pulse
    System Group: pulse
    Access Group: pulse-access
    Enable per-user EsounD socket: yes
    Force preopen: no
    Preopened modules: all

    • My bad, I mixed it. I have a different setup where dbus, udev both enabled. And I get a different error in while running.

      src/pulseaudio -n -F src/default.pa -p $(pwd)/src/.libs/ -vvvv

      This one has almost nothing enabled !!

      • OK, I’m not really sure if you’re describing a problem any more. Anyway, the kind of advice is now beyond a blog comments section I think. If you still don’t manage to get things working, then feel free to drop by our IRC channel or post on the mailing list for advice.

  8. Is there a way to use paprefs with this local build of pulseaudio? Even when setting the LD_LIBRARY_PATH correctly and creating the symlinks, paprefs won’t allow me to toy with the network settings (they are greyed out).

    Thanks for this how-to!

    • Ahh good point. paprefs should do runtime module path detection to allow it to know which ones are installed, but it may not work properly with this approach. One thing you can do is run paprefs with the system version of PA and enable the options you need. paprefs should just be a frontend to gconf so enabling things for the system version should allow it to be enabled for the self compiled version. I’ll try this out later myself to double check, but it should work :)

      • Ok. So I configured pulseaudio (using the system’s paprefs) as a sound server, but I cannot see it on a PC setting next to it on a LAN when I start my locally built version.

        Doesn’t seem to play RTP streaming either. Here are my build flags:

        Have X11: no
        Enable OSS Output: yes
        Enable OSS Wrapper: yes
        Enable CoreAudio: no
        Enable Alsa: yes
        Enable Solaris: no
        Enable GLib 2.0: yes
        Enable Gtk+ 2.0: yes
        Enable GConf: yes
        Enable Avahi: yes
        Enable Jack: yes
        Enable Async DNS: no
        Enable LIRC: yes
        Enable DBUS: yes
        Enable HAL: yes
        Enable BlueZ: no
        Enable udev: yes
        Enable HAL->udev compat: no
        Enable TCP Wrappers: yes
        Enable libsamplerate: yes
        Enable IPv6: yes
        Enable OpenSSL (for Airtunes): yes
        Enable tdb: yes
        Enable gdbm: no
        Enable simple database: no
        Enable fftw: no
        Enable orc: no

        System User: pulse
        System Group: pulse
        Access Group: pulse-access
        Enable per-user EsounD socket: yes
        Force preopen: no
        Preopened modules: all

        Is there an option that I lack which is required to see my soundserver on another PC through padevchooser? Thanks again!

        • Not quite sure why it wouldn’t have worked. Try looking at pacmd list-modules output and making sure that module-gconf is loaded. Perhaps try looking at the debug output to work out whether or not the gconf module is behaving correctly.

          I’d generally advise including X11 support (although padevchooser is obsolete, it sets it’s settings via X11 properties). If in doubt, simply load module-zeroconf-publish. You’ll also need to load module-native-protocol-tcp with appropriate options to allow remote connections (e.g. auth-anon=1).

          Ping me again on IRC for more interactive advice.

  9. For those still looking for a way to run a freshly compiled pulseaudio in gdb, this is how it works:

    libtool –mode execute gdb src/pulseaudio

    The libtool wrapper will ensure that all the locally built shared libraries are used for the run time instance, so you don’t need to touch your system’s default installation.

  10. This may not be the best place to ask this question, but here it goes anyway.

    So, using this guide, I was able to compile from git on Ubuntu 10.04 x86_64. I did this so I could make use of the patch at http://www.mail-archive.com/pulseaudio-discuss@mail.0pointer.de/msg09284.html. The reason I’m asking here is because you commented on the set of patches that Maarten Bosmans commited that they’re all in your tree now.

    Moving on, I went to patch the source and discovered that the patches had already been commited to the source. So I went head and started compiling as detailed in this guide. After a little bit of playing (and having to upgrade ALSA to 1.0.24), I got the dev branch to work.

    However, the changes to pactl aren’t working. See the below output.

    chris@chrisnet-netbook:~/github_stuff/padev/build$ src/pulseaudio –version
    W: main.c: Couldn’t canonicalize binary path, cannot self execute.
    pulseaudio 1.0-dev-264-g575ba-dirty
    chris@chrisnet-netbook:~/github_stuff/padev/build$ src/pactl set-sink-input-volume 1 10%
    Failure: No such entity

    Help? I’m using cmus right now and it’s working fine. I’ve been trying to find a way to control sink inputs from the command-line using relative adjustments for awhile now (over a year).

    Correction: Audio output is NOT working. cmus was using ALSA. When I forced it to output on pulseaudio, I get Error: opening audio device: internal error when using pulseaudio from git.

    • Sorry for the late reply. I hope you’ve got things working by now? If not just drop by our IRC or mailing list to ask for help and advice. I can’t say from the above quite what’s wrong, but I’m sure we’ll get to the bottom of it :)

  11. Have a question. After command ../configure –prefix=$(pwd) it shows the error(at the end of output):

    checking whether to build static libraries… no
    checking ltdl.h usability… no
    checking ltdl.h presence… no
    checking for ltdl.h… no
    configure: error: Unable to find libltdl version 2. Makes sure you have libtool 2.2 or later installed.

    However libltdl-2.4-2 is installed(Fedora 15)
    Any ideas?

    • That’s the runtime library. You’re likely missing the development package. Easiest option to ensure you have everything installed is to download the fedora SRPM for PA and then try and prepare the (rpmbuild -bp) It will warn you if you do not have any of the “BuildRequires” installed. That way you should be good to build the source outside of the SRPM. HTHs

  12. Great article! Thanks much.

  13. Hi Colin,

    Could you help me out with building and installing pulse from source.

    i used the following option
    ./configure –prefix=/usr –sysconfdir=/etc ..

    After i install paplay doesnt work with installed binary means after installing i start
    1. “pulseaudio -v &”
    2. paplay .wav

    Pulse doesnt play the file, but strange behaviour is if i start pulse binary present under”src” folder then it plays

    Please do explain the issue i have?? i am stuck in this for couple of days , my requirement is to install a particular new version of pulseaudio after patching the same.

    WIth thanks
    Aji.

    • Your PA configuration is likely not configured to autospawn (or there is some problem with that configuration). If it’s not configured to autospawn, paplay and any other audio client application will not launch the PA daemon and thus you have to start it manually.

  14. Hi got problems while ./bootstrap.sh -V command was executed:

    [admin@localhost padev (master)]$ sudo ./bootstrap.sh -V
    [sudo] password for admin:
    + case $(uname) in
    ++ uname
    + ‘[' -f .git/hooks/pre-commit.sample -a '!' -f .git/hooks/pre-commit ']‘
    + ‘[' -f .tarball-version ']‘
    + pkg-config –version
    + type -p colorgcc
    + ‘[' x-V = xam ']‘
    + rm -rf autom4te.cache
    + rm -f config.cache
    + rm -f Makefile.am~ configure.ac~
    + bash -s — –copy –force
    ++ which gettextize
    + sed ‘s/read dummy/\#/’ /bin/gettextize
    Copying file ABOUT-NLS
    Not copying intl/ directory.
    Copying file po/Makefile.in.in
    Copying file po/boldquot.sed
    Copying file po/en@boldquot.header
    Copying file po/en@quot.header
    Copying file po/insert-header.sin
    Copying file po/Makevars.template
    Copying file po/quot.sed
    Copying file po/remove-potcdate.sin
    Copying file po/Rules-quot
    Copying file m4/gettext.m4
    cp: cannot stat `/usr/share/aclocal/gettext.m4′: No such file or directory
    Copying file m4/iconv.m4
    cp: cannot stat `/usr/share/aclocal/iconv.m4′: No such file or directory
    Copying file m4/lib-ld.m4
    cp: cannot stat `/usr/share/aclocal/lib-ld.m4′: No such file or directory
    Copying file m4/lib-link.m4
    cp: cannot stat `/usr/share/aclocal/lib-link.m4′: No such file or directory
    Copying file m4/lib-prefix.m4
    cp: cannot stat `/usr/share/aclocal/lib-prefix.m4′: No such file or directory
    Copying file m4/nls.m4
    cp: cannot stat `/usr/share/aclocal/nls.m4′: No such file or directory
    Copying file m4/po.m4
    cp: cannot stat `/usr/share/aclocal/po.m4′: No such file or directory
    Copying file m4/progtest.m4
    cp: cannot stat `/usr/share/aclocal/progtest.m4′: No such file or directory
    Copying file m4/codeset.m4
    cp: cannot stat `/usr/share/aclocal/codeset.m4′: No such file or directory
    Copying file m4/fcntl-o.m4
    cp: cannot stat `/usr/share/aclocal/fcntl-o.m4′: No such file or directory
    Copying file m4/glibc2.m4
    cp: cannot stat `/usr/share/aclocal/glibc2.m4′: No such file or directory
    Copying file m4/glibc21.m4
    cp: cannot stat `/usr/share/aclocal/glibc21.m4′: No such file or directory
    Copying file m4/intdiv0.m4
    cp: cannot stat `/usr/share/aclocal/intdiv0.m4′: No such file or directory
    Copying file m4/intl.m4
    cp: cannot stat `/usr/share/aclocal/intl.m4′: No such file or directory
    Copying file m4/intldir.m4
    cp: cannot stat `/usr/share/aclocal/intldir.m4′: No such file or directory
    Copying file m4/intlmacosx.m4
    cp: cannot stat `/usr/share/aclocal/intlmacosx.m4′: No such file or directory
    Copying file m4/intmax.m4
    cp: cannot stat `/usr/share/aclocal/intmax.m4′: No such file or directory
    Copying file m4/inttypes_h.m4
    cp: cannot stat `/usr/share/aclocal/inttypes_h.m4′: No such file or directory
    Copying file m4/inttypes-pri.m4
    cp: cannot stat `/usr/share/aclocal/inttypes-pri.m4′: No such file or directory
    Copying file m4/lcmessage.m4
    cp: cannot stat `/usr/share/aclocal/lcmessage.m4′: No such file or directory
    Copying file m4/lock.m4
    cp: cannot stat `/usr/share/aclocal/lock.m4′: No such file or directory
    Copying file m4/longlong.m4
    cp: cannot stat `/usr/share/aclocal/longlong.m4′: No such file or directory
    Copying file m4/printf-posix.m4
    cp: cannot stat `/usr/share/aclocal/printf-posix.m4′: No such file or directory
    Copying file m4/size_max.m4
    cp: cannot stat `/usr/share/aclocal/size_max.m4′: No such file or directory
    Copying file m4/stdint_h.m4
    cp: cannot stat `/usr/share/aclocal/stdint_h.m4′: No such file or directory
    Copying file m4/threadlib.m4
    cp: cannot stat `/usr/share/aclocal/threadlib.m4′: No such file or directory
    Copying file m4/uintmax_t.m4
    cp: cannot stat `/usr/share/aclocal/uintmax_t.m4′: No such file or directory
    Copying file m4/visibility.m4
    cp: cannot stat `/usr/share/aclocal/visibility.m4′: No such file or directory
    Copying file m4/wchar_t.m4
    cp: cannot stat `/usr/share/aclocal/wchar_t.m4′: No such file or directory
    Copying file m4/wint_t.m4
    cp: cannot stat `/usr/share/aclocal/wint_t.m4′: No such file or directory
    Copying file m4/xsize.m4
    cp: cannot stat `/usr/share/aclocal/xsize.m4′: No such file or directory
    Updating EXTRA_DIST in m4/Makefile.am (backup is in m4/Makefile.am~)
    Adding an entry to m4/ChangeLog (backup is in m4/ChangeLog~)

    Please use AM_GNU_GETTEXT([external]) in order to cause autoconfiguration
    to look for an external libintl.

    Please create po/Makevars from the template in po/Makevars.template.
    You can then remove po/Makevars.template.

    Please run ‘aclocal -I m4′ to regenerate the aclocal.m4 file.
    You need aclocal from GNU automake 1.8 (or newer) to do this.
    Then run ‘autoconf’ to regenerate the configure file.

    You will also need config.guess and config.sub, which you can get from the CVS
    of the ‘config’ project at http://savannah.gnu.org/. The commands to fetch them
    are
    $ wget ‘http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess’
    $ wget ‘http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub’

    You might also want to copy the convenience header file gettext.h
    from the /usr/share/gettext directory into your package.
    It is a wrapper around that implements the configure –disable-nls
    option.

    Press Return to acknowledge the previous five paragraphs.
    + test -f Makefile.am~
    + test -f configure.ac~
    + touch config.rpath
    + test x = x
    + LIBTOOLIZE=libtoolize
    + intltoolize –copy –force –automake
    ./bootstrap.sh: line 89: intltoolize: command not found

    I am trying it on Fedora 17, because I cannot instal git on Mandriva 2011, any help please!

    • You simply don’t have the necessary build time dependencies installed. There is a massive clue on the last line of your log: intltoolize: command not found. So you should install whatever package gives you that command on Fedora. You should likely install all the other build time deps mentioned in the fedora packages. e.g http://pkgs.fedoraproject.org/cgit/pulseaudio.git/tree/pulseaudio.spec?h=f17 (although this is for an older version of PA, so the deps from the newer fedora package might be needed too). Ultimately this is not specific to PulseAudio – this is simply standard autotools stuff. You should be able to solve these problems easily enough.

      Also, you should not run the command via sudo. There is no need to be root during any point of the build process. Depending on the configure options and the install prefix chosen, you may need to be root for the “make install” stage but that’s it.

      If you are not building PA to hack on, I would strongly suggest making an updated package instead. It keeps your system much cleaner that way.

  15. Thanks for reply!
    I am trying to compile pulse audio and using it on ‘Tomato Usb by shibby’. I’ ve tried on Mandriva 2011 but i don’t know how to install git repo, so maybe it would be easier on Mandriva getting git instead of installing those packages at Fedora.

    • Whether it’s Fedora, Mandriva or (my distro of choice) Mageia, the steps are approximately the same. Installing git on Mandriva or Mageia are both simply matters of installing the correct packages (IIRC on Mandriva 2011, it was called git-core or git-scm or something due to it conflicting with an existing project also called “git”). Regardless, you’ll still have to install the required development packages to build PA from git on Mandriva or Mageia in exactly the same was as on Fedora! I think you’ll just have to do a bit more reading on development on linux systems generally to get a feel for how this kind of stuff works overall before jumping into specific cases :)

  16. Hi Colin,

    a very nice article. Please, is there an up-to-date document describing the design and the internal architecture of PulseAudio?

    BR

    Vaclav M.


Leave a comment