[Howto] Running Logitech Media Server's SqueezeLite Client on Rasplex/Openelec/LibreElec

Hi there

 

Finally managed to get SqueezeLite running on Rasplex/Openelec. I now have only one Raspi running both Plex for my videos as well as SqueezeLite to stream music to my TV setup using a Logitech Media Server. Awesome combination :-).

 

Notes:

  • I'm using a Raspberry Pie 2 with Rasplex version 0.7 (clean install).
  • And now upgraded to LibreElec 7.0.1 on a Raspi 3 running PlexKodiConnect :-)
  • LMS and video output is over HDMI to my receiver
  • You need to manually shut-down your new LMS Rasplex Client before using Plex again by using your LMS controller. Otherwise, Plex playback won't start.
  • SqueezeLite and Rasplex can't play audio simultaneously. However, with the undocumented SqueezeLite v1.8 "-C x" option, SqueezeLite will relinquish its use of alsa audio after x seconds. This should prevent most scenarios where you'd be playing simultaneously. You do not need to manually shut down the SqueezeLite player instance either.
  • With Rasplex 0.7, SqueezeLite and Rasplex can now simultaneously play audio. Does not sound pretty though :-).
  • If you run into problems e.g. unresponsive Rasplex because you did use two audio streams, a simple reboot should help.

![post-128263-0-54157800-1430212161.png|368x108](upload://sQReIu0MIo32NhWBELNuoN4oz74.png)

 

1. Get static SqueezeLite binary

Non-static versions did not work for me. I found a static version here (squeezelite-1.7.1-armv6hf-static): ralph_irving.users.sourceforge.net/pico/. New static binary here (SqueezeLite -> Linux -> squeezelite-1.8.0-584-armv6hf.tar.gz): https://www.mediafire.com/folder/4q8dvq20iyz9e/Builds#lllwjg7xjl1by

Upload the binary to your Raspi to a new folder using e.g. WinSCP; username "root", password "rasplex". I used the new folder /storage/.plexht/userdata/squeezelite. Rename the binary to e.g. squeezelite-1.8-armv6hf-static. Set the file permissions to 755. 

 

2. Load module

SSH into your Rasplex installation with the same credentials. Type the following:

cd /storage/.config/modules-load.d
nano squeeze.conf

In the new, empty windows, just enter "snd_bcm2835" without the quotes. Safe and exit nano.

 

3. Disable LIRC

Don't know whether this is really needed; other posts seem to suggest that disabling LIRC improves stability.

cd /storage/.config/modprobe.d/
nano disable-lirc.conf

In the new, empty windows, just enter "blacklist lirc_rpi" without the quotes. Safe and exit nano.

Reboot

4. Figure out the correct audio device

You need to tell SqueezeLite which audio device to use.

cd /storage/.plexht/userdata/squeezelite
./squeezelite-1.8-armv6hf-static -l

Copy-paste the correct audio device for you. In my case "default:CARD=ALSA".

If at this point you don't get any meaningful output devices, try this:

mount -o remount,rw /flash
nano /flash/config.txt

Search for any line containing "dtparam" and put a hash "#" in front of it to disable it. Add instead "dtparam=audio=on" (without a hash) or "dtparam=audio=on,spi=on" if you want to use e.g. Hyperion. Save and exit nano. Then:

mount -o remount,ro /flash
reboot

 Then start over again with this fourth step. 

5. Test SqueezeLite

./squeezelite-1.8-armv6hf-static -n "SqueezeLite-Test" -o "default:CARD=ALSA"  -a "200"

The command prompt should be "stuck" at this point without any output. If you check your Logitech Media Server, you should now see a new player "SqueezeLite-Test". Press Ctrl + c to stop SqueezeLite and return to prompt.

 

6. Setup SqueezeLite to start on boot

Create or update your autostart.sh:

cd ~/.config 
nano autostart.sh

In the new window, enter the following:

#!/bin/sh

ALSA-SETUP

############

Force Alsa output to HDMI (2=HDMI)

amixer cset numid=3 2

Set Alsa volume to 100%

amixer cset numid=1 400

SQUEEZELITE-SETUP

###################

Variables

Path to squeezelite bin

PATH=$PATH:/storage/.plexht/userdata/squeezelite
SL_BINARY=“squeezelite-1.8-armv6hf-static”

the name for the squeezelite player (-n option):

SL_NAME=“Wohnzimmer”

Set the soundcard

SL_SOUNDCARD=“default:CARD=ALSA”

Highest bitrate, find highest number in line starting with

“output_init_common:394 supported rates:”

when running squeezelite -d output=debug. E.g. 384000

SL_BITRATE=“384000”

Set buffer (CHANGE THIS IF YOUR OUTPUT STUTTERS)

SL_BUFFER=“50000”

Set timeout (for squeezelite >= 1.8 only!)

SL_TIMEOUT=“3”

Start SqueezElite

($SL_BINARY -n $SL_NAME -o $SL_SOUNDCARD -a $SL_BUFFER -r $SL_BITRATE -C $SL_TIMEOUT -z)&


Safe and exit nano. Make autostart.sh executable and reboot:

chmod +x autostart.sh
reboot

That's it. You should now be able to EITHER have your normal Rasplex Plex audio OR stream your Logitech Media Server audio. Do remember to always shut-down your LMS Player "SqueezeLite" with your LMS controllers of choice before starting to use Plex.

 

Edit: added "and set the file permissions to 755"

Edit2: updated from v1.7.1 to v1.8 and included the "-C" option of SqueezeLite

Edit3: wtf?!? My email showed up as discussion title

Edit4: update from Rasplex 0.6 to 0.7

Edit5: Update step 4 and PlexKodiConnect and buffer up to 50'000 (from 5'000)


That's it. You should now be able to EITHER have your normal Rasplex Plex audio OR stream your Logitech Media Server audio. Do remember to always shut-down your LMS Player "SqueezeLite" with your LMS controllers of choice before starting to use Plex.

Excellent write-up @tomkat83, can you mark your previous topic as answered. Thanks.

Very cool tomkat83!  I'll have to give it a try.  Shutting down LIRC is not an option for me, so I'll have to see how that works.


That's it. You should now be able to EITHER have your normal Rasplex Plex audio OR stream your Logitech Media Server audio. Do remember to always shut-down your LMS Player "SqueezeLite" with your LMS controllers of choice before starting to use Plex.

I assume this restriction is due to the fact that no two process can access the sound card at the same time, and this would fix that limitation.

Do you think with a Hifiberry for Squeezelite's audio output (or any other DAC) and HDMI for Rasplex, this would remove the need to power off the Squeezebox client before using Raplex? In my case they'd be on two separate inputs on my receiver anyway, so they'd never play at the same time.

I assume this restriction is due to the fact that no two process can access the sound card at the same time, and this would fix that limitation.

Do you think with a Hifiberry for Squeezelite's audio output (or any other DAC) and HDMI for Rasplex, this would remove the need to power off the Squeezebox client before using Raplex? In my case they'd be on two separate inputs on my receiver anyway, so they'd never play at the same time.

I'd guess so. Give it a try and let us know whether it worked simultaneously. Although I cannot fathom why you would want to have 2 different audio sources running at the same time :P

It’s not about running both simultaneously but more about not having to think about powering off either one when I want to use the other (more family-proof). I’ll give it a go as soon as I have some free time and report back.

Firstly, thanks for your work on this, it's something I really need so that I don't have to swap between SD cards (RASPlex/PiCorePlayer).

Why can't Plex and squeezelite both stream independently without conflicting?

(I don't want to have to stop/start squeezelite to use Plex - wife acceptance factor)

Do Plex and Squeezelite call for exclusive access of the sound devices?
Does ALSA require that? Surely it can mix the two streams?

ThanksALot

Can anyone help with this, please?

ThanksALot

@SirThanksALot said:

Do Plex and Squeezelite call for exclusive access of the sound devices?

Rasplex does at the moment, check again in the next release, which is coming very soon.

Regards

Meanwhile, I found a workaround :-). There is a new, undocumented “-C x” option. Squeezelite will then drop the connection to alsa after x seconds if nothing is being played. You won’t need to explicitly turn off squeezelite before using Rasplex.

I’ll update the Howto above soon.

In a nutshell:

  1. Download and use the newer 1.8 static squeezelite binary “squeezelite-1.8.0-584-armv6hf.tar” from here (under SqueezeLite->Linux): https://www.mediafire.com/folder/4q8dvq20iyz9e/Builds#lllwjg7xjl1by
  2. Replace the squeezelite binary on your rasplex accordingly. Use the following as your autostart.sh:
#!/bin/sh

# ALSA-SETUP
############
# Force Alsa output to HDMI (2=HDMI)
amixer cset numid=3 2
# Set Alsa volume to 100%
amixer cset numid=1 400

# SQUEEZELITE-SETUP
###################
# Variables
# Path to squeezelite bin
PATH=$PATH:/storage/.plexht/userdata/squeezelite
SL_BINARY="squeezelite-1.8-armv6hf-static"
# the name for the squeezelite player (-n option):
SL_NAME="Wohnzimmer"
# Set the soundcard
SL_SOUNDCARD="default:CARD=ALSA"
# Highest bitrate, find highest number in line starting with
# "output_init_common:394 supported rates:"
# when running squeezelite -d output=debug. E.g. 384000
SL_BITRATE="384000"
# Set buffer (CHANGE THIS IF YOU'RE OUTPUT STUTTERS)
SL_BUFFER="5000"
# Set timeout (for squeezelite >= 1.8 only!)
SL_TIMEOUT="3"

# Start SqueezElite
$SL_BINARY -n $SL_NAME -o $SL_SOUNDCARD -a $SL_BUFFER -r $SL_BITRATE -C $SL_TIMEOUT -z 

Good news here. With Rasplex 0.7, you can now simultaneously use Rasplex and SqueezeLite. No need to remember to shut down your SqueezeLite instance.

Probably due to 0.7.0 using two different players, one for video audio and one for music audio (which SqueezeLite uses).

Regards

Thanks, this is seems to work well for me so far with Rasplex 0.7.

I’d like to add that your step 1 was not easy for me to do. I’m not a programmer and it took me a while to figure out which file you were referring to ( binary file) because I had a .tar file which contained a folder and two files. At first I uploaded the .tar file and on my second I uploaded the uncompressed folder and I had problem setting the proper command for the permission (chmod -R 755 /storage/.plexht/userdata/squeezelite/insertnamehere). Thanks again for your post!

So do we need tomkat83’s workaround,or does it (0.7.0) work without it? confused

@SirThanksALot said:
So do we need tomkat83’s workaround,or does it (0.7.0) work without it? confused

No you don’t. But I guess it does not hurt to include the SqueezeLite “-C” option, so that SqueezeLite automatically drops the audio connection when not playing.

@tomkat83 said:

  • With Rasplex 0.7, SqueezeLite and Rasplex can now simultaneously play audio. Does not sound pretty though :-).

What does this mean? I currently use a Cubox (which has its own SPDIF) for my Squeezelite needs (and overall is probably a better player anyway), but it would be nice to combine the two.

@robertsig said:
What does this mean? I currently use a Cubox (which has its own SPDIF) for my Squeezelite needs (and overall is probably a better player anyway), but it would be nice to combine the two.

Well, in my case I have 2 audio streams on the same speakers. For example, a movie with tons of explotions while SqueezeLite plays classical music on them, too :stuck_out_tongue:

Thank you for the tuto.
When I do the command line (I got an USB DAC) :
./squeezelite-1.8-armv6hf-static -n "BEDROOM" -o "default:CARD=DAC" -a "200"

Everything works well, i got Raplex and i can play any song on the squeezelite client.

But, when i reboot, i don’t have anymore the squeezelite client running.

The only way for the squeezelite client to run at start is to modify the autostart.sh :

# Path to squeezelite bin PATH=/storage/.plexht/userdata/squeezelite

# Start SqueezElite $PATH $SL_BINARY -n $SL_NAME -o $SL_SOUNDCARD

But Rasplex doesn’t work anymore.

Any idea ?

PS : I install this package http://www.mediafire.com/download/jdtkcqwehax40f3/squeezelite-1.8.0-589-armv6hf.tar.gz

PS2 : I got this message at the boot of Rasplex “Failed to start load kernel modules” (I’m with the 0.7.0)

PS3 : Does it matter if i use the Raspberry Pi B or B+ or 2 ?

My guess is that you messed something up with the PATH variable. This line takes the existing paths of Rasplex and then adds your additional new path to Squeezelite
# Path to squeezelite bin PATH=$PATH:/storage/.plexht/userdata/squeezelite
Then drop $PATH command later:
# Start SqueezElite $SL_BINARY -n $SL_NAME -o $SL_SOUNDCARD

.
Nothing to see here… Why can’t we delete posts ???