Shairport Sync

From ArchWiki

Shairport Sync is an AirPlay audio player — it plays audio streamed from iTunes, iOS devices and third-party AirPlay sources such as ForkedDaapd and others. Audio played by a Shairport Sync-powered device stays synchronised with the source and hence with similar devices playing the same source. In this way, synchronised multi-room audio is possible without difficulty.

Shairport Sync does not support AirPlay video or photo streaming.

Shairport Sync is a fork of the original Shairport which was based on reverse-engineering Apple's key used in its AirPort Express. Be advised that this functionality may be removed at Apple's discretion.

Installation

Install the shairport-sync package.

Note: Shairport Sync requires the avahi-daemon to be running. You can start/enable avahi-daemon.service using systemd.

Configuration

The configuration file can be found at /etc/shairport-sync.conf. It contains useful comments and configuration hints. More documentation is available in the README file.

Audio backend

Shairport Sync works well with PulseAudio, while the timing information is not as accurate as that of Alsa or sndio, it is often impractical to remove or disable PulseAudio. In that case, the pa backend can be used.[1]

If you would like to change the backend, check the list of output devices, e.g. by using tools from alsa-utils, and look at the raw audio device, like:

$ aplay -L
...
sysdefault:CARD=PCH
    HDA Intel PCH, ALC269VC Analog
    Default Audio Device
...

Then add the device name:

/etc/shairport-sync.conf
// These are parameters for the "alsa" audio back end.
// For this section to be operative, Shairport Sync must be built with the following configuration flag:
// --with-alsa
alsa =
{
    output_device = "sysdefault";
}

System service

Starting

Start/enable shairport-sync.service.

Daemon Setup

If you want to run shairport-sync as a daemon you will need to have a folder created in /run which is a tempfs by default in Arch Linux. To have a folder created automatically on boot create a tempfiles configuration file, for example:

/usr/lib/tempfiles.d/shairport-sync.conf
d /run/shairport-sync 0755 username group

you can now use shairport-sync -d to run shairport-sync as a daemon, and shairport-sync -k to kill the daemon.

User service

According to the author, the PulseAudio backend with the default PulseAudio configuration can only work as a user service. As of 2022-01-27, it seems to just work as a system service with pulseaudio (pipewire-pulse) without modification, not needing the user service.

To run shairport-sync as user daemon, you can add it to the desktop environment autostart, or enable shairport-sync.service as a user unit.

Next, edit shairport-sync.service and comment out the next lines:

[Unit]
...
#Requires=avahi-daemon.service
#After=avahi-daemon.service
...
[Service]
...
#User=shairport-sync
#Group=shairport-sync
...

Now, you are ready to enable/start shairport-sync.service as user:

To obtain logs, use the journal or check the unit status.