TUTORIAL - Update Shairport, the AirPlay daemon, to Latest

WHY?
well, firstly this bug, where Airfoil cannot work with Volumio has been fixed. Also, there have been number of other improvements

HOW?
well, follow along amigo… we are going to compile from source… woohoo :bulb: :astonished:

Stop the Shairport daemon

/etc/init.d/shairport stop

Install the required tools

apt-get update
apt-get install libssl-dev libavahi-client-dev libasound2-dev build-essential

Make a temp dir in /root/temp

cd /root mkdir temp cd temp

Get the latest Source Code and unzip

wget https://github.com/abrasive/shairport/archive/master.zip
unzip master.zip
cd shairport-master

Compile the Source Code

./configure make

WAIT… WAIT…WAIT…

Backup the old binary and replace it with the new, freshly compiled version

mv /usr/local/bin/shairport /usr/local/bin/shairport.old cp shairport /usr/local/bin/

Start the Shairport daemon

/etc/init.d/shairport start

Cleanup (optional)

cd ~ rm -rf /root/temp reboot

No Sound or playback through MPD?
Sometimes MPD has a little heart attack and cannot playback if you are using multiple players.
See: mpd-fix-failed-to-open-alsa-device-hw-0-0-device-busy-t670.html

If all goes well, you will have the new version of Shairport up and running, any issues, post here and we will try to help. :ugeek:

Thanks Dakku for mentioning airfoil and of course the tutorial. I had already updated shairport to 1.0 master branch the other day. I totally forgot to test with airfoil. It’s nice to play some streams off safari now!

The current version behaves a little differently for me though now. First, shairport doesn’t sync with my apple tv or computer playback anymore. It wasn’t super close, but close enough. But after the install, it became a lot worse. Ran maybe half a second behind.

I added a buffer attribute of “-b 95” to /etc/init.d/shairport. Seems to sync ok now. I think the default was 220. Less buffer now I guess.

I have a dac (hifimediy u2) that has a hardware mixer. I like the hardware volume control. When I was looking at shairport help, it says you can actually choose your output and mixer type. Default is software. Hardware would be better if you have the ability. So I tried the following.

/usr/local/bin/shairport -b 95 -d -a "Volumio" -o alsa -- -t "hardware"

But get this error: FATAL: Failed to find mixer elementFailed to find mixer element

Don’t know what that’s all about. Anyone have any idea?

Another thing I noticed. I’m hearing a weird pop between tracks when manually picking songs. It kind of sounds like a split second blip of the previous or current track? When you just let the song play through to the next there is no pop though. I don’t think I noticed this noice with the older version of shairport. I could be wrong though. Have you noticed this?

Thanks, I noticed that mine was off too - I will try this buffer change and let you know.

I am running a Musical Fidelity V-DAC (classic) via USB, but mine doesnt have the hardware mixer, so I cannot test the above. However, my understanding was the the volume control was on the transmitter? ie, Airfoil??

I remember reading about it in another forum. However, I have not noticed any issues (apart from the lag/buffer issue). I mostly use Airfoil from my macbook pro with Spotify (free). Will do some more testing and let you know.

How can one check to see what version of shairport is currently installed?

sadly Shairport does not have a way to check version. But if you compiled from source using the “master” brach - as per the tutorial, then you should have the latest version.

I was more curious to know the version included with Volumio, to see all the changes. No big deal, I can estimate by the date.
When I run configure, I get these messages. Will these cause any problems? Especially Avahi, isn’t that required for iOS to find the Airplay receiver?

PulseAudio or its dev package not found
Avahi client or its dev package not found
dns_sd.h not found

May I ask what version of Volumio are you running? I installed on 1.1 and didnt see any of those issues (or atleast I dont recall seeing them). As long as configure doesnt bum out with en error and fail, i think you might be ok.

The image I’m using is called VolumioBeta1.1PI.img.

I am on the same version. let me try to compile again and I will post the full log.

Configure Output

root@volumio:~/temp/shairport-master# ./configure Configuring Shairport OpenSSL found libao found PulseAudio or its dev package not found ALSA found Avahi client found getopt.h found CFLAGS: -I/usr/include/alsa -D_REENTRANT LDFLAGS: -lm -lpthread -lssl -lcrypto -lao -lasound -lavahi-common -lavahi-client Configure successful. You may now build with 'make' root@volumio:~/temp/shairport-master#

Make Output

root@volumio:~/temp/shairport-master# make
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   shairport.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   daemon.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   rtsp.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   mdns.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   mdns_external.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   mdns_tinysvcmdns.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   common.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   rtp.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   player.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   alac.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   audio.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   audio_dummy.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   audio_pipe.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   tinysvcmdns.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   audio_ao.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   audio_alsa.c
cc -c -O2 -I/usr/include/alsa   -D_REENTRANT   mdns_avahi.c
cc shairport.o daemon.o rtsp.o mdns.o mdns_external.o mdns_tinysvcmdns.o common.o rtp.o player.o alac.o audio.o audio_dummy.o audio_pipe.o tinysvcmdns.o audio_ao.o audio_alsa.o mdns_avahi.o -lm -lpthread -lssl -lcrypto   -lao   -lasound   -lavahi-common -lavahi-client   -o shairport
root@volumio:~/temp/shairport-master# 

Hello,
thank you for the tutorial!
Unfortunately I did not succeed, please could you give me any hint to solve the problem.
I wanted to update the shairport because my current version does not support the option -w, as it is recommended in this thread:

shairport-and-mpd-won-get-along-t332.html

The option -w is simply not listed (shairport -h) in my version.
My current shairport version has file size 61900 (-rwxr-xr-x 1 root staff 61900 Aug 22 2013 shairport)

System specs:
CuBox-i4-Pro
Volumio 1.2 (VolumioBeta12CuboxI.img)

I could install the packages libssl-dev libasound2-dev build-essential,
but not libavahi-client-dev.

I got the message:

root@volumio:/# apt-get install  libavahi-client-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libavahi-client-dev : Depends: libdbus-1-dev (>= 0.60) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.[/code]
Probably therefore I could not succeed with the step Compile the Source Code:
[code]root@volumio:~/temp/shairport-master# ./configure
Configuring Shairport
OpenSSL or its dev package not found
Required package not found, cannot continue[/code]
[code]root@volumio:~/temp/shairport-master# make
Makefile:2: config.mk does not exist, configuring.
sh ./configure
Configuring Shairport
OpenSSL or its dev package not found
Required package not found, cannot continue
make: *** No rule to make target `config.mk'.  Stop.[/code]
I tried to find the solution using google, but probably I miss something. I'm getting into Linux step by step, but I'm far from being an expert...
Thank you for any hints in advance!

EDIT:
Actually the problem is the dependent package libdbus-1-3
[code]root@volumio:/etc/init# apt-get install libdbus-1-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libdbus-1-dev : Depends: libdbus-1-3 (= 1.6.8-1+deb7u1) but 1.6.12-1 is to be installed
E: Unable to correct problems, you have held broken packages.[/code]
I wanted to try if I can remove the package libdbus-1-3 and reinstall it again. But I stopped here because I don't think that I can remove all the other packages and reinstall them as well, I'm not sure...
[code]root@volumio:/etc/init# apt-get remove libdbus-1-3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cron exim4 exim4-base exim4-config exim4-daemon-light heirloom-mailx libfile-copy-recursive-perl
  libtdb1 logrotate samba-common samba-common-bin tdb-tools update-inetd
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  avahi-daemon avahi-utils dbus libavahi-client3 libcups2 libdbus-1-3 libfluidsynth1 libnss-mdns
  libpulse0 mpd samba
0 upgraded, 0 newly installed, 11 to remove and 0 not upgraded.
After this operation, 19.6 MB disk space will be freed.
Do you want to continue [Y/n]?

I could solve the problem with the package libavahi-client-dev using aptitude as follows. I hope I did not break something else with this solution :smiley:
All other steps I could do according the first post from dakku.

System specs:
CuBox-i4-Pro
Volumio 1.2 (VolumioBeta12CuboxI.img) - new clean flash

[code]
root@CuBox-i:~# apt-get install libavahi-client-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libavahi-client-dev : Depends: libdbus-1-dev (>= 0.60) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.[/code]

apt-get install aptitude
aptitude -f install libavahi-client-dev

[code]The following actions will resolve these dependencies:

 Keep the following packages at their current version:
  1. libavahi-client-dev [Not Installed]
    
  2. libdbus-1-dev [Not Installed]
    

Accept this solution? [Y/n/q/?] n

The following actions will resolve these dependencies:

 Install the following packages:
  1. pkg-config [0.26-1+b1 (stable)]
    

    Downgrade the following packages:

  2. libdbus-1-3 [1.6.12-1 (now) -> 1.6.8-1+deb7u1 (stable)]
    

Accept this solution? [Y/n/q/?] y[/code]

root@CuBox-i:/usr/local/bin# ls -all total 148 drwxrwsr-x 2 root staff 4096 May 2 19:46 . drwxrwsr-x 10 root staff 4096 Aug 10 2013 .. -rwxr-xr-x 1 root staff 74524 May 2 19:46 shairport -rwxr-xr-x 1 root staff 61900 Aug 22 2013 shairport.old root@CuBox-i:/usr/local/bin#
Now I have a new version of shairport, that finally also offers the option -w

[code]root@CuBox-i:/usr/local/bin# shairport -h
Usage: shairport [options…]
or: shairport [options…] – [audio output-specific options]

Mandatory arguments to long options are mandatory for short options too.

Options:
-h, --help show this help
-p, --port=PORT set RTSP listening port
-a, --name=NAME set advertised name
-k, --password=PW require password to stream audio
-b FILL set how full the buffer must be before audio output
starts. This value is in frames; default 220
-d, --daemon fork (daemonise). The PID of the child process is
written to stdout, unless a pidfile is used.
-P, --pidfile=FILE write daemon’s pid to FILE on startup.
Has no effect if -d is not specified
-l, --log=FILE redirect shairport’s standard output to FILE
If --error is not specified, it also redirects
error output to FILE
-e, --error=FILE redirect shairport’s standard error output to FILE
-B, --on-start=COMMAND run a shell command when playback begins
-E, --on-stop=COMMAND run a shell command when playback ends
-w, --wait-cmd block while the shell command(s) run
-o, --output=BACKEND select audio output method
-m, --mdns=BACKEND force the use of BACKEND to advertise the service
if no mdns provider is specified,
shairport tries them all until one works.

Available mDNS backends:
avahi
external-avahi
external-dns-sd
tinysvcmdns

Available audio outputs:
alsa (default)
ao
dummy
pipe

Options for output alsa:
-d output-device set the output device [default*|…]
-t mixer-type set the mixer type [software*|hardware]
-m mixer-device set the mixer device [‘output-device’|…]
-c mixer-control set the mixer control [Master
|…]
-i mixer-index set the mixer index [0*|…]
*) default option

Options for output ao:
-d driver set the output driver
-o name=value set an arbitrary ao option
-i id shorthand for -o id=
-n name shorthand for -o dev= -o dsp=

Options for output dummy:
There are no options for dummy audio.

Options for output pipe:
pipe takes 1 argument: the name of the FIFO to write to.[/code]
I can start shairport manually using the script

/etc/init.d/shairport start

and play audio from my iPhone 4S iOS7.
I will try to modify the script using the option -w and will also test if shairport starts after reboot.

Now the shairport starts automatically during the boot sequence, it seems to be working pretty stable.
I rebooted Volumio 1.2 on my Cubox-i 4 Pro several times, tried switching the playback from mpc to shairport and back, sending audio to AirPlay from multiple iOS7 devices, did not get any errors so far.

nano /etc/rc.local

add line:

/usr/local/bin/shairport -d -a "Volumio" -w -B "mpc stop"

Since the Volumio are all the same, it would be a good idea to provide a working package, without having everyone recompile the same stuff again and again (waste of time, efforts and energy).

Question: why was shairport instead of shairplay used?

Well, this thread was about shairport, so I did it with shairport, I’ve never heard about shairplay before :slight_smile:
I don’t know why the package shairplay doesn’t come with Volumio.

/etc/init.d/shairport start -bash: /etc/init.d/shairport: No such file or directory
update do not help! )

[code]at /etc/init.d/shairport
#! /bin/sh

/etc/init.d/shairport

BEGIN INIT INFO

Provides: shairport

Required-Start: alsa-utils hostname avahi

Required-Stop: alsa-utils hostname avahi

Short-Description: shairport - Airtunes emulator!

Description: Airtunes emulator!

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

END INIT INFO

NAME=“Volumio”

case “$1” in
start)
/usr/local/bin/shairport -d -a “$NAME” -w -B “mpc stop”
;;
stop)
killall shairport
;;
*)
echo “Usage: /etc/init.d/shairport {start|stop}”
exit 1
;;
esac

exit 0
[/code]

/etc/init.d/shairport start Starting Shairport 1.1.1-23-gd65b8e8 Listening for connections. 1709