[Apple TV] HOW-TO install audio streaming server on Ubuntu running on ATV
#1
I've recently had success in getting Airfoil http://www.rogueamoeba.com/airfoil/ running as a streaming audio server on the Apple TV running Sam's oldest image that I've since upgraded.

What's Airfoil?

Airfoil is an application that allows you to hijack your audio out on a computer and feed that audio stream to a remote set of speakers, say those that are connected to the Apple TV. What it does is hi-jack AirTunes, which is an Apple protocol for audio streaming.


Sample use case:

Capture browser audio from music streaming site and send to high-fidelity speakers connected to Apple TV.


How to:

I will assume you know how to FTP into your box, and have basic understanding of the command line and how to get access to it via terminal interface.

You will need the following:
Airfoil for linux .deb: http://rogueamoeba.com/airfoil/download/...ux.all.deb
A collection of Airfoil dll's: http://kevin.colyar.net/wp-content/uploa...l-DLLs.zip
"run_airfoilspeakers" script from this package http://rogueamoeba.com/airfoil/download/...sLinux.tgz
Badgerports repository http://badgerports.org/hardy.html

Great, now that you have the prerequisites, this is how to put it all together.

(1) Copy AirfoilSpeakersLinux.all.deb, run_AirfoilSpeakers (you'll have to find it buried inside the .tgz file) to the Apple TV via sftp or other method to /home/xbmc/

(2) Configure badgerports if you haven't done so already. When you're done be sure to enter:
Code:
sudo apt-get update

(3) We need to upgrade mono to version 2.0 because some of the packages allow for .NET windows development, this is why we needed badgerports. To upgrade mono, enter the following:
Code:
sudo apt-get install cli-common monodevelop

(4) We'll need to install avahi-daemon now, since that is a prerequisite for AirfoilSpeakers. To install, type:
Code:
sudo apt-get install avahi-daemon libavahi1.0-cil

(5) Now we're ready to install AirfoilSpeakers! To do so, navigate to the folder that you currently have your AirfoilSpeakersLinux.all.deb in (I suggested /home/xbmc/ earlier) and run this code:
Code:
sudo dpkg -i AirfoilSpeakersLinux.all.deb

(6) Launch an (s)FTP client and connect to the Apple TV and copy the four .dll's that you acquired earlier (you'll have to unzip them first) and place them in /usr/lib/airfoilspeakers/. You should overwrite one or two files, but that's OK.

(7) We're almost done! Now go back to the folder you have the run_airfoilspeakers in. We'll have to change some configuration now specifically for Ubuntu. Enter the following code to enter a text editor:
Code:
sudo nano run_airfoilspeakers
Change the path variable to =/usr, so you should be replacing "./" with "usr". (thanks @Wikking for the correction)

(8) At this point we're ready to unleash the magnificence of streaming audio. To run airfoil in headless mode, enter the following code while still in the directory that "run_airfoilspeakers" is in.
Code:
./run_airfoilspeakers --gui=false

I also did the following to ensure there were no permission problems:
Code:
sudo chmod 777 run_airfoilspeakers
sudo chown root:root run_airfoilspeakers

To make it run at startup without having to manually run the script enter the following:
Code:
sudo cp run_airfoilspeakers /etc/init.d
sudo chmod +x /etc/init.d/run_airfoilspeakers
sudo update-rc.d run_airfoilspeakers defaults 98 02

There you have it, it's now live and ready for you to connect to. Go on your laptop or desktop, acquire a copy of Airfoil for Windows/Mac (Warning: paid application, but free to try) and connect to the apple TV. It will appear as a penguin. You might have to try a couple different browsers to find one that works, but who knows, you might get lucky on the first try.

Cheers,
J
Reply
#2
Hi Spacecraft,

i've been following this forum for a while.
But i had never created an account until now. I did it tonight for only one reason : to thank you for your useful step by step tutorial.
I was trying to figure out how to install Airfoil on my AppleTV running Pin's image for a few days (since i had the idea to do it).
And thanks to your post, i succeeded in doing it in less than i could expect.
You're the man !

Cheers

Esseki
Reply
#3
No worries, glad this post helped someone!
J
Reply
#4
Hi Spacecraft,

thank you a lot for sharing this. I tried installing airfoil following your tutorial. However i screwed up because I was so excited and thus to stupid to read slowly.

So I did "sudo apt-get install cli-common monodevelop" without updating the repository. It all went well until I had to install AirfoilSpeakersLinux.all.deb (which by the way i copied to /home/atv because in Sam's latest image that's the home directory and /home/xbmc does not exist...so I guessed this would be OK...was I wrong?).
However...while installing the Package I got an error saying
Code:
airfoilspeakers: Depends: libavahi1.0-cil but it is not going to be installed
So i installed it via apt-get and then the install went through. But wen i run ./run_airfoilspeakers --gui=false I get this
Code:
** (usr/lib/airfoilspeakers/AirfoilSpeakers.exe:5707): CRITICAL **: _wapi_shm_file_open: shared file [/home/atv/.wapi/shared_data-atv-Linux-i686-312-11-0] open error: No such file or directory

** (usr/lib/airfoilspeakers/AirfoilSpeakers.exe:5707): CRITICAL **: _wapi_shm_attach: shared file [/home/atv/.wapi/shared_data-atv-Linux-i686-312-11-0] open error
**
** ERROR:(shared.c:346):shm_semaphores_init: assertion failed: (tmp_shared != NULL)

** (usr/lib/airfoilspeakers/AirfoilSpeakers.exe:5707): WARNING **: Thread (nil) may have been prematurely finalized
Stacktrace:


** (usr/lib/airfoilspeakers/AirfoilSpeakers.exe:5707): WARNING **: Thread (nil) may have been prematurely finalized

** (usr/lib/airfoilspeakers/AirfoilSpeakers.exe:5707): WARNING **: Thread (nil) may have been prematurely finalized

Native stacktrace:

        /usr/bin/mono [0x816b20a]
        [0xb77d6440]
        /lib/tls/i686/cmov/libc.so.6(abort+0x101) [0xb75a8a01]
        /usr/lib/libglib-2.0.so.0(g_assertion_message+0x121) [0xb7768681]
        /usr/lib/libglib-2.0.so.0 [0xb7768bdd]
        /usr/bin/mono [0x811703e]
        /usr/bin/mono [0x8109342]
        /usr/bin/mono(mono_once+0x96) [0x8112726]
        /usr/bin/mono [0x810907c]
        /usr/bin/mono [0x8115f6e]
        /usr/bin/mono [0x8116364]
        /usr/bin/mono [0x80d1877]
        /usr/bin/mono(mono_runtime_init+0x26) [0x80d8836]
        /usr/bin/mono [0x8134545]
        /usr/bin/mono(mono_main+0x3aa) [0x805a9da]
        /usr/bin/mono [0x805a122]
        /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0) [0xb7592450]
        /usr/bin/mono [0x805a091]

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

My guess is that this is related to a false path...it's trying to access /home/atv/.wapi/* but the correct path for my system is /root/.wapi/* which by the way also counts for xbmc which is located under /root/.xbmc/*. I guess that's why you said "copy the files to /home/xbmc/ but reinstalling the package from /root/.xbmc/ did not resolve the problem and the wrong path stays unchanged.
Do you or anyone got an idea what i could do the resolve this?
Regards.
Reply
#5
Hi Wikking,

You'll have to bring me up to speed on your environment under Sam's image in order for me to help you.

What version of ubuntu?

Additionally, I have the following questions for you. Were you able to add the badgerports repository? That is crucial as it will add the necessary backports of mono 2.0 for Hardy.
Reply
#6
Hi Spacecraft,

thanks for the immediate reply!

info states this:
Code:
System Information:
No LSB modules are available.
OS: Distributor ID: Ubuntu Description: Ubuntu 8.04.4 LTS Release: 8.04 Codename: hardy
Kernel: 2.6.24-28-generic

And yes I was able to add the repository but didn't update first. So these two
Code:
sudo apt-get install cli-common monodevelop
sudo apt-get install avahi-daemon
went through without using the badgerports repository. I then uninstalled those (after getting the error from airfoil ) and reinstalled with the repository updated but nothing changed. What really confuses me is the wrong path that the log is showing. Hope that helps. And thanks again!
Reply
#7
still in need of help here...would be great using the atv with airfoilspeakers!
Reply
#8
OK i have it running now! With a fresh install and a small midification (using "/usr" in step 7) I am now able to start run_airfoilspeakers.

However when I connect to the airfoilspeakers on the ATV and streaming sound I am not hearing anything! Do I have to configure something? I am using HDMI for video/sound.

Any suggestions?
Reply
#9
Great news!

I can't really help you there, since I have a different setup and it just seemed to work. Here are a couple of good places to look though. Also, if you could describe in a little more detail how you got your system to work, I'll edit my guide above so that the next person will have less headache. At any rate, mono is running to show which should use your default audio device defined in ALSA. Look into amixer, aplay and ./asourndrc for more information on alsa configuration. I know that HDMI audio on the ATV running linux was trouble for some. Using "aplay", you'll be able to see if your default audio device is the HDMI output, in which case you can contain the problem to mono and/or airfoilspeakers. I suspect it's ALSA, so best of luck running that one to ground.
Reply
#10
Update:

I figured it out. The sound is being output through the component audio output (L/R Audio) and not via HDMI (so it's working). At the moment I have no idea how to switch the default output. Guess I have to do some reading when I got some time on my hands.

As for the small modifications:

before step 5: sudo apt-get install libavahi1.0-cil

modification of step 7: Change the path variable to be =/usr, so you should be replacing "./" with "/usr". (else it would give me a path not found error)


@spacecraft: btw...which audio-output do you use?

Edit: OK...while playing with alsamixer and alsactl I now lost all audio on my testing-usb-stick (i think that this --> "sudo alsactl store 0" broke it). All the configs were set for sound over HDMI but I only got airfoilspeakers to play via analog.

@spacecraft: do you mind sharing your config? (.asoundrc, aplay -l output and if you got /etc/asound.conf..because if have not! And if yes its contents) TIA

OH...and just one more question: when you stream something to the ATV does this interfere with sound from xbmc? I mean is both being output on the same device (for example the optical output)?

EDIT2: Now that XBMC doesn't have sound anymore and will crash as soon as I play anything, I got airfoilspeakers playing via HDMI (maybe becaouse i reset also through alsa-utils)...am seriously thinking about biting my own hands off!
Reply
#11
If xbmc is crashing as soon as you play anything, then it's a problem with ALSA. If you are still having trouble getting XBMC to play audio, then post your .asoundrc file here. It sounds like you have success with airfoil over HDMI, and I'm guessing that's your objective. You cannot play airfoil and use xbmc to play audio at the same time. The device will be "busy" when either is using it, so it will appear as unavailable to the other.

It should look like this http://alsa.opensrc.org/.asoundrc
Reply

Logout Mark Read Team Forum Stats Members Help
[Apple TV] HOW-TO install audio streaming server on Ubuntu running on ATV0