Saturday, May 26, 2012

Running SqueezeSlave on Raspberry Pi

- Running SqueezeSlave on Raspberry Pi

Getting Squeezeslave to run on the RPi is very easy - here is a revised version of the instructions that I posted on the Raspberry PI forum.NOTE: This has been tested on Debian Squeeze (and I think it also works on Wheezy) - but will almost certainly need some updated to work on hard-float builds such as Raspbian and has been updated since first published to include instructions for Raspbian Wheezy (the hardfloat version of Debian that is endorsed by Raspberry Pi Foundation).Version numbers shown here were correct when this blog was written but it is possible that newer versions have been released since then ... and they might work better (or worse) so check on Sourceforge (for official release) and GoogleCode (for latest test versions).

Most of what is shown below could be copied to a script and run - but there is no error checking so it is best to run as individual commands - e.g. copy / paste into SSH session

NOTE: Some of the lines below are very long and get wrapped when presented in the blog.
I have left a blank line after those long lines to make it clearer. If you are using copy/paste to replay the commands then make sure that you take the full line and unwrap it if needed.

Start an interactive login to the Raspberry Pi then ...

mkdir squeezeslavesrc

cd squeezeslavesrc# If on Debian (not Raspbian) then perform the next 2 commands

# at this point you have the various binaries for ARM/Linux so no need to build from source

# and you now have enough to run squeezeslave

# however, by downloading some more files you can make it easier to start/stop squeezeslave

# to test what you already have - assuming you are already running LMS somewhere on the same LAN

# type

./squeezeslave -L

# if this lists audio device(s) then things will probably work for you

# if there are none then try (note - this should not be necessary on Raspbian)

sudo modprobe snd-bcm2835

# and then

./squeezeslave -L

# to run it as a player ...

./squeezeslave -D -F

# to quit from that display mode hit the "q" key

# remember - if you are doing this via SSH from a different room then

# you will only hear something if you are at the device (e.g. the speakers on your TV!)

# If it acts like it is playing something but you cannot hear it then it might be that the sound on the Raspberry PI is set too low (in ALSA).# In that case - quit (q) Squeezeslave and runsudo alsamixerthen boost the sound by pressing the up arrow key (and the "esc" key to exit and then try running Squeezeslave again

# assuming all was OK from above - then you can do more to automate the startup

# the backslashes above are needed to make the quotation marks go into the file

# if you look at the file afterwards it should look like this

# SBSHOST="-F"

# if you needed to run the modprobe to get sound working then also do this

echo "modprobe snd-bcm2835" >> defaultsqueezeslave

# then copy the file over to become the default configuration for SqueezeSlave

# Done this way because trying to use sudo to echo direct to /etc/default does not work on some builds

sudo cp defaultsqueezeslave /etc/default/squeezeslave

# then to start it ...

sudo /etc/init.d/squeezeslave start

# and to stop it (for example if something else is trying to use the audio port and sharing not working)

sudo /etc/init.d/squeezeslave stop

# it should start automatically on the next reboot of your Raspberry Pi

Here is a short video showing the result ... to be honest there is not much to see because it SqueezeSlave is running in the background. However, it does show how quickly the Raspberry Pi reboots.

I also had this synchronising with a couple of real Squeezeboxes. It needed some tweaks to the timing offsets in LMS to get it to be closely in sync.

If you plan to add more SqueezeSlave devices to your set-up then you will need to change the fake MAC address that SqueezeSlave uses. It defaults to 00:00:00:00:00:01

I will probably update the default to set the SqueezeSlave MAC address to be the real MAC address of the Raspberry Pi (which in turn is usually derived from the serial number of the device).

If you did download and unpack the source - then it is also possible to build your own copy of SqueezeSlave. I did this as well and it worked - but you have to build the "contribs" as well to get the ARM version. I might update this blog entry with how to do it if there is some interest.

Remember, though, if you are on Raspbian then start from a software release that is known to work on hard-float (armhf).

September 2012 - updated with some extra information for Raspbian users

Yes - I did add it to /etc/modules later - in fact I made the same suggestion to the author of the Xsqueeze plug-inhttp://forum.xbmc.org/showthread.php?tid=122199&pid=1138160#pid1138160

As for why the audio is still going through HDMI ... it has priority if you have HDMI connected.I suspect that you can run alsamixer (sudo alsamixer) to change the default to be the analogue output ... or reboot the RPi without the HDMI connected or force it withsudo amixer cset numid=3 1(to set it back to "auto" change the 1 at the end to 0)

Despite updating firmware, I still get breaks in the sound when playing on analogue ... which I think corresponds with long SD card activity ... so I plan to find a way to reduce that or increase sound buffer size.

I worked through the commands - which initially allowed me to run squeezeslave - however since rebooting I get the no output device found error. - I checked with OMXPlayer and the audio seems to be fine. Any thoughts ?

I see a suggestion elsewhere ( http://forum.xbmc.org/showthread.php?pid=1157721 ) that this might be a result of contention for the audio port.Could there be any other sound programs running?(eg another copy of SqueezeSlave already running in background - auto-started after a reboot)sudo ps -ef | more(space for next page or q to quit)

I've got squeezeslave now working, but I had also to go through this tutorial http://elinux.org/R-Pi_Troubleshooting#Sound because I couldn't have sound through the headphones output (even when the RPi was boot without an HDMI plug in)

OK, I allready got this working with the on board audio plug, but now I also got it working with an USB audio card. But it took me a while to figure it out.

The problem was I had to tell squeezeslave which audio device to use.

For those who are also struggling with this:

Execute this command to list the audio devices:./squeezeslave -LThe device with the star in front is the one that is used. In my case it was the default. Which wasn't good because it should have been audio device number zero: 0: (ALSA) C-Media USB Headphone Set: USB Audio (hw:0,0) (11/46)

To tell squeezeslave to use the correct one do the following:

sudo nano /etc/init.d/squeezeslave

find this line:SSOPTIONS=And add "-o" In my case it was device number zero, so mine looked like:SSOPTIONS=-o0

I've not tried this but assuming that you can forward ports at your router when the LMS is running then it should be possible.See this old post by Mark Vardy (I assume that is his name based on site URLhttp://techblog.vardyfamily.co.uk/2010/01/using-squeezebox-server-remotely.html?m=1

Hello Simon.You could try leaving "top" running to see if there is a slow memory leak in one of the components that makes is slowly crawl to a halt.Another alternative, if you don't need the basic interactive capability of SqueezeSlave, would be to run Troide's SqueezeLite instead. There is now a HF version.

Hey Simon,I'm not experiencing this issue. I've tried to reproduce it and haven't been able to. Mine will pause for days on a local played file. I wouldn't expect this to work on a live streamed station however.

I use the -R switch to allow it to retry connecting to the LMS if it looses track of it. You might try that. It is also important if you want to run headless and just boot into squeezeslave from startup. I find that the rc.local script starts up squeezeslave before the network as finished optaining an IP address, and fails the first few times. The -R fixes that. You might try this as well.

I am using LMS version 7.7.0 which I believe is one version back from the latest. You might experiment with the -k switch which is a keepalive value. It normally isn't needed for server versions over 6.5.x and defaults to 10 I believe in that case. But is required for servers below that value.

I would also say check the system log to see if you are getting USB disconnections/resets. Run the dmesg command to see the boot and system log. I don't have a keyboard on my squeezeslave Pi now, but when I did, I saw a LOT of USB resets going on and it was due to my keyboard being a USB ver 1.1 and my external sound card being at USB ver 2.0. I had them on the same powered hub, which was connected to one of the Pi's USB ports.

I found that if I moved the keyboard to the other USB port on the Pi, the USB reset messages went away. I noticed it because it made the mouse clicks get missed in X as well.

Now I only have the external sound card directly connected to the Pi, with no other devices. Since the built-in ethernet adapter is actually connected via the USB buss in the Pi, I could see a reason to believe network disconnects could be occurring on your situation.

I will look further into your suggestions but my guess right now is that it got be something network related because when the pi isn't connected anymore after a couple of hours to LMS I can't connect via ssh as well, but If I do try to connect a second time via ssh pi is up again and as well again connected to the LMS.

I have not tried Openelec for a long time but my recollection is that the Linux environment is more constrained so it might not be as easy.However - XSqueeze (XBMC add-on) might work.Also, Squeezelite has been making great advances and might well run in environments that defeat SqueezeSlave.

I'd say I'm a basic/medium user of Linux and I'm trying to install squeezeslave on a model B raspberry pi (bought the other day) I have installed squeezeslave and can successfully run using the ./squeezeslave -D -F command (with music output, so I know it functions correctly) but all attempts to run at start up have failed.

I have tried on the Raspbian (2013-05-25) and the Soft-float Debian (2013-05-29) OS' using the squeezeslave-1.2.311 and squeezeslave-1.3.393 versions.

Everytime I attempt to start from boot or manually using the command 'sudo /etc/init.d/squeezeslave start' I get the following error message /etc/init.d/squeezeslave: 49: .: 3: Too many open files

Any ideas people as this is most annoying :o( I'd like to setup a couple extra of these for the home but also need a backup when my two existing branded Logitech squeezebox recievers fail.

This is always from a fresh install with nothing else installed other than the rpi-updates.

I'd say I'm a basic/medium user of Linux and I'm trying to install squeezeslave on a model B raspberry pi (bought the other day) I have installed squeezeslave and can successfully run using the ./squeezeslave -D -F command (with music output, so I know it functions correctly) but all attempts to run at start up have failed.

I have tried on the Raspbian (2013-05-25) and the Soft-float Debian (2013-05-29) OS' using the squeezeslave-1.2.311 and squeezeslave-1.3.393 versions.

Everytime I attempt to start from boot or manually using the command 'sudo /etc/init.d/squeezeslave start' I get the following error message /etc/init.d/squeezeslave: 49: .: 3: Too many open files

Any ideas people as this is most annoying :o( I'd like to setup a couple extra of these for the home but also need a backup when my two existing branded Logitech squeezebox recievers fail.

This is always from a fresh install with nothing else installed other than the rpi-updates.

No it wasn't running when I attempt to launch it from the init script.I get the same error message on the console as it trys to load on boot so definatly not running.As far as I can tell the script file looks correct and has the stop, start, restart handles defined, the only thing I have changed is the SBSHOST value to SBSHOST="-F"

What do you see around line 48 of the init script?However, it shouldn't have been necessary to edit that file - because of the instructions related to defaultsqueezeslave.So perhaps something went wrong in the editing process and easiest would be to copy back the original and use the defaultsqueezeslave approach to set the -F

Okay will give that a go tomorrow, I just realised I may have made my life hard by creating the squeezeslavesrc at root / rather than in the pi home directory, I'm guessing the permissions would be different on a folder /squeezeslavesrc to a folder in /home/pi/squeezeslavesrc ?

Thanks for your help, all commands now run okay and I can stop,start,restart squeezeslave using the init scripts and it starts on boot also too.Don't have any sound this time round but thats okay I think I just need to play around with the SSOPTIONS section when I get my USB speakers tomorrow, failing that run the slightly older version 1.2.311 on your blog rather than the newer 1.3.393 as I had sound working on the 1.2.311 the other day.Thanks

That is good news Phillip.You might also like to try SqueezeLite ... which has more codecs built in and can work with some other plug-ins.There is also SqueezePlug and PicoPlayer - both are complete OS distributions .... with PicoPlayer (hopefully the right name) able to run without needing the SD card after booting - and SqueezePlug havings lots of different servers and players included for scripted install.

Hi Paul, I used this howto to install squeezeslave on my raspberry pi. It all works great except for one thing: after a period of time there is no more audio coming from squeezeslave. This period differs per time and I have no idea what causes it. After a reboot squeezeslave works fine again with the audio.. what I find strange is that playing a file with aplay works fine. I do not know how to troubleshoot this as I am pretty much new to Linux (starting to learn more in the process though). Any suggestions?Thanks!

Hello namrehIf you are not using your RPi for anything else then you might find it better to use SqueezePlug (if you have a spare SD card you will find it pretty easy to test).Otherwise I can only suggest the default approach of going through the software update route and hope that the issues you are seeing have been fixed in more recent versions of RPI firmware/Raspbian/SqueezeSlave - with the danger that moving to later versions introduces new problems.Checking the SqueezeSlave updates first is probably the easiest and least risky.Simply compare the version listed in this old blog post with the latest on the site that I linked to ... and if newer there then repeat the first few steps but with the new file archive name.

I wouldn't bail out on Squeezeslave that fast. It stays running indefinitely for me. However I did have powersuppy issues make the USB port lose track of my external sound card device and quite playing. The solution is to run the Pi on a powered USB hub so that you have extra power for other USB devices and the Pi itself. Worth a look if you aren't already using a powered USB hub. Lots of mysterious hangs and disconnects vanished after using the powered USB hub for everything...even the Pi's power.

Hi Paul and BitbangerI have my Pi connected to a USB charger that I bought with the Pi.. also there is no external USB sound card so I cannot see how power issues could create the problem.. also I cannot debug the system so therefore I followed the advice of Paul and did a installation of SqueezePlug. As I bought a not out of the box supported USB WLAN device (which is not advisable), I first installed the Raspbian image that did have this. In my case http://blog.pi3g.com/2013/05/tp-link-tl-wn725n-nano-wifi-adapter-v2-0-raspberry-pi-driver/ . With this I installed the SqueezePlug like Thomas describes here http://www.squeezeplug.eu/?p=283 (because the driver for the WLAN USB are not available in the default distribution(kernel) that Thomas provides I found that this was the way to go). After that keep in mind that you turn the drivers on as squeezeplug turns them off by default somehow (so I followed the modprobe part). I then easily installed Shairport and Squeezeslave. The networkconfig in Squeezeplug did not work for me so in case readers have the same problem: this is the way to do it:sudo nano /etc/network/interfacesput this:auto wlan0iface wlan0 inet dhcp wpa-ssid "your ssid" wpa-psk "your password"iface default inet dhcp

in it

I just finished this - took me around an hour.. probably this would be a breeze for you but as I said.. new to linux :-) Anyway: will leave this setup running and will let you know how if it works (sure hope it will!)

Tricky one.When you tried Squeezeplug did you go for SqueezeLite or SqueezeSlave?SqueezeLite seems to have more active development at present and might have a better chance of having issues resolved.A firmware update /might/ also help.Guesswork really - sorry.Digging through logs might help.But if you simply want to have something that usually works then forcing an overnight reboot via cron could be a workaround.- if nothing else happening on the device.

I would try removing the USB wifi adapter and just hardwire it to your router and see if it stays running. If you are not using an external sound card, you are likely getting pop/click sounds as the onboard sound device is opened/closed. I found that to be not-musical, and especially annoying with sub-woofers. Adding an external USB sound card solves that issue.

You still might have power issues, as you haven't tried anything different than that USB charger. Your wifi card may be taxing your adapter's current capacity and hanging. What is the output current rating of that adapter? Try a larger one.

I already tried Squeezelite once and this was what I got: https://code.google.com/p/squeezelite/issues/detail?id=31 .. pretty annoying.

@Bitbanger: Audio does work when squeezeslave stops. Right now the audio of Squeezeslave stopped working, however this: aplay /usr/share/sounds/alsa/Front_Center.wav creates a nice sound on the Raspberry.

I think I'll just go for a periodic reboot overnight. The Raspberry is only doing Squeezeslave.. I'll have a little look on the net before though. Will let you know if I find anything!

Hi, can someone point out my error? I'm trying to run two instances of Squeezeslave on the Pi. I have two commmand lines:/usr/bin/squeezeslave --mac 00:1f:02:82:3f:d9 --output 0 192.168.111.45 &/usr/bin/squeezeslave --mac 80:1f:02:82:3f:d9 --output 1 192.168.111.45 &

Either command works, but if I then run the other one that doesn't produce sound from the USB PCM2740 DACS I have connected via a hub.

Show us what your -L output looks like. Kill any existing squeezeslave processes then run one with only -L. Post that here. Let's make sure that 0 and 1 aren't really the same device. Secondly, I'd change the last octet of the MAC to be different than the first, tho I don't think that makes much different to LMS, it might be considered invalid with the 80 as the first octet. Try making the first three 00:04:20 then make up the last three.

It might be possible to get LMS to resample - but I'd recommend a different approach and switch from SqueezeSlave to SqueezeLite.It seems to get more development.Also - if you have a spare SD card or don't care about the contents of your current one then you could download SqueezePlug (http://www.squeezeplug.eu ).It is a Raspbian distribution with menu driven installation of SqueezeLite (or SqueezeSlave), LMS and other options.