OpenEmbedded layer for Shairport Sync

I wrote an OpenEmbedded layer for Shairport-Sync software, which enables a Linux device as an AirPlay audio receiver.
In December 2022, I attended for work an embedded Linux course with Bootlin. It introduced me the basics to set-up an embedded Linux system on custom hardware. In the toolbox I got introduced, there is the OpenEmbedded build framework and the Yocto project to create custom distributions.
OpenEmbedded
OpenEmbedded project logo
Yocto project
Yocto project

As a good exercise is always more than thousand words, I decided to apply my new skills on a meaningful project; When I’m working, I like to listen to music on my office’s speakers. It’s even better to do it wireless. I wanted to stream more generally any sound out of my iPad. The perfect software to do so is Shairport-Sync. It’s open-source and proposed by mikebrady on GitHub to enable your Linux system as an Apple AirPlay playback device on your network. Recently, he added the AirPlay 2 support which enables the integration of your system in the Home app.

Even before this, it was already fully configurable in terms of audio outputs, backends and settings; it can trigger scripts when the playback starts or stops and even report the currently played track’s info over MQTT.

Instead of manually installing Shairport on a standard Linux distribution, I created an OpenEmbedded layer to be able to install it on a minimal system, with its basic requirements; Shairport depends on SoxR, a well-known resampling library and also needs nqptp “Not Quite PTP” created by mikebrady as a timing data monitor.

Writing the recipes to compile and install this software and dependencies with autotools and CMake taught me how to use the OpenEmbedded and Bitbake ecosystem.

Shaiport gets compiled with Alsa as audio backend and AirPlay2 protocol. The layer installs it as a SysVInit daemon which starts up nqptp then Shairport at boot. It means that after adding the Shairport layer to a Yocto distribution, you just have to compile and flash your rootfs, set your network up, plug speakers to your board and you end up with an AirPlay audio device!

For my use case, I made a system for a Raspberry Pi + HifiBerry HAT setup. As you can see on the images below, my “AudioOffice” is in the iOS AirPlay devices selection menu. I can cast any sound on my device to my office speakers !

AirPlay devices list
List of available AirPlay devices
Audio office playing
Playing music in Apple Home app

All of this lets tons of space for improvements: Shairport could be compiled with many more features, such as MQTT, other audio backends, resampling features and many more. SysVInit is currently used, but Systemd should be used for bigger systems. These compilation flags  could be chosen automatically, depending on the init system and audio backend used in the distro.

The source code of the layer is available on my GitHub under MIT license, ready to be explored, starred, used and improved!