I just found out that OpenWRT can be used as Apple Airplay2 Receiver via shairport-sync.
Audio is a bit finicky to setup, if you are unfamiliar with Linux audio (like me
). I also could not find useful step-by-step instructions.
Here is what I found, after some hours of experiments, to get it up and running (for me it worked on OpenWRT 24 and 25, on a Raspberry and a x86 device). Maybe it is helpful for someone else.
Restrictions:
- you need ~40MB (!) of free space on the OpenWRT device, as it needs FFMPEG to be installed. So you may need to configure extroot-on-USB on plastic routers first.
- there is no LuCi GUI
You need to connect Linux-ALSA-supported audio hardware:
- any USB-Audio-adapter or USB-soundcard will do, as this is a generic standard (a simple adapter might have come as headphone-jack-to-USB adapter with your mobile phone)
- or a X86 device with on-mainboard HD-Audio-Audio-chip
- or a Raspberry (like the 4) with built-in audio output jack
(I have not tested, whether HDMI output would work)
Install ALSA audio driver:
- RaspberryPi4: BMC audio packages are already contained in default OpenWRT image
- x86 with Realtek audio chip: packages
kmod-snd-hda-scodec-component kmod-sound-core kmod-sound-hda-core kmod-sound-hda-codec-realtek - USB sound card: package
kmod-usb-audiokmod-usb2 kmod-usb3 - other audio hardware: check if the packages
kmod-sound-*have anything matching your audio hardware
Install ALSA utils:
- Install package
alsa-utils: one of the contained tools isalsamixer, you will likely need this, to configure your sound card audio mixer, before you are able to hear any audio output.
Install the service:
- Install the package
shairport-sync-mbedtls(or one of its other two variants, depending on which SSL library you are using on your OpenWRT device)
Configure the audio mixer channels of the sound card:
- Make sure to have rebooted once after installing the modules, then run
alsamixer. - Use
F6to select the audio adapter. - Iterate through all mixers and set each to the max volume using the
cursorkeys. - Pay attention to the line
xOOx or xMMxunder each mixer channel. If any of it saysxMMx, this means, the channel is muted, if so, you need to use them-key to unmute the channel. - The config gets autosaved, when you exit via
ESC-key.
Understand that there are 3 shairport-sync usage variants on OpenWRT:
/etc/init.d/shairport-sync+ config file/etc/config/shairport-sync/etc/init.d/shairport-sync+ config file/etc/config/shairport-sync+ config file/etc/shairport-sync.conf/usr/bin/shairport-sync+ config file/etc/shairport-sync.conf
I will refer to variant 1 for the following steps.
Check if shairport-sync can successfully detect the audio hardware:
Run /usr/bin/shairport-sync -h.
On x86 hardware with onboard sound chip, the end of the output will look like:
hardware output devices:
"hdmi:PCH"
on a Raspberry 4 with an additional USB-analogue dongle, the output will look like:
hardware output devices:
"hw:Audio"(<- this was an USB audio dongle in my case)
"hw:Headphones"(<- this was the RPI4 integrated headphone jack)
Configure and run shairport-sync:
Step 1: If you only have a single audio device, you can safely skip step 1. If you have multiple audio devices, you need to tell Shairport-sync which of the audio devices it is supposed to use:
To do so, edit /etc/config/shairport-sync and
in section config shairport-sync 'shairport_sync', set the output device to one of the previously detected audio device:
option alsa_output_device 'hw:Audio'
Step 2: In /etc/config/shairport-sync
in the default sectionconfig shairport-sync 'shairport_sync'
enable the config via:
option enabled '1'
Step 3: Start the OpenWRT shairport-sync daemon:
/etc/init.d/shairport-sync enable
/etc/init.d/shairport-sync start
Done. You should now find a new working Airplay2 receiver target in your Apple device music app.
Troubleshooting:
- x86: make sure the sound chip is in enabled in BIOS
- any: if no audio hardware was found, verify, if all required modules are installed.
- any: check the config of
alsamixeragain. - any: take a look, if the output of the additional diagnostic tools
amixer,aplay -l,aplay -Lare of any help (the utils are also part of the packagealsa-utils). - USB soundcards and USB audio dongles:
lsusb(Packageusbutils) must list the device. - USB soundcards and USB audio dongles: You can use Windows 11, to verify, if the adapter is working properly. Without having to install any Windows drivers, the device manager
devmgmt.mscshould list a new USB audio device in the “Sound, video and game controllers” section. The Sound Managermmsys.cplshould list an additional output device in the “Playback” tab. Under its context menu->Configure, you can test play a test sample and under its context menu->Properties-> Advanced, you can check the supported hardware specs.