Stream audio to any Sonos component via AirPlay using a Raspberry Pi (Model B, Raspbian Jessie) and the following software:

  • Shairport Sync: configures the Raspberry Pi as an AirPlay audio player.
  • DarkIce: encodes audio received from AirPlay (system audio) and sends it to Icecast2.
  • Icecast2: serves streaming audio from DarkIce at a network URL.

Setup Raspberry Pi

Alsa Loopback 1

Create a loopback device to capture system audio.

sudo modprobe snd-aloop

Persist by adding the following to /etc/modules:


note: use aplay -l to see playback devices

Shairport Sync


note: this method uses stow, to symlink files installed to /usr/local/stow/shairport-sync.

cd /usr/src
git clone
cd shairport-sync
sudo apt-get install build-essential autoconf automake libtool \
                     libdaemon-dev libasound2-dev libpopt-dev \
                     libconfig-dev avahi-daemon libavahi-client-dev \
                     libssl-dev libsoxr-dev
autoreconf -i -f
./configure --with-alsa --with-avahi --with-ssl=openssl --with-metadata \
            --with-soxr --with-systemd --prefix=/usr/local
make PREFIX=/usr/local
sudo make install prefix=/usr/local/stow/shairport-sync
cd /usr/local/stow
sudo stow shairport-sync

Edit /lib/systemd/system/shairport-sync.service to comment out the User/Group lines (creating this user and group was not needed):


Edit /etc/shairport-sync.conf:

general = {
  name = "Sonos";
  interpolation = "soxr";

note: set interpolation to basic to reduce cpu load.

Start and persist on reboot:

sudo systemctl start shairport-sync.service
sudo systemctl enable shairport-sync.service



sudo apt-get install icecast2

Edit /etc/icecast2/icecast.xml to reduce latency:


Start and persist on reboot:

sudo systemctl start icecast2
sudo systemctl enable icecast2



sudo apt-get install darkice

Create and add the following to /etc/darkice.cfg:

# see the darkice.cfg man page for details

duration        = 0
bufferSecs      = 1
reconnect       = yes
realtime        = yes
rtprio          = 3

device          = hw:Loopback,1,0
sampleRate      = 44100
bitsPerSample   = 16
channel         = 2

bitrateMode     = vbr
format          = mp3
quality         = 0.8
server          = localhost
port            = 8000
password        = <pwd>
mountPoint      = sonos
name            = sonos

Create and edit /etc/systemd/system/darkice.service:

Description=DarkIce Live audio streamer



start, and persist on reboot:

sudo systemctl daemon-reload
sudo systemctl start darkice.service
sudo systemctl enable darkice.service

Setup Sonos Controller

Download the Sonos Desktop Controller

Add the icecast2 streaming URL (http://<ip_addr>:8000/sonos.m3u) via the Sonos Desktop Controller

Play Music

  1. Reboot the Raspberry Pi
  2. Play music to the ‘Sonos’ AirPlay controller (Raspberry Pi)
  3. Connect the Sonos zone(s) to the stream via My Radio Stations in TuneIn