Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4
Posted: Mon Oct 18, 2021 2:07 pm
Updated: 20/01/22 - Just changed links to use a newer static SqueezeLite build (1.9.9.1392)
Warning:
This is a bit of a hack, but it is something I have done for a while now. It works well for me and provides stable base for OpenFrame devices with external DACs talking very happily to recent versions of LMS (8.2 GIT for me currently).
It may well NOT be worth the effort of doing this if you are not using an external USB DAC, or you are and everything already works well for you.
Don't attempt any of this if you are not prepared to ultimately reinstall your OpenFrame device using BirdsLikeWires reflash scripts if things go wrong.
Background:
For a long time I have been running recent static builds of SqueezeLite alongside the rest of the recent SqueezePlayOS (rather than JiveLite) on my Jogglers and OF devices to give me some more configurability from SqueezeLite.
As SqueezeLite is taking over the playback duties, it has also allowed me to sidestep issues I could never totally nail down when using some USB DACs despite rebuilding/tinkering with the OpenFrame SqueezePlay code (frequent crashes of SqueezePlay when undertaking sample rate conversions (crashing with Free() errors and dumping to the X terminal, even without audio outputs enabled, or chipmunking when using a USB DAC on my setup and other gremlins that have gone away with the switch to SqueezeLite).
My reason for doing this was simple, it allows for more fine grained control of sample rates, audio buffers and anything else you might want to tweak with SqueezeLite directly (just edit up the command line to suit your magic needs) while keeping the nicely customised OpenFrame SqueezePlay and scripts almost completely intact.
The logic behind this is simple enough, it exploits a design feature of SqueezePlay, if SqueezeLite is already running and has exclusively claimed the ALSA device it wants to access, SqueezePlay (Jive) will just use SqueezeLite as the local player and not keep spawning jive-alsa for playback. This actually happens fairly seamlessly from a user perspective with just a small grumble in the log files.
Basically, we are creating some horrid chimera
of older SqueezePlay and recent SqueezeLite, without ripping out all of SqueezePlay and replacing it cleanly with JiveLite. It may be horrid, but it works.
Why?
Well I wanted more more control over sample rates and outputs and generally to tweak things BUT I also wanted to keep the lovely core of SqueezePlay and the OpenFrame wrappers that just make the device a little more polished in day to day use.
That, and I was already running the OF 5.4 images and did not really want to change much or fully roll my own setup, so hacky tweaking felt like a valid option.
Prerequisites:
Shell (SSH is ideal) access to your OpenFrame panel, ability to sudo, some basic CLI knowledge to do some script mods, a little knowledge of your ALSA setup and an i386 Linux build of SqueezeLite.
Thankfully, Ralph Irving kindly provides static linked i386 Linux builds of SqueezeLite (1.9.9) built from his recent GIT code (https://sourceforge.net/projects/lmscli ... z/download) with all common playback libs linked in. This saves you having to build your own
.
The version of SqueezeLite included with Ubuntu 18.04 is old and I can't honestly recommend you use the version in the repositories.
Currently my setup is using excellent BirdsLikeWires OpenFrame Bionic 5.4 images with (SqueezePlayOS) setup, run and tested before starting, this gives you a known base to work from.
You also need to setup SqueezePlayOS to exclusively claim the audio device (via Settings > Audio Settings > Audio Interface > (Internal or External) Direct).
Also make sure network is running as you want.
Lastly, do yourself a favour and along with a reboot before you start anything else and ensure you have free space, especially if your running from the limited internal flash.
It should work just as well with the kernel 3 images as well (I done this with those images in the past) if you want a more mature base. Not tried with this the SPOS 3 (Ubuntu 14.04) images, that is just to old for me to want to mess with and defeats the point of wanting a semi recent base to build from.
Setting up SqueezeLite
Connect into the shell on your OF device to run commands.
Grab some helpful ALSA information on your setup (save the output handy, for later on in the process).
You will want the details for card 0 if internal, card 1 if your using an external DAC, (hw:CARD=DAC,DEV=0 in my case).
Depending on your setup you will want the simple mixer control that supports pvolume for your card (PCM in my case)
Download the statically linked SqueezeLite binary.
Untar
Check your download is ok
If you see something like
Move the binary to the SqueezePlay users home directory (or any other location that suits).
Edit up the script that launches SqueezePlay as the squeezeplay user.
Scroll to the bottom and paste the following just before the xset line (done so as it is started as early as practical).
Change the command line and path to suit as needed if you have different devices.
-M is the model, set to OpenFrame to match what OF SqueezePlay returns.
-o is the output device (internal or external ALSA device you want to claim)
-V is just telling it to use ALSAs volume control. Just a perferance thing for me, you can tweak as needed.
Regarding the -a commands, the defaults above I find work well for me, tweak as needed.
You could also add a -n to force the player name, otherwise it will 'inherit' whatever you called the SqueezePlay player in LMS (as it is on the same MAC address).
Optional extra:
Setup the Jive process to respawn if it does not exit cleanly (via Quit). I do this so that if for any reason it crashes it comes back rather than dumping to the X terminal, I consider this fairly important on devices that normally don't have any input devices beyond the touchscreen connected. It is a bit belt and braces, but hey
.
Replace the ./jive at the bottom of the script with the following.
Just as an aside, I have not had SqueezePlay crash (that I have noticed) since I moved to SqueezeLite for playback, this is an overhang from before I switched.
Finishing Up:
Check and double check your file changes, save them with Ctrl+X + Y.
Now comes the moment of truth, reboot your device with.
Once your device is back up, you should have SqueezePlay running but connecting to the SqueezeLite instance, not the built in one.
You can verify this by looking at the device info in the LMS web page or just running top/htop in a OF shell.
Now you need to test playback and generally customise things to you liking or fix any issues (nothing here will have stopped network/SSH access so you should be able to get back in to sort stuff as needed).
If you want to experiment with the SqueezeLite settings you can kill off the running instance and just run it again in an SSH shell (without -z) to see what happens. SqueezePlay and LMS will just reconnect to the instance when it comes back. CTRL + C to exit and try other parameters until you find the ideal setup to copy into the script (adding on the -z again).
Similarly, if you want to update SqueezeLite in the future, just download the latest release, check it works (as per the above instructions), kill off the running instance and copy the new static build over the top then sync and reboot your device.
I suspect I have missed a load of info in this post but as I have done this on a fair few OF devices and have helped a few others do it, I felt that writing things down was long overdue on the basis that it might be helpful to someone.
Any comments, just shout.
Warning:
This is a bit of a hack, but it is something I have done for a while now. It works well for me and provides stable base for OpenFrame devices with external DACs talking very happily to recent versions of LMS (8.2 GIT for me currently).
It may well NOT be worth the effort of doing this if you are not using an external USB DAC, or you are and everything already works well for you.
Don't attempt any of this if you are not prepared to ultimately reinstall your OpenFrame device using BirdsLikeWires reflash scripts if things go wrong.
Background:
For a long time I have been running recent static builds of SqueezeLite alongside the rest of the recent SqueezePlayOS (rather than JiveLite) on my Jogglers and OF devices to give me some more configurability from SqueezeLite.
As SqueezeLite is taking over the playback duties, it has also allowed me to sidestep issues I could never totally nail down when using some USB DACs despite rebuilding/tinkering with the OpenFrame SqueezePlay code (frequent crashes of SqueezePlay when undertaking sample rate conversions (crashing with Free() errors and dumping to the X terminal, even without audio outputs enabled, or chipmunking when using a USB DAC on my setup and other gremlins that have gone away with the switch to SqueezeLite).
My reason for doing this was simple, it allows for more fine grained control of sample rates, audio buffers and anything else you might want to tweak with SqueezeLite directly (just edit up the command line to suit your magic needs) while keeping the nicely customised OpenFrame SqueezePlay and scripts almost completely intact.
The logic behind this is simple enough, it exploits a design feature of SqueezePlay, if SqueezeLite is already running and has exclusively claimed the ALSA device it wants to access, SqueezePlay (Jive) will just use SqueezeLite as the local player and not keep spawning jive-alsa for playback. This actually happens fairly seamlessly from a user perspective with just a small grumble in the log files.
Basically, we are creating some horrid chimera

Why?
Well I wanted more more control over sample rates and outputs and generally to tweak things BUT I also wanted to keep the lovely core of SqueezePlay and the OpenFrame wrappers that just make the device a little more polished in day to day use.
That, and I was already running the OF 5.4 images and did not really want to change much or fully roll my own setup, so hacky tweaking felt like a valid option.
Prerequisites:
Shell (SSH is ideal) access to your OpenFrame panel, ability to sudo, some basic CLI knowledge to do some script mods, a little knowledge of your ALSA setup and an i386 Linux build of SqueezeLite.
Thankfully, Ralph Irving kindly provides static linked i386 Linux builds of SqueezeLite (1.9.9) built from his recent GIT code (https://sourceforge.net/projects/lmscli ... z/download) with all common playback libs linked in. This saves you having to build your own

The version of SqueezeLite included with Ubuntu 18.04 is old and I can't honestly recommend you use the version in the repositories.
Currently my setup is using excellent BirdsLikeWires OpenFrame Bionic 5.4 images with
Code: Select all
of-install squeezeplay
You also need to setup SqueezePlayOS to exclusively claim the audio device (via Settings > Audio Settings > Audio Interface > (Internal or External) Direct).
Also make sure network is running as you want.
Lastly, do yourself a favour and
Code: Select all
sudo apt-get update && sudo apt-get upgrade
Code: Select all
sudo sync && sudo reboot
It should work just as well with the kernel 3 images as well (I done this with those images in the past) if you want a more mature base. Not tried with this the SPOS 3 (Ubuntu 14.04) images, that is just to old for me to want to mess with and defeats the point of wanting a semi recent base to build from.
Setting up SqueezeLite
Connect into the shell on your OF device to run commands.
Grab some helpful ALSA information on your setup (save the output handy, for later on in the process).
Code: Select all
aplay -Ll
Code: Select all
amixer
Download the statically linked SqueezeLite binary.
Code: Select all
wget -O squeezelite-1.9.9.1392-i686.tar.gz https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1392-i686.tar.gz/download
Code: Select all
tar xvfz squeezelite-1.9.9.1392-i686.tar.gz
Code: Select all
./squeezelite -?
and the help options, you are good.Squeezelite version number, Copyright 2012-2015 Adrian Smith, 2015-2021 Ralph Irving. See -t for license terms
Move the binary to the SqueezePlay users home directory (or any other location that suits).
Code: Select all
sudo mv squeezelite /home/squeezeplay/squeezelite
Code: Select all
sudo nano /opt/squeezeplay/bin/squeezeplay.sh
Code: Select all
# Start SqueezeLite to 'force' SqueezePlay to not get a lock on the audio device and not start jive_alsa as a result.
#
# This means SqueezeLite takes over as the player and SqueezePlay acts more like JiveLite with all the nice OpenFrame
# extensions still working. Make sure you have forced SqueezePlay to exclusive use of your audio device (so it can fail cleanly).
~/squeezelite -M OpenFrame -o hw:CARD=DAC,DEV=0 -V PCM -a 80:4::1: -z
-M is the model, set to OpenFrame to match what OF SqueezePlay returns.
-o is the output device (internal or external ALSA device you want to claim)
-V is just telling it to use ALSAs volume control. Just a perferance thing for me, you can tweak as needed.
Regarding the -a commands, the defaults above I find work well for me, tweak as needed.
-z runs it as a deamon.
Specify the ALSA params to open output device (-a)
<b>:<p>:<f>:<m>:<d>
b = buffer time in ms or size in bytes
p = period count or size in bytes
f = sample format (16|24|24_3|32)
m = use mmap (0|1)
You could also add a -n to force the player name, otherwise it will 'inherit' whatever you called the SqueezePlay player in LMS (as it is on the same MAC address).
Optional extra:
Setup the Jive process to respawn if it does not exit cleanly (via Quit). I do this so that if for any reason it crashes it comes back rather than dumping to the X terminal, I consider this fairly important on devices that normally don't have any input devices beyond the touchscreen connected. It is a bit belt and braces, but hey

Replace the ./jive at the bottom of the script with the following.
Code: Select all
until ./jive; do
echo "SqueezePlay crashed with exit code $?. Respawning.." >&2
sleep 1
done
Finishing Up:
Check and double check your file changes, save them with Ctrl+X + Y.
Now comes the moment of truth, reboot your device with.
Code: Select all
sudo sync && sudo reboot
You can verify this by looking at the device info in the LMS web page or just running top/htop in a OF shell.
Now you need to test playback and generally customise things to you liking or fix any issues (nothing here will have stopped network/SSH access so you should be able to get back in to sort stuff as needed).
If you want to experiment with the SqueezeLite settings you can kill off the running instance and just run it again in an SSH shell (without -z) to see what happens. SqueezePlay and LMS will just reconnect to the instance when it comes back. CTRL + C to exit and try other parameters until you find the ideal setup to copy into the script (adding on the -z again).
Similarly, if you want to update SqueezeLite in the future, just download the latest release, check it works (as per the above instructions), kill off the running instance and copy the new static build over the top then sync and reboot your device.
I suspect I have missed a load of info in this post but as I have done this on a fair few OF devices and have helped a few others do it, I felt that writing things down was long overdue on the basis that it might be helpful to someone.
Any comments, just shout.