Sonntag, 5. Januar 2014

Synology NAS as an Airplay Receiver

by on Sonntag, 5. Januar 2014 19:35

The Synology DSM already provides quite some fancy ways to stream music (and even video) *FROM* the Synology NAS via Airplay to Airplay Receivers e.g. Apple-TV, etc. (see: Synology's Blogpost on Airplay).

However: unfortunately I could not find any out-of-the-box-solution or a (neither official nor un-official) package to use the Synology NAS as an Airplay-Receiver to stream music *TO* the NAS (...and play back via an USB soundcard).

All I could find were some horribly complicated instructions on how to compile that stuff on your own and eventually get it working. I have to mention and thank...

...for providing me some guidance. Since those posts are about 1-2 years old now, I guess newer packages made it a lot easier for me. In contrast to their approaches, I could now use...
  • a C-only fork of shairport (unmodified ;-))
  • ALSA instead of OSS for sound output (way less hassle)

Prerequisites

My setup is as follows:

  • Synology DS1512+ (Intel Atom thingy) with DSM 4.3-3776. Should work with others as well - not sure regarding ARM/PPC/etc... (feedback welcome)
  • Audiolab M-DAC (A.10 firmware) as USB soundcard. Again: should work with others as well - however: you might want to check Synology's Compatibility List.

Software-sides:

  • Apple-Bonjour enabled
  • SSH-Login to that Synology
  • A working IPKG (Hint: this link)

What do I have to do?

1. fetch needed IPKG packages:

> ipkg install pkgconfig gcc make openssl openssl-dev alsa-lib

2. fetch shairport
> wget "https://github.com/abrasive/shairport/archive/master.zip"
> unzip master.zip
> cd shairport-master

3. compile shairport
> ./configure
> CC=gcc make

4. Configure ALSA to allow playback for your user (by default not even root is allowed):
> echo "defaults.pcm.ipc_gid    \"root\"" > ~/.asoundrc

5. Launch shairport into backgound
> LD_LIBRARY_PATH=/opt/lib ./shairport -p 5005 -a "Synology" &
Default Airplay port is 5000, which is also the alternative port of the Synology DSM. Can be changed using "-p" in shairport. "-a" specifies the name which will appear in Airplay.

Et voilà! Go to iTunes an try to use that new Airplay target.

Conculsion

Still a bit complicated to start and stop, but surprisingly this worked quite stable for the last hours now... ;-)

Next up: how do I compile a Synology Package... ;-)

comments. 24 tags. , , ,

Hi Losty,

Very useful post indeed.

I followed carefully those steps, and faced the following:

1) I had first an unexpected compilation issue related to broken pthreads library, that I solved right away thanks to this post: http://forum.synology.com/enu/viewtopic.php?f=90&t=30132

2) Then I was able to launch shairport, and was able to "see" it from several Apple devices (iPad, iPhone) ;-)

3) But when I tried playing anything (from any iPad app) on the NAS shairport, the app seams to be starting streaming, ... and then stops (approx after 1 sec).
Without any explaination on iPad side or shairport side :-(

Any idea about this ?
Is there a way of activating logs in shairport to debug this?

Thanks,
Pierre.

Just to mention:

NAS model: DS211j (Marvell Kirkwood mv6281 1.2Ghz ARM)
sound card: SOUND BLASTER X-FI GO! PRO (works perfectly with DS audio and Audio Station)

... when I start streaming from the iPad to the NAS shairport, I don't hear anything (it doesn't start). The iPad sees the NAS, but it looks like the sreaming connection fails.

Hi Pierre,

shairport should output some warnings by default. Don't you see *any* output from shairport?

As you say you can already *see* that AirPlay device, but not start playback - that indeed points towards problems with the soundcard or alsa-lib. Can't tell you anything about that Soundblaster thingy, but when DS Audio works with it, that's already a good sign. Probably alsa-lib has problems. Did you perform Step #4 (alsa configuration)? However - I always got an error message from shairport when having alsa misconfigured.

Another "known issue": given your DS211j - I'm not sure, but that model might have some old version of "avahi-daemon" running. In that case you might need to install and start a newer one, as http://blog.elsdoerfer.name/2011/05/15/shairport-on-synology-nas/ did. However: I was under the impression, this is only used for discovery. As you said you can see the Airplay device thats probably not your problem. But I don't know whats wrong with that old version. My system came with a sufficient one...

Please let you know if some of this helped...

Good luck & Cheers,
Losty

Fantastic! Is there a package on the way or already out there? Or is this the best and simplest way to do it? Is it easy to remove if one wants?

I've started and now I'm stuck, when trying to get shairport with
>wget "https://github.com/abrasive/shairport/archive/master.zip"
I get the following response
https://github.com/abrasive/shairport/archive/master.zip: HTTPS support not compiled in.

Tried with http:// but it redirects to https, is there a way around this? Also tried to enable https service in DSM but with no result.

Hi Aksel,

that means the version of wget has no SSL support. I don't know why this is. Are you running that command on the diskstation? Synology might have packed very slimed down versions of those kind of tools. You can try downloading the master.zip locally - even with your regular webbrower - you just have to put it into the directory you're working in on the diskstation.

Regarding the Package. Well... I filed a pull request to SynoCommunity https://github.com/SynoCommunity/spksrc/pull/848 , but not much happening there lately... ;-/

What kind of diskstation do you have?

...and, yes - both, package and self-compiled version are very easy to remove...

Ive tried to get this working now for quite some time but i'm not that good in the terminal so i will add some code to troubleshoot (if you have time), I think everything is right up to the point where I'm about to compile Shairport (didn't know where to put the zip so i put it in the optware folder, wrong?);
Link to the code; http://txs.io/5rob

Thanks!

This sounds like a great project but unfortunately I run into the same problem as Aksel above does. The Shairport.sh is not compiled so I cannot launch it. Any ideas about that? Thanks for helping!
Karsten

Hi all,

here are some pre-compiled spk packages: http://home.losty.ch/webfilebrowser/share/shairport-goes-diskstation?key=d97c1ef3 ... just send me some kind of message, if you need an additional architecture and I'll ask the mighty-mighty cross-compiler.

As already mentioned, the pull request for syno-community is already open: https://github.com/SynoCommunity/spksrc/pull/848 - unfortunately not much progress there...

I've also compiled a list of "confirmed workings" over here: https://www.evernote.com/shard/s198/sh/598561fd-5bed-4546-94b9-d2e3ed07fca6/7d2c3d24c2863824ceacfc871fad1091 ... looking forward to more reports... ;-)

Cheers,
Losty

Einar Olason said on 10. Dezember 2014 um 19:30

Hi Losty,

May I be so bold as to ask for a package for my DS 214 SE? Output from uname -a is

Linux Roberts 3.2.40 #5004 Sat Nov 29 01:34:41 CST 2014 armv7l GNU/Linux synology_armada370_214se

Cheers,

Einar

You're welcome...

http://home.losty.ch/webfilebrowser/share/shairport-goes-diskstation?key=d97c1ef3 -> shairport_armada370_1.1.1-1.spk

...does it work?

Cheers,
Jochen

I am also running into the issue where iTunes/iPhone connects for a second or two and then errors out without anything showing in the output of shairport. I'm using a Synology DS410 PPC. Was anyone able to fix the issue? Thanks

Anonym, are you using the pre-compiled packages? Had that issue to but since using the pre comp packages and the last update it works fine.

No, I compiled it because I cannot find a pre-compiled version for my synology DS410. Thanks

I'm afraid there's something wrong with the latest shairport nightly. When I first compiled a package, shairport did not have a release ready, so I used just latest for V 1.0-1 of my package. Had a couple of complaints lately. With V 1.1.1-1 I fixed shairport from latest to V 1.1.1. Seems as this solved the problem.

Anyways: DS 410 should be ppc8533. Try http://home.losty.ch/webfilebrowser/share/shairport-goes-diskstation?key=d97c1ef3 -> shairport_ppc853x_1.1.1-1.spk

Is it working?

Einar Olason said on 16. Dezember 2014 um 16:56

Hi Losty,

That was quick! And it works like a charm, starts automatically and is stable so far. Also, the spousal acceptance factor is very high! :^)

Thanks a lot!

Einar

Einar Olason said on 18. Dezember 2014 um 18:08

Hi Losty

Spoke too soon - kind of :^/ I updated my Diskstation last night and now the shareport connection fails and iTunes says there was a network problem. When I log on to the Diskstation Shareport is labelled as "stopped" and I can restart it - but iTunes still cannot connect.

Does this sound familiar to anyone here? Is there a known solution?

Cheers,

Einar

Start and stop Audio Station, it will initialize som necessary parts for the audio. But if it starts with automatically i don't know. You might get som info here: https://github.com/SynoCommunity/spksrc/pull/848

Einar Olason said on 19. Dezember 2014 um 17:27

Hi Aksel,

Thanks for the tip. I'd taken this a step further and un-installed Audio Station (don't need that now I have this fancy Shareport-thing!). Now that I've re-installed it everything works flawlessly again.

Cheers,

Einar

Sorry for the delay. As Aksel already said - the Audio is obviously initialized not at system boot, but by Audio Station. Therefor Audio Station needs to be running. I wanted to include a own audio initialization when I find some time. Hopefully I'm then able to apply certain different setting like sample rate, etc...

Great thread, any thoughts about outputting the received audio back to connected airplay devices?


I've been looking around for a decent and cost effective multi-room solution for my various Airplay devices. As I don't want to go for a specific brand (Like Sonos). I started to look for a solution that would allow me to connect my source (Ipad, Iphone, Computer) to an Airplay "Bridge" or "relay" that would then connect to all my other receives. That way I can easily stream same audio in all rooms.

Audio Station has this feature when it comes to locally stored audio. However it doesn't accept to receive an external source and relay it to the other receivers.

Would it be possible for the Audio Station or DSM to become an Airplay relay?

Let me know your thoughts

Hm... sorry, not quite sure what you mean. I only maintain the compiling and packing of Shairport for Synology boxes. Details around the Airplay protocol are handled by Shairport itself ( https://github.com/abrasive/shairport ). If you manage to present a "bridge" (...to whatever) as a soundcard to the Synology, this package might be used accept Airplay connections from the network and forward them to that virtual soundcard. Some settings regarding the choice of the soundcard etc. can be passed to shairport. BTW: Personally, I use Porthole ( http://www.getporthole.com/ ) to play back to multiple speakers. It has some natural limitations (especially in remote controlling) but works quite good and has very enthusiastic developers, so that I definitely can recommend it. BTW: Porthole uses Soundflower ( http://rogueamoeba.com/freebies/soundflower/ ), which itself might already be very helpful in relaying or bridging audiostreams. Hope that helps!

Hi Losty, is your Shairport thing still working? I have a DS216j and would love to use its USB DAC for airplay.
Pleasel et me know,ThanksThomas

Pretty perverted way to enjoy music ;) Nevertheless, thanks for the guide!

twitter.

flickr.