Shairport Sync

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Shairport Sync is an w: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: aplay -L and look at the raw audio device, like:

sysdefault:CARD=PCH
    HDA Intel PCH, ALC269VC Analog
    Default Audio Device

Edit /etc/shairport-sync.conf and add the device name:

// 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 using systemd.

Daemon Setup

If you want to run shairport-sync as a daemon you will need to have a folder created in /var/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 /var/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.

To run shairport-sync as user daemon, you can add it to the desktop environment autostart, or use a systemd service:

# cp /usr/lib/systemd/system/shairport-sync.service /etc/systemd/user/

Next, edit /etc/systemd/user/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 start service as user:

$ systemctl --user enable --now shairport-sync.service

To obtain logs:

$ journalctl --user -fu shairport-sync.service