I have no idea what I'm doing.

Sunday, November 10, 2013

AirPlay to an Arch Linux Raspberry Pi via Shairport

Here's a list of the components:

  • Raspberry Pi - Model B (512 MB / Revision 2)
  • Arch Linux 3.6.11-18-ARCH+
  • some iOS devices (iPhone, iPad, etc)
  • an audio receiver with AUX in


The path of the music:

iOS device -> wifi -> router -> Pi -> 3.5mm output -> receiver input -> speakers -> my living room -> my ears


Here's a few of my notes for getting this up and running... 

Most of this is a modified version of the steps here:
http://engineer.john-whittington.co.uk/2013/05/airpi-diy-airplay-speakers-using-shairport-and-a-raspberry-pi-updated/
I wouldn't say this is an 'updated' version, because I don't know what the hell I'm doing... keep that in mind.

The first few steps are the same:
pacman -Syu
pacman -S kernel26-headers file base-devel abs
pacman -S git
pacman -S avahi libao openssl perl-crypt-openssl-rsa perl-io-socket-inet6 perl-libwww
pacman -S wget
wget https://aur.archlinux.org/packages/pe/perl-net-sdp/perl-net-sdp.tar.gz
tar -zxvf perl-net-sdp.tar.gz

The directory name is different, so...
cd perl-net-sdp
makepkg -s

And the package name is different, so...
pacman -U perl-net-sdp-0.07-1-any.pkg.tar.xz
pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins
amixer cset numid=3 1
shutdown -r now

After the Pi reboots...
mkdir shairport


The Shairport repo has moved, so use this location:
git clone https://github.com/abrasive/shairport.git shairport
cd shairport
make

Here's where things start to get a little fuzzy.
pacman -S avahi nss-mdns
systemctl restart dbus.service
systemctl |grep avahi-daemon.service

Getting avahi installed and loaded required a little more work.  While trying to start the service it would enter a failed state.  You can check the status with:

systemctl
or more specifically:
systemctl |grep avahi

It wasn't until I found this post:
that said to edit avahi-daemon.conf and change "disallow-other-stacks" from no to yes. 
vim /etc/avahi/avahi-daemon.conf

Find "disallow-other-stacks=no" and change it to yes.  Then try to restart the service:

systemctl restart avahi-daemon
check the status:
systemctl status avahi-daemon

After that, change to the Shairport directory and start it up.  From iOS you should see the new AirPlay device.
./shairport -a AirPi



A little more troubleshooting...

I needed to play around with some of the mixer settings...
pacman -S alsa-utils
alsamixer

Make sure it's unmuted and audio is going out the 3.5mm port:
amixer sset Master unmute
amixer cset numid=3 1


The final step... configure Shairport to run at startup.

following along from the blog post above....

Create the service file for shairport:
vi /etc/systemd/system/shairport.service

Add this text to the file.  If you have shairport in a different location, adjust the ExecStart path accordingly:

[Unit]
Description=Startup ShairPort (Apple AirPlay)
After=network.target
After=avahi-daemon.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/shairport -a AirPi 
ExecStop=/usr/bin/killall shairport
RemainAfterExit=yes

[Install]

WantedBy=multi-user.target

After that, give it a reboot and see if the service starts up ok.  Check the service with:
systemctl












No comments:

Post a Comment