Apr 25

On Friday 8th April, ShairPort was released. Containing the private key from a reverse-engineered Apple AirPort Express, this allows unlicensed/homebrew devices to act as AirPlay target speakers – e.g. allows iTunes, iPods, iPads, and iPhones to use them as an output device.

Immediately, the obvious thought is to add AirPlay support to Logitech/Slim Devices’ Squeezebox Server software so that the excellent Squeezebox devices can be used as remote speakers.

(As an aside, I’ve had my 3rd generation Squeezeboxsince they were introduced in 2005, and it is without the highest quality and most used gadget I have, still going strong and as useful as ever more than five years later!)

After a few false-starts trying to configure ALSA to record the digital output of the host’s soundcard, the latest release of ShairPort provides a perfect solution to lossless audio reproduction, without even needing a soundcard.

Given that WaveInput is designed to re-record a soundcard’s output, this was my first vector of attack. After several days of reading asound.conf definitions and a great deal of head-scratching, the best I managed was working but massively distorted and noisy AirPlay. It worked, but the sound codec in my server (a Realtek ALC887) only supports Analogue recording from the Headphone output to the Microphone input. I suspect that the fact that these physical inputs were disconnected gave rise to the static and noise. I may, with time, have been able to fix this with a combination of plugs and plugins in ALSA, but it was just too much of a hack.

So I had a re-think, and moved on to:

Setup:

I have a storage-server which contains my digital music files, and also runs the Squeezebox Server software. This machine runs Gentoo Linux with the gentoo-specific build of this software, which splits it up into different locations on the filesystem rather than keeping everything in one directory – that should not affect these instructions.

The Squeezebox hardware is in a different room, connected only by being on a Wifi network which is bridged to the wired network the storage server runs on.

Pre-requisites:

To follow this guide, you will need:

  • A media server (which needn’t be powerful: this one is a dual-core Intel Atom machine);
  • … with at least perl-5.10.0;
  • … and the latest version of Logitech’s Squeezebox Server software;
  • … along with avahi to provide Rendezvous/Bonjour auto-discovery on Linux.

ShairPort itself requires IPv6 to be supported and enabled (/sbin/ifconfig | grep -B2 inet6), and requires perl’s IO::Socket::INET6 to be installed.

Note that the Squeezebox Server plugin used here is also available on Windows, but I don’t know how to interact with this OS’ pipe implementation.

Mac OS users are actually in a much better position: pre-0.5 ShairPort implementations would have needed a utility such as Soundflower in order to record audio output – this the new approach neatly sidesteps this issue. As OS X is fully POSIX-compliant, named pipes work just as below.

Method:

ShairPort’s hairtunes code now supports audio output to a named pipe, so all we need do is to make use of this option, and then read the data from this pipe back into Squeezebox Server (via the WaveInput plugin) in order to have (mostly) lossless AirPlay/AirTunes audio via Squeezebox. ecasound will block on reading from the pipe if no writer is attached, and hairtunes will block on write without a reader. iTunes will continue to play regardless, and there may be instances where stale data is read from the pipe when a reader re-connects. On Linux, pipes will cache up to 64k of data, and since writing is done in real-time with no seek capability drop-outs are uncommon but possible if the network is congested. It is possible to cause ecasound to buffer more data, at the expense of lag when starting playback or changing tracks. With the default settings, there is a delay of about a second due to buffering.

Installation:

For a Gentoo Squeezebox Server installation (“emerge -v squeezeboxserver“), a stack of perl modules will have to have been required. In addition to this, ShairPort also needs:

IO::Socket::SSL
IO::Socket::INET6
Crypt::OpenSSL::RSA

… to be installed, so “emerge -v IO-Socket-SSL IO-Socket-INET6 Crypt-OpenSSL-RSA” and resolve any keywords/dependency conflicts which may occur. Also install avahi and ecasound whilst at it, this latter being the suggested tool to transcode the sound stream from AirPlay/AirTunes.

Ensure that Squeezebox Server works and can contact the Squeezebox hardware, and then go to Settings -> Plugins and look for a “WaveInput” item. If not present, then add “http://bpaplugins.googlecode.com/svn/trunk/repo.xml” in the text-box at the bottom of the page, Apply, and then look for WaveInput in the new “bpa’s Squeezecenter Plugins” section. Tick this, and a “WaveInput” directory will be created in the Squeezebox Server “Plugins” directory.

(WIth the Gentoo-specific installation, this will be in /var/lib/squeezeboxserver/cache/InstalledPlugins/Plugins/, but since we’ll be customising the supplied files I suggest moving the WaveInput directory to /var/lib/squeezeboxserver/Plugins/)

Within the WaveInput directory, there will be a selection of custom-convert.conf files – backup any existing custom-convert.conf and rename custom-convert.conf.ecasound to have this name. Edit the contents to read:

1
2
3
4
5
6
7
8
9
10
11
12
#
# wavin
#
wavin wav * *
# IFR
[ecasound] -q -z:db -b:4096 -f:16,2,44100 -i /var/lib/squeezeboxserver/airplay-fifo.raw -o stdout
wavin mp3 * *
# IFRB:{BITRATE=-B %B}D:{RESAMPLE=--resample %D}
[ecasound] -q -z:db -b:4096 -f:16,2,44100 -i /var/lib/squeezeboxserver/airplay-fifo.raw -o stdout  | [lame] --silent -r -x -q $QUALITY$ $RESAMPLE$ -v $BITRATE$ - -
wavin flc * *
# IFRD:{RESAMPLE=-r %d}
[ecasound] -q -z:db -b:4096 -f:16,2,44100 -i /var/lib/squeezeboxserver/airplay-fifo.raw -o stdout  | [flac] -cs --totally-silent --endian=little --channels=2 --sign=signed --bps=16 --sample-rate=44100 --compression-level-0 -

Noting that /var/lib/squeezeboxserver/airplay-fifo.raw is the location I’ve chosen to store the reference to the named pipe in the filesystem – no data is ever written to this file. The name must end in “.raw” in order for ecasound to be able to recognise the type of data coming from it.

In Squeezebox Server’s web user-interface, create a new Favourite named “AirPlay” with URL “wavin:default” (although the text after the colon is not used, and is a carry-over from the previous ALSA-based attempts at getting AirPlay to work).

Download ShairPort (“git clone https://github.com/albertz/shairport.git“) and edit the Makefile if necessary – I set custom CFLAGS and LDFLAGS to match the system:

$ diff Makefile Makefile.local
2,3c2,3
< CFLAGS:=-O2 -Wall
< LDFLAGS:=-lm -lpthread
---
> CFLAGS:=-march=atom -Os -pipe -Wall

> LDFLAGS:=-lm -lpthread -Wl,-O1 -Wl,--as-needed

… and run ‘make -f Makefile.local‘ – you will need a working C compiler installed (or Xcode on OS X – Windows users need Cygwin).

Update: ShairPort 0.5 is now updated with my additional fixes and Squeezebox control code so this next part no longer applies! ;)

If using ShairPort 0.5, edit the shairport.pl file, and make the following changes to fix code-correctness:

$ diff shairport.pl /usr/local/bin/shairport.pl
1c1,15
< #!/usr/bin/env perl
---
> #!/bin/sh

> if test -n "`perl -V | grep "5\.0"`"
> then
>    echo -n "FATAL: You appear to have perl "
>    for WORD in `perl -v | grep "^This is "`
>    do
>        echo $WORD
>    done | grep "5" | xargs echo -n
>    echo ", but at least version 5.10.0 is required."
>    exit 1
> fi
> exec perl -wx $0 "$@"
>    if 0;
> #!perl -w
> #line 16
27a42,43
> use strict;
>
61a78
> my $help;
64,68c81,86
< say "Can't find the 'hairtunes' decoder binary, you need to build this before using Shairport.";
<     say "Trying to build it for you anyway...";
<     system("cd ${FindBin::Bin}; make || gmake");
<     die("Nope, didn't work out. Read the INSTALL instructions!") unless -x $hairtunes_cli;
<     say "Phew! Worked out okay, by the looks of it.";
---
>     die "Can't find the 'hairtunes' decoder binary, you need to build this before using Shairport.";

>     #say "Can't find the 'hairtunes' decoder binary, you need to build this before using Shairport.";
>     #say "Trying to build it for you anyway...";
>     #system("cd ${FindBin::Bin}; make || gmake");
>     #die("Nope, didn't work out. Read the INSTALL instructions!") unless -x $hairtunes_cli;
>     #say "Phew! Worked out okay, by the looks of it.";
137c155
< exec 'avahi-publish-service',
---
>     { exec 'avahi-publish-service',

141,142c159,160
< "tp=UDP", "sm=false", "sv=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", "ss=16", "sr=44100", "pw=false", "vn=3", "txtvers=1";
<     exec 'dns-sd', '-R',
---
>         "tp=UDP", "sm=false", "sv=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", "ss=16", "sr=44100", "pw=false", "vn=3", "txtvers=1"; };

>     { exec 'dns-sd', '-R',
147c165
< "tp=UDP", "sm=false", "sv=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", "ss=16", "sr=44100", "pw=false", "vn=3", "txtvers=1";
---
>         "tp=UDP", "sm=false", "sv=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", "ss=16", "sr=44100", "pw=false", "vn=3", "txtvers=1"; };

216c234
< foreach $fh (@waiting) {
---
>     foreach my $fh (@waiting) {

(Note to self: Update diff syntax for GeSHi to support unified diffs… I’m afraid the spacing appears to be out above on the first line of each original block above – I’ll try to fix this layout problem)

… and copy hairtunes and shairport.pl to the desired final location – I used /usr/local/bin/.

Finally, we just need a script to start ShairPort with the correct options. This is again targetted at Gentoo, but any Linux distribution will be similar. ShairPort 0.5 includes a plist for OS X as well as installation instructions. I guess Windows users could create a service… it’s not really my area (… but if you have perl working and a C compiler, I’m guessing you’re way ahead of me at this point ;)

/etc/conf.d/airplay:

1
2
3
4
5
6
7
8
9
10
11
12
# Settings for shairport/Apple AirPlay daemon...
AIRPLAY_NAME="Squeezebox Airplay"
AIRPLAY_PASSWD=""

# Send output to a pipe/FIFO
AIRPLAY_PIPE="/var/lib/squeezeboxserver/airplay-fifo.raw"

# Audio output options
#AIRPLAY_AUDIO_DRIVER="alsa"
#AIRPLAY_AUDIO_DEVICE="hw:0,0"

AIRPLAY_USE_SQUEEZEBOX="1"

/etc/init.d/airplay (Updated for Squeezebox support):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/sbin/runscript

AIRPLAY=/usr/local/bin/shairport.pl
uid=nobody
gid=nogroup
pid=/var/run/airplay.pid

depend() {
    need avahi-daemon
    use squeezeboxserver
}

start() {
    local OPTS=""

    if ! [[ -x "$AIRPLAY" ]]; then
        eerror "Cannot locate AirPlay daemon '$AIRPLAY'"
        return 1
    fi
    if [[ -z "$AIRPLAY_NAME" ]]; then
        eerror "Access Point name not set"
        return 1
    fi
    if [[ -n "$AIRPLAY_USE_SQUEEZEBOX" ]]; then
        if [[ -r /etc/conf.d/squeezeboxserver ]]; then
            SBS_OPTS="$( grep "^SBS_OPTS" /etc/conf.d/squeezeboxserver | sed -r '/^SBS_OPTS/s:^.*\s(--cliport\s+[0-9]+).*$:\1:' )"
        fi
        OPTS="$OPTS --squeezebox"
    fi
    if [[ -n "$AIRPLAY_PIPE" ]]; then
        if [[ -p "$AIRPLAY_PIPE" ]]; then
            chmod 0660 "$AIRPLAY_PIPE" && \
            chown $uid:audio "$AIRPLAY_PIPE" && \
            einfo "Using existing named pipe \"$AIRPLAY_PIPE\" for output" || \
            { eend $? "Unable to set correct metadata on named pipe \"$AIRPLAY_PIPE\"" ; return 1 ; }
        else
            mkfifo -m 0660 "$AIRPLAY_PIPE" && \
            chown $uid:audio "$AIRPLAY_PIPE" && \
            einfo "Named pipe \"$AIRPLAY_PIPE\" created" || \
            { eend $? "Failed to create named pipe \"$AIRPLAY_PIPE\"" ; return 1 ; }
        fi
        OPTS="$OPTS --pipe=\"$AIRPLAY_PIPE\""
    else
        if [[ -n "$AIRPLAY_AUDIO_DRIVER" ]]; then
            OPTS="$OPTS --ao_driver=\"$AIRPLAY_AUDIO_DRIVER\""
            einfo "Using audio driver \"$AIRPLAY_AUDIO_DRIVER\""
        fi
        if [[ -n "$AIRPLAY_AUDIO_DEVICE" ]]; then
            OPTS="$OPTS --ao_devicename=\"$AIRPLAY_AUDIO_DEVICE\""
            einfo "Using audio device \"$AIRPLAY_AUDIO_DEVICE\""
        fi
    fi
    if [[ -n "$AIRPLAY_PASSWD" ]]; then
        ebegin "Starting password-protected AirPlay daemon for Access Point '$AIRPLAY_NAME'"
        OPTS="$OPTS -p \"$AIRPLAY_PASSWD\""
    else
        ebegin "Starting AirPlay daemon for Access Point '$AIRPLAY_NAME'"
    fi
    if ! start-stop-daemon --start --exec "$AIRPLAY" --chuid $uid --background --make-pidfile --pidfile "$pid" -- -a "$AIRPLAY_NAME" $OPTS; then
        export pid AIRPLAY AIRPLAY_NAME OPTS
        touch "$pid"
        chown $uid:$gid "$pid"
        #su - $uid -m /bin/sh -c "echo \"\$$\" >\"$pid\" ; exec \"$AIRPLAY\" -a \"$AIRPLAY_NAME\" $OPTS /dev/null 2>&1" &
        su - $uid -m /bin/sh -c "\"$AIRPLAY\" -a \"$AIRPLAY_NAME\" -d -w \"$pid\" $OPTS $SBS_OPTS"
    fi
    eend $? "Failed to start \"$AIRPLAY\""
}

stop() {
    ebegin "Stopping AirPlay daemon"
    start-stop-daemon --stop --exec "$AIRPLAY" --pidfile "$pid" --retry
    eend $? "Failed to stop \"$AIRPLAY\"$( test -e "$pid" && echo " (PID " && cat "$pid" && echo ")" )"
}

status() {
    if [[ -e "
$pid" ]]; then
        einfo "
AirPlay daemon $( "$AIRPLAY" --help | head -n 1 | cut -d" " -f 3 ) running as PID $( cat "$pid" )"
    fi
}

… customise these files with any installation-specific paths, and things are ready to go!

Once the airplay script is started, iTunes and any iOS devices should see a new AirPlay target with the specified name (“Squeezebox Airplay”) and can play to this immediately. One the Squeezebox main menu, choose Favourites and press play, and after a second’s delay (due to buffering) you should get crystal-clear AirPlay audio!

Sound data is sent uncompressed from hairtunes, but will be converted by Squeezebox Server to the most efficient format your hardware supports – but network congestion can cause drop-outs which will cause playback pauses (bear in mind that you’ve likely got one audio stream from the source device to the AirPlay server, and another from the AirPlay server to the Squeezebox – so this isn’t something for a loaded 802.11b Wifi network…).

Given that the kernel will only cache a maximum of 64k of data for a named pipe, there is no risk if Squeezebox Server stops reading from the pipe or crashes. iTunes at least seems happy to send data even if the pipe is blocked, and playback will start (with a potential 64k glitch and then re-sync delay) as soon as the pipe has a reader attached. ecasound will happily sit on the pipe waiting for data to appear, and Squeezebox Server seems happy to handle this (showing the AirPlay Favourite as playing and with the playback timer increasing as expected). I’ve not yet had chance to test when happens if multiple clients attempt to connect – I assume that the AirPlay protocol handles this itself before the audio layer is involved.

So that’s it! AirPlay on Squeezebox – life’s good :)

(Bonus points: WTF isn’t start-stop-daemon working in the above script, necessitating the work-around implemented below? Free Promo code for one of my commercial iOS apps to anyone who can enlighten me in the comments below…)

51 Responses to “AirPlay support for Logitech Squeezebox devices”

  1. Stuart Says:

    So if another device tries to connect it will happily appear to play, without anything actually happening. This is because the first device to connect opens the named pipe as a writer and then nothing else can connect. For multi-writer pipes, you’re into Unix Domain Socket territory.

    However, the mtime/ctime of a named pipe is updated iff data is transferred (e.g. a reader and writer are connected) so a periodic job could be created to remove and re-create stale pipes, so that an old client can’t block the speakers if not transmitting any data, or if the Squeezebox isn’t playing. This would need testing…

    Another good idea would be to watch shairport.pl’s output for “client connected” events, and issue an HTTP command to Squeezebox Server to power-on and play the AirPlay Favourite (or the AirPlay URL directly).

  2. Stuart Says:

    Q: Why define multiple formats the “custom-convert.conf”?
    A: Squeezebox Server can choose to play different streams depending on the hardware (the original SliMP3 can only play MP3 data, the 1st generation Squeezebox adds aif and pcm, whilst the 2nd generation Squeezebox adds native flac and wma) and the network conditions.

    Q: Why use ecasound to process the incoming data for the “wav” entry when there is no conversion taking place?
    A: There is no guarantee of the form of the input data, and ecasound is used to re-sample and mix the source data into 2 x 16-bit channels of audio at a 44.1k sample-rate – and also to buffer the result. Simply ‘cat‘ing the pipe provides no under-run protection and makes no guarantee about the characteristics of the output.

  3. Stuart Says:

    I’ve had my code to add support for the triggering of Squeezebox hardware actions on AirPlay client connect (un-muting, selecting the correct source, etc.) added to the project github repository!

    https://github.com/albertz/shairport/commit/34ddce28b9c699fade5876b902b776365e215ebc

    There’s also an OS X-native menu item available from here:

    https://github.com/rcarlsen/ShairPortMenu (NB: Requires Xcode to build…)

  4. Shamus Says:

    I’m running Ubuntu Server 10.04 and thought I’d give your instructions a whirl. Not sure if there are any other Ubuntu users out there, but I’ve run into a wall and cannot get any further (at least tonight).

    Following your instructions, I made the following changes for Ubuntu:
    1. /etc$ sudo vi airplay –> Ubuntu does not use conf.d
    2. /etc/init.d$ sudo vi airplay
    –> All start scripts in Ubuntu seem to require #!/bin/sh at the beginning
    –> change reference to /etc/squeezeboxserver
    3. /etc/init.d$ sudo update-rc.d airplay defaults

    Now, when I try: sudo service airplay start… nothing, no error messages, no results…

    Thoughts?

  5. Stuart Says:

    I did see your post on the Squeezebox forum, and I’ve been trying to find a working Ubuntu machine since ;)
    Please bear with me…

  6. Shamus Says:

    Fantastic… thanks! I used VirtualBox on OS X to create a VM–didn’t want to “play” on my production server.

    Please let me know if there is anything you want me to test… happy to help where I can!

  7. Krolli Says:

    Hey, something new for Ubuntu/Debian?

  8. Stuart Says:

    I’ve received reports that for people, like me, who are finding that iTunes connects to the AirPlay service but that iOS devices don’t, the counter-intuitive solution is to disable IPv6 support.

    Once I’ve tested this suggestion more thoroughly, I can add options to shairport.pl to allow IPv4 or IPv6 to be selected.

    It would be interesting to confirm whether this is necessary on IPv6-capable networks…

  9. kimc Says:

    If you have enabled passwords on your squeezeserver, shairport.pl need to send a login string first. “login username password”, else it will fail with some undefined variables.

    Also hairtunes only bind itself to udp6 socket, but the stream in my setup is coming on udp4 socket.

    I have tried changing the above and now I got data in my pipe. I still have trouble getting it to the squeezeserver. I assume the data in the pipe should be playable in mplayer?

    I tried using cat file
    ecasound … > file
    ecasound … | lame … file

    and I only get whitenoise if I try to play file with mplayer, Im not sure what I do wrong.

    Setup:
    Debian(ipv6 enabled) and iphone ios 4.3.1.

  10. lakidd Says:

    Hi kimc and stuart,
    On the whitenoise front I found that the signal to my squeezeboxes was being massively overdriven. I added -eadb:-40 (to reduce the gain by 40db) to the ecasound command line in custom-convert.conf and it fixed the problem
    Now if I could just get rid of my underruns and segfaults i’d be happy.
    lakidd

  11. Rakesh Says:

    Hi Stuart,

    I have been googling on and off ever since airplay was announced for this!

    However, I’m on OS X and don’t know how to get all this to work (what to compile, how to get waveinput working on squeezebox as it seems linux based).

    Any chance of some instructions for only minorly technical OS X types?

    Thanks

  12. Stuart Says:

    Hi Rakesh,

    The issue on OS X is that, probably due to wanting to keep iTunes locked-down, there’s no built-in way (that I’m aware of) to directly record audio streams in the way that the WaveInput plugin requires.

    However, there’s a Mac application named SoundFlower which will allow recording – so this is one option.

    Having said this, the method described above actually avoids the audio hardware entirely (as it was causing me problems) and should work on any POSIX-compliant system including OS X.

    If I get the chance to try out OS X then I’ll post further details – or feel free to have a go yourself, and please let me know how you get on or if you get stuck!

    Cheers,

    Stuart

  13. theseal Says:

    struggling w fedora, any takers??? I get the shairport.pl runnig but it is not visible on my devices… and also, I don’t get the sugested script running..

    stuck.com

  14. Stuart Says:

    theseal, this could potentially be one of two things:

    • shairport.pl isn’t running;
    • You’ve hit the possibly-IPv6 related problem.

    To diagnose the first problem, try “ps -ef | grep -E "perl|shairport"” and check that you do see shairport.pl running. If not, try “shairport.pl -v” to enable more verbose (error) messages.

    The second case I have no real answer to – a fairly common issue seems to be that iTunes will happily connect to the service and play audio, but iOS devices won’t even see that an AirPlay client is available. I’ve heard reports that completely disabling IPv6 resolves this problem, but I’ve had no success when removing all IPv6 addresses from all interfaces on the shairport.pl server – so this information may be wrong, or kernel support for IPv6 (or the IPv6 module?) may need to be removed.

    If you’re affected by the second case and do make any progress, please report back and let us know!

    Cheers,

    Stuart

  15. Robert Greenberg Says:

    Stuart,

    I’m sure the method above will work on OS-X, but what a previous commenter (and I and many others) would need is a version for ‘dummies’ – ie. Exactly what to do in more detail – what to enter into which programs, etc.

  16. David Schamis Says:

    Robert – well said.

    Staurt – I’m dying for this to be able to with in my OSX environment – a version for “dummies” on OSX would be fabulous!

    Thanks,

    David

  17. Isar Says:

    Stuart, I too would love to see a user friendly version of this :)

  18. Stuart Says:

    If anyone wants to stream to their Mac rather than to a Squeezebox, this just caught my eye:

    http://www.tuaw.com/2011/10/11/airserver-brings-airplay-streaming-support-to-lion/

    For everyone else, I am trying to get around to writing a Mac guide – but development on shairport has slowed and I’ve still not been able to work out definitively why iTunes will happily stream whilst iOS devices connect appear to be playing, without shairport receiving any data. This seems to be the issue to focus on – but I’ve not forgotten about everyone else!

  19. Scott Says:

    Any followup on the Ubuntu question? I’m exactly where Shamus was stuck before. :(

  20. Roscoe Says:

    Amazing work Stuart! Im very new to Linux and really could do with your help. I seemed to have got it nearly all working and feel like i must be missing something simple!

    Shairport is working fine, i.e output to speakers, it is also outputting fine to the pipe. its integrated with squeezebox as far as i get “Playing Airplay” on the Player when i send music, but just does not seem to bring the audio?? I am using Linux Mint and feel its around the Init.d script?

    Could this be it and if so what am i missing when trying to run it on Linux?
    As i said im new to linux and cant convert this script?

    Any Help from anyone would be amazing!! Cheers

  21. Toju Says:

    This looks great! Where are you with writing your mac guide?
    That would be really cool to have a slightly easier setup for the rest of us ;)

    Another option would be to run it on a NAS connected to the SB… Do you think it would be reasonable?

    Thanks

  22. Reto Says:

    Great work… any success so far in bringing this to a QNAP appliance?

    cheers
    reto

  23. Stuart Says:

    Ah – now this is interesting:

    http://www.engadget.com/2012/01/20/raspberry-pi-demos-model-b-computers-airplay-capabilities-vide/

    I shall have to take a look at the Raspberry Pi AirPlay client and see how it works…

  24. Stuart Says:

    Looks like this:

    http://code.google.com/p/airplay-nmt/

    … a package for Network Media Tank [networkedmediatank.com].

  25. Carl-Erik Says:

    Any news on a fix for IOS devices for the mysterious glitches that might or might not be related to ipv6?

  26. Stuart Says:

    Carl-Erik, yes!

    I recently pulled the newest source, and with the latest hairtunes binary AirPlay from iOS devices worked! It’s not perfect – there seem to be more frequent drop-outs/interruptions than when playing from iTunes – but it’s definite progress :)

  27. Spot Says:

    Any news on how to install under debian? I am stuck at the same place as the others.

  28. Spot Says:

    Bump!? Is this project dead?

  29. Gilbert Says:

    is it possible to get squeezebox server to stream to a airplay speaker ?

  30. Stuart Says:

    Spot I was going to say “No!” and provide much more information, but when I came to test my current setup I’m again not seeing connection events with the latest code :(

    So – it’s definitely not a dead project, but I need to find a free weekend to do some hacking and get things back on track.

    Stay tuned…

    Gilbert there is this (nice theme there, I notice ;) which uses an iOS device as a repeater to receive audio from SqueezeCenter and then relay it to an AirPlay-capable speaker natively?

  31. Gilbert Says:

    Hi Stuart, yes i’m using plugplayer now as a repeater, but would be nicer if it was possible to get airplay speakers just show in the squeezebox menu

  32. schmurtz Says:

    I use waveplugin + shairport with shairport4w to get airplay feature on my squeezebox wich work under windows. It work but it’s not very easy as real airplay…

  33. schmurtz Says:

    May be one day someone will make a new plugin with
    wave plugin
    http://code.google.com/p/bpaplugins/downloads/list
    and shairport4w
    http://sourceforge.net/projects/shairport4w/

    All the solutions are here, we just need a good developper ;)

  34. Edwin Says:

    I tried to configure this on my AMD Opensuse Linux server. I configured all files but all I get is a lot of static noise and lot of errors on the shairport daemon;

    late packet 0000 (1E2D:1E2F)

    late packet 0000 (1E2D:1E2F)

    late packet 0000 (1E2D:1E2F)

    late packet 0000 (1E2D:1E2F)

    late packet 0000 (1E2D:1E2F)

    late packet 0000 (1E2D:1E2F)

    late packet 0000 (1E2D:1E2F)

    late packet 0000 (1E2D:1E2F)
    requesting resend on 1 packets (port 54586)
    requesting resend on 1 packets (port 54586)

    etc.

    Can you please help were to look? I start the daemon by hand as the start scripts do not work for OpenSuse;

    perl /usr/local/bin/shairport.pl -a “Squeezebox Airplay” -mac “xx:xx:xx:xx:xx:xx” -w /var/run/airplay.pid –squeezebox –pipe=/var/lib/squeezeboxserver/airplay-fifo.raw

  35. Stuart Says:

    Edwin, that actually looks as if it’s (more or less) working as intended!

    It’s normal for the dæmon to be fairly noisy, and warn verbosely about missed, early, or late packets, as audio-streaming over wifi is a somewhat inexact science…

    Do you hear anything?

    (Top tip – you can run xxd on the socket rather than connecting the WaveInput plugin, and see if it moves…)

  36. Edwin Says:

    Stuart,

    Thanks for your reply. When I try xxd /var/lib/squeezeboxserver/airplay-fifo.raw it gives a lot of output. When I catch the output from the pipe to a wave.pcm file;

    cat /var/lib/squeezeboxserver/airplay-fifo.raw > wave.pcm

    and open it with a sound editor like Audition I get music! So somehow the WaveInput filter does not seem to work. Any tips?

  37. Edwin Says:

    By the way I only hear a lot of static noise…

  38. Edwin Says:

    Hmmm:

    ecasound -q -z:db -b:4096 -f:16,2,44100 -i:/var/lib/squeezeboxserver/airplay-fifo.raw -o stdout | flac -cs –totally-silent –endian=little –channels=2 –sign=signed –bps=16 –sample-rate=44100 –compression-level-0 – > /s/c.flac

    seems to give a good working flac, however no good music (noise) through my squeezebox server… strange!

  39. Edwin Says:

    This part does not work on a Squeezebox Touch:

    print “Showing message… ” if $verbose;
    print $socket “$mac show line2%3AStarting%20AirPlay duration%3A5 brightness%3ApowerOn font%3Ahuge\n”;
    $response = ;
    print “$response\n” if $verbose;

  40. Edwin Says:

    It is working although a bit unstable. Sometimes the music just stops. The last part was wrong rights on the /var/lib/squeezeboxserver/airplay-fifo.raw pipe. When I changed the uid of the pipe to squeezeboxserver it seem to work.

    I also changed the custom-convert.conf as your version does not seemed to have the right tab indentation when you copy and paste it. All the ‘paragraphs’ need to be tabbed-in.

    Many thanks!

  41. Luke Stepniowski Says:

    I’m close to having this working but it looks like my setup is failing with something related to the WaveInput plugin configuration. I’m clearly writing audio to the named piped as evidence by “xxd”. I’d appreciate a second set of eyes to look over my configuration.

    Logitech Media Server Version: 7.7.2 – r33893
    Operating system: Debian – EN – utf8 (Linux data 2.6.32-41-server #88-Ubuntu SMP Thu Mar 29 14:32:47 UTC 2012 x86_64 GNU/Linux)
    Platform Architecture: x86_64-linux
    Perl Version: 5.10.1 – x86_64-linux-gnu-thread-multi
    Database Version: DBD::SQLite 1.34_01 (sqlite 3.7.7.1)
    WaveInput (v1.04)

    Full DEBUG level output: http://majjix.com/~lstepnio/server.log
    Slim::Player::TranscodingHelper::getConvertCommand2 (425) Error: Didn’t find any command matches for type: wavin

    custom-convert.conf: http://majjix.com/~lstepnio/custom-convert.conf

    prw-rw-rw- 1 squeezeboxserver nogroup 0 2012-05-12 21:11 /var/lib/squeezeboxserver/airplay-fifo.raw

    I appreciate any pointers. :)

  42. atca Says:

    Thanks Stuart my Ubuntu success with Shairport and a Squeezebox touch based on your post is here http://confoundedtech.blogspot.co.uk/2012/08/airplay-to-squeezebox-touch-via-linux.html

  43. Basejump Says:

    Hi,
    I’m another Mac based user, I would very much like to use Airtunes to send music (& other stuff) to my Squeezeboxes (3rd Gen)
    I’m using an iMac for both iTunes and Squeezeserver 7.7 with 4x Sq.Box v3 x4, and SqRadio and SqBoom…
    Any news on the Mac instructions …?
    Thanks for all the hard work by the clever ones!
    BJ

  44. atca Says:

    The Airplay favourite doesn’t automatically play for me on the Squeezebox when using the -s option any idea as to why or how to debug?

  45. M. M. Says:

    I guess your start-stop-daemon doesn’t work because the usage of the exec argument. It “Check for processes that are instances of this executable” [1], but your process isn’t your script but the perl interpreter.

    [1] http://man.cx/start-stop-daemon(8)/

  46. Tom Says:

    Hello,
    I installed everything and my squeezebox and itunes seem to communicate just fine. But I do not get any audio on my squeezebox. Here is the last output I get from shairport after playing some music in iTunes:

    Found favourite 'wavin:default' with ID '14' at position 14.
    Turning on player (if off)... 00:04:20:2b:f1:22 power 1
    
    Stopping player (if playing)... 00:04:20:2b:f1:22 stop
    
    Unmuting player (if muted)... 00:04:20:2b:f1:22 mixer muting 0
    
    Audio Streamb4FUkTjwwLNZeKsgroWUVwREQ: SETUP
    launched decoder: 789 on port: 6000
    REQ: RECORD
    REQ: SET_PARAMETER
    REQ: SET_PARAMETER
    
  47. ppccrazy Says:

    Can this whole setup be made on a raspberry pi, to run Squeezebox server and shairport and the other steps, will it be capable enough to handle this setup?

  48. Stuart Says:

    ppccrazy: I plan on testing this very soon, actually – my pi-Tower cluster is almost ready to go (I’ll be writing an article about it at some point…)

    Without having tried it, I’d expect that any pi would be more than capable of running Squeezebox Server & shAirport – you’ll likely want your media to be remotely-mounted for capacity reasons so, in combination with the Pi’s slow MMC, database updates won’t be all that fast. Streaming should be fine, trans-coding potentially less-so – the real problem may turn out to be the Pi’s dodgy USB implementation. Whilst this is still improving, sustained high-bandwidth transfers may sometimes be asking too much of it…

  49. ppccrazy Says:

    I just want to use this to send airplay output to my 2 squeezeboxes thru the squeezebox server, can that be handled. which os I should loas on the pi to make this setup simple. I am a noob when it comes to anything on the linux side of the house.

  50. ppccrazy Says:

    Hi, I have done this whole installation on a Pi, with Squeezeplug, everything is working, but I hardly get any audio its mostly hiss, any suggestions?

  51. schmurtz Says:

    Hi, I’ve finaly made something equivalent for Windows Squeezebox server. You can find it here :
    http://forums.slimdevices.com/showthread.php?100048

Leave a Reply

%d bloggers like this: