I'm using Raspberry Pi as sound server, the pi will be connected to USB DAC and pulseaudio will serve over local network and also serve as bluetooth speakers, how amazing is that. But when using stable OS like bullseye making pulseaudio left behind of newest version, currencly debian 11 bullseye, latest OS for Raspberry Pi got version 14.2 comparing to upstream that already got version 16. With version upgrade there is also improvements and fixes, mostly the bluetooth audio part. Then let we upgrade our pulseaudio shall we? First step, of course wipe out our local installation of pulseaudio sudo apt remove --purge pulseaudio\*, this will remove pulseaudio and it friends dependencies, just look at the log in the case some break packages introduced.

Second step is to cloning the pulseaudio repository

$ git clone -depth=1 -b pulse-version https://github.com/pulseaudio/pulseaudio.git

What is pulse-version? it the version that tagged as stable by developer in format vXX.Y in this section we use v16.0, so the full git clone url become git clone -depth=1 -b pulse-version https://github.com/pulseaudio/pulseaudio.git you can also remove the -b pulse-version part to get the latest and greatest code from upstream.

Next we install the dependencies for building pulseaudio, as im building pulseaudio on headless (no GUI) server some depedencies may removed.

# apt install --no-install-recommends libsndfile1-dev libspeexdsp-dev libtool libglib2.0-dev libjson-c-dev gettext libtdb-dev \
  libbluetooth-dev libsbc-dev ninja libdbus-1-dev meson libsoxr-dev libwebrtc-audio-processing-dev \
  check libcap-dev libudev-dev libsamplerate0-dev libwrap0-dev xmltoman libasound2-dev libgstreamermm1.0-dev \
  libice-dev libsm-dev libxtst-dev libsystemd-dev

Then we run meson command:

$ cd pulseaudio
$ meson build

meson will check our installed dependecies and setup configuration for our pulseaudio before building it. One thing you need to notice is the end part:

Message: 
    ---{ pulseaudio 16.0 }---

    prefix:                        /usr/local
    bindir:                        /usr/local/bin
    libdir:                        /usr/local/lib/arm-linux-gnueabihf
    libexecdir:                    /usr/local/libexec
    mandir:                        /usr/local/share/man
    datadir:                       /usr/local/share
    sysconfdir:                    /usr/local/etc
    localstatedir:                 /var/local
    modlibexecdir:                 /usr/local/lib/arm-linux-gnueabihf/pulseaudio/modules
    alsadatadir:                   /usr/local/share/pulseaudio/alsa-mixer
    System Runtime Path:           /var/local/run/pulse
    System State Path:             /var/local/lib/pulse
    System Config Path:            /var/local/lib/pulse
    Bash completions directory:    /usr/share/bash-completion/completions
    Zsh completions directory:     /usr/local/share/zsh/site-functions
    Compiler:                      gcc 10.2.1

    Enable pulseaudio daemon:      true
    Enable pulseaudio client:      true

    Enable memfd shared memory:    true
    Enable X11:                    false
    Enable D-Bus:                  true
    Enable GLib 2:                 true
    Enable systemd integration:    false
    Enable FFTW:                   false
    Enable IPv6:                   true
    Enable Gcov coverage:          false
    Enable Valgrind:               false
    Enable man pages:              true
    Enable unit tests:             true

    --- Pulseaudio client features ---

    Enable Gtk+ 3:                 false
    Enable Async DNS:              false
    Enable OSS Wrapper:            true

    --- Pulseaudio daemon features ---

    Safe X11 I/O errors:           false
    Enable Avahi:                  false
    Enable OSS Output:             true
    Enable Alsa:                   true
    Enable Jack:                   false
    Enable LIRC:                   false
    Enable GSettings:              true
    Enable BlueZ 5:              true
      Enable native headsets:    true
      Enable  ofono headsets:    true
      Enable GStreamer based codecs: false
    Enable GStreamer:              false
    Enable libsamplerate:          false
    Enable ORC:                    false
    Enable Adrian echo canceller:  true
    Enable Speex (resampler, AEC): true
    Enable SoXR (resampler):       true
    Enable WebRTC echo canceller:  true

    Enable udev:                   true
      Enable HAL->udev compat:     true
    Enable systemd units:          true
    Enable elogind:                false
    Enable TCP Wrappers:           true
    Enable OpenSSL (for Airtunes): true
    Database:                      tdb
    Legacy Database Entry Support: true
    module-stream-restore:
      Clear old devices:           false
    Running from build tree:       true
    System User:                   pulse
    System Group:                  pulse
    Access Group:                  pulse-access
Build targets in project: 172

Some features is marked as False like X11, gtk3. To add support for this feature you need to install the -dev packages. In sample x11 will be libx11-dev, looking around debian package website for dev package is the best you can get.

Then we build the pulseaudio

$ ninja -C build

Take a break, let the compilation run, its compiling on Pi, take your time.

Almost done, we install the pulseaudio

$ cd build
# meson install --no-rebuild

Reboot the system, it just safe measures, that systemd loading pulseaudio correctly. Run pactl info to check currently running pulseaudio:

2022-10-19-094330_779x373_scrot

This is a special part As im running pulseaudio headless, the pulseaudio may not running at startup because mostly pulseaudio will run if some user logged in and it run as that logged user. But on headless system no one can interact to login, we can set some user to automatically log in but i think override pulseaudio to run system wide is more efficient. Lets begin create our systemd pulse service

nano /etc/systemd/system/pulseaudio.service

Copy-Pasta this:

#/etc/systemd/system/pulseaudio.service
# systemd service spec for pulseaudio running in system mode -- not recommended though!
# on arch, put it under /etc/systemd/system/pulseaudio.service
# start with: systemctl start pulseaudio.service
# enable on boot: systemctl enable pulseaudio.service 
[Unit]
Description=Pulseaudio sound server
After=avahi-daemon.service network.target

[Service]
ExecStart=/usr/local/bin/pulseaudio --disallow-exit
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=30
User=pi
WorkingDirectory=/home/pi

[Install]
WantedBy=multi-user.target

You may change or update the User or WorkingDirectory depends on your system installation. Last is to enable the service sudo systemctl daemon-reload then sudo systemctl enable --now pulseaudio.service

Voila! You get latest pulseaudio on your Pi, how if the pulseaudio get new version? Delete the old pulseaudio cloned dir and clone new version, rebuild again without installing dependencies steps if you don't wipe any

sources:

Previous Post Next Post

Add a comment