Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

General discussion relating to the O2 Joggler, from the default O2 setup, to alternative operating systems and applications.
Post Reply
User avatar
DJWillis
Posts: 18
Joined: Wed Aug 24, 2011 8:39 pm

Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

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 :twisted: 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 :D.

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
(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

Code: Select all

sudo apt-get update && sudo apt-get upgrade
along with a reboot

Code: Select all

sudo sync && sudo 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).

Code: Select all

aplay -Ll
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).

Code: Select all

amixer
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.

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
Untar

Code: Select all

tar xvfz squeezelite-1.9.9.1392-i686.tar.gz
Check your download is ok

Code: Select all

./squeezelite  -?
If you see something like
Squeezelite version number, Copyright 2012-2015 Adrian Smith, 2015-2021 Ralph Irving. See -t for license terms
and the help options, you are good.

Move the binary to the SqueezePlay users home directory (or any other location that suits).

Code: Select all

sudo mv squeezelite /home/squeezeplay/squeezelite
Edit up the script that launches SqueezePlay as the squeezeplay user.

Code: Select all

sudo nano /opt/squeezeplay/bin/squeezeplay.sh
Scroll to the bottom and paste the following just before the xset line (done so as it is started as early as practical).

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
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.

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)
-z runs it as a deamon.

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
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.

Code: Select all

sudo sync && sudo reboot
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.
Last edited by DJWillis on Thu Jan 20, 2022 12:53 pm, edited 1 time in total.
Man in a van
Posts: 383
Joined: Sun Aug 25, 2013 2:39 pm
Location: Staffordshire. UK

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by Man in a van »

Many thanks for this DJ :)

I'm running an Cisco OpenFrame with a small Hama usb hub, Khadas Toneboard dac (used as a headphone player) OS is on a SanDisk Ultra Fit USB stick.

I'll pull a LMS version over at sometime, to make it a self contained unit.

Cheers

ronnie
User avatar
DJWillis
Posts: 18
Joined: Wed Aug 24, 2011 8:39 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

That is a nice looking little DAC board (most of mine are older Topping stuff unless in Pi's).

The higher res audio should be fine with the right Squeezelite settings, if you want to use DSD you are going to want to play with the -D setting (DOP, DSD over PCM frames) but that should work, I tried it with one of the DSD DACs I have.

As for LMS, you may slightly struggle with perl and 32bit libs if you want to be running the latest versions of LMS but all that is fixable if your happy to tinker. One my my setups is used by a friend and I built that around an OF2 with LMS (8), Squeezelite and Squeezeplay (as above) and a music folder on there NAS. Slow to setup but once running and indexed it runs well enough for use.
Man in a van
Posts: 383
Joined: Sun Aug 25, 2013 2:39 pm
Location: Staffordshire. UK

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by Man in a van »

No problem with LMS :)

I installed v8.2.1(stable nightly) configured it, then updated to v8.3.0 (dev)
Logitech Media Server Status
Logitech Media Server Version: 8.3.0 - 1635067942 @ Sun Oct 24 11:59:10 CEST 2021
Hostname: openframe
Server IP Address: 192.168.1.117
Server HTTP Port Number: 9000
Operating system: Debian - EN - utf8
Platform Architecture: i686-linux
Perl Version: 5.26.1 - i686-linux-gnu-thread-multi-64int
Audio::Scan: 1.05
IO::Socket::SSL: 2.060
Database Version: DBD::SQLite 1.34_01 (sqlite 3.7.7.1)
I ran (just to be sure)

Code: Select all

sudo apt update && sudo apt install libio-socket-ssl-perl libnet-libidn-perl libnet-ssleay-perl libcrypt-openssl-rsa-perl lame
before I downloaded with wget and then installed with

Code: Select all

sudo apt install ./logitechmediaserver_8.3.0~1635067942_i386.deb
LMS can now use apt to install and pull in the needed binaries, but I just wanted to be "belt and braces" ;)

No tinkering with the BBC Sounds plugin now required, either :)

ronnie
Man in a van
Posts: 383
Joined: Sun Aug 25, 2013 2:39 pm
Location: Staffordshire. UK

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by Man in a van »

I thought I would just add my squeezelite command line

Code: Select all

~/squeezelite -M OpenFrame -n ToneBoard -s 127.0.0.1 -o hw:CARD=Control,DEV=0 -V PCM  -a 80:4::1: -z
By the way, using the external usb stick set-up, the OS can just be swapped between Jogglers.

I have just copied the above line from my "betting shop" Joggler :)

I would also add that the standard Joggler caveat still holds; "not all usb sticks and usb dacs". I did experience some difficulty until I found the "right" combination ;)

ronnie
User avatar
DJWillis
Posts: 18
Joined: Wed Aug 24, 2011 8:39 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

Man in a van wrote: Mon Oct 25, 2021 10:10 am I would also add that the standard Joggler caveat still holds; "not all usb sticks and usb dacs". I did experience some difficulty until I found the "right" combination ;)
That is a very good point, nothing about these tweaks improves hardware support directly or makes up for USB snags that can dog the OF devices or the needs for hubs inline if you draw the 2.0 USB off the PCB.
jogglerhase
Posts: 172
Joined: Wed Aug 08, 2012 3:02 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by jogglerhase »

Thanks for this 'dirty hack' @DJWillis!

I followed your instructions and it (mostly) works in my setup as well.
I needed to do it, because I encountered random crashes with @roobarb! 'std' install.

But I have 3 questions:

1) In LMS, I see now 2 players: Beside the new SqueezeLite one, I still see the old SqueezePlay as well. I assume, that is normal - can you confirm that?

2) More importantly, I still have the 'screen backlight goes to 100% when hitting the power icon (on / off / on toggle)' issue with this setup. And I seem not be able to bandaid it with @roobarb! old bandaid:
"Take a look at /opt/squeezeplay/share/jive/jive/JiveMain.lua. In there are some instances of 'xset' being run - comment them out with '--'."
If I do that the screen does not react at all on the power icon toggle
-> Do you see that as well? Do you have an idea how to fix that?
***update to 2) ***:
So strange - I tried a lot yesterday to fix this. No Luck. Today I asked here for help, but tried afterwards again, just to be sure... Now it (the bandaid) works again!
-> This works and is not an issue anymore.

3) A general problem I have with this image: update&upgrade (to keep the system healthy) seems to break something, as the system will not boot into the GUI afterwards. This is a generic issue with this image, not related to your 'dirty hack'. But my question: Does anyone sees that as well?

Other that that I can only reiterate that I am very thankful to all yopu people keeping this Joggler alive as a 'Squeezebox'.

P.S. I know it has been 2 month since the last activity in this thread.... so I hope my response is still beeing noticed.....
User avatar
DJWillis
Posts: 18
Joined: Wed Aug 24, 2011 8:39 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

@jogglerhase just to respond, sorry, got logged out and lost track of the reply.

On the 1st point, nope, you should just see one player if you did it as I have. The SqueezeLite player claims things before the full Jive gets run up, meaning the player code backs off as it sees a player already running (assuming your using the same name/details/MAC etc.). At least that is my experience and I did a quick dig into the code to check my reasoning but not in detail as it just worked. That said, I'll look more, I can think of reasons this might happen.

2nd, I tend to see some backlight issues but they are fairly minor, I run my Jogglers on auto brightness most of the time. The snags have never been enough to bother me with my units (Jogglers and OF2's) and they have been running for many years.

3rd, yep, this I see every so often, in my experience it is normally a sign of the USB getting bad (if your running on USB). EXT2 is fairly friendly to flash but with the logs and the like, it seems to eat cheap cards. I keep a 'good' image of the unit on another stick as it is cheaper to swap them out and boot it up. In all cases I have seen this with USB the flash sticks have been on the way out, independently verified when testing outside the Joggler.

If your using the built in NAND it may be a similar issue, I found that to cause me more issues than it solved so I switched to USB for the most part many years ago. I just keep a clean CLI Bionic image on the NAND for any sort of service.
jogglerhase
Posts: 172
Joined: Wed Aug 08, 2012 3:02 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by jogglerhase »

DJWillis wrote: Thu Jan 20, 2022 10:23 am @jogglerhase just to respond, sorry, got logged out and lost track of the reply.

On the 1st point, nope, you should just see one player if you did it as I have. The SqueezeLite player claims things before the full Jive gets run up, meaning the player code backs off as it sees a player already running (assuming your using the same name/details/MAC etc.). At least that is my experience and I did a quick dig into the code to check my reasoning but not in detail as it just worked. That said, I'll look more, I can think of reasons this might happen.

2nd, I tend to see some backlight issues but they are fairly minor, I run my Jogglers on auto brightness most of the time. The snags have never been enough to bother me with my units (Jogglers and OF2's) and they have been running for many years.

3rd, yep, this I see every so often, in my experience it is normally a sign of the USB getting bad (if your running on USB). EXT2 is fairly friendly to flash but with the logs and the like, it seems to eat cheap cards. I keep a 'good' image of the unit on another stick as it is cheaper to swap them out and boot it up. In all cases I have seen this with USB the flash sticks have been on the way out, independently verified when testing outside the Joggler.

If your using the built in NAND it may be a similar issue, I found that to cause me more issues than it solved so I switched to USB for the most part many years ago. I just keep a clean CLI Bionic image on the NAND for any sort of service.
Thank you for the feedback!

Regarding 1): I think I missed before the instruciton 'force SqueezePlay to exclusive use of your audio device' and also using the same Name.
W/ these 2 things corrected, only squeezelite from the Joggler shows up in LMS. Great - Thank you!
(On the Jogglers screen-Interface, I still have 2 'Joggler's to select from as available players, but that selection option on the Jogglers screen I never use, so thats no problem.)

Regarding 3), I am surprised about that this should be related to the USB stick in use (I do use an USB stick, not the internal memory), I say that because I see that behavior(*) with different USB sticks, which otherwise work totally reliable in the Joggler

(*) Just to confirm we talk about the same thing:
My described problem only happens when I do 'sudo apt-get update && sudo apt-get upgrade' (not during the setup sequence, where it works as expected, but later in normal use to keep the system up2date).
User avatar
DJWillis
Posts: 18
Joined: Wed Aug 24, 2011 8:39 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

jogglerhase,

Cool, yep, it is the fact that the audio interface is claimed that makes this work cleanly. Glad that is working.

On 3, just out of interest, I did a few updates to older Jogglers recently and I noticed that the startx systemd script for starting X as the Squeezeplay user seems to get broken with some update (I noticed it after a dist-upgrade on a Joggler I had been neglecting for a bit). Starting X manually after SU'ing into the Squeezeplay user worked just fine. I'll look into checking if it has an easy fix. Suspect it is something simple as I bet a symlink is missing.
jogglerhase
Posts: 172
Joined: Wed Aug 08, 2012 3:02 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by jogglerhase »

DJWillis wrote: Sun Jan 23, 2022 6:45 pm jogglerhase,

Cool, yep, it is the fact that the audio interface is claimed that makes this work cleanly. Glad that is working.

On 3, just out of interest, I did a few updates to older Jogglers recently and I noticed that the startx systemd script for starting X as the Squeezeplay user seems to get broken with some update (I noticed it after a dist-upgrade on a Joggler I had been neglecting for a bit). Starting X manually after SU'ing into the Squeezeplay user worked just fine. I'll look into checking if it has an easy fix. Suspect it is something simple as I bet a symlink is missing.
Reg. 3) - that would be really great, if you would find a 'real' solution for the issues after update!
(With the current situation, I avoid updates - until I forget the problem and end up with just a command line on the Joggler.
Out of interest: How do you start X and the Squeezeplay GUI manually? )
User avatar
DJWillis
Posts: 18
Joined: Wed Aug 24, 2011 8:39 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

jogglerhase wrote: Mon Jan 24, 2022 10:49 am Out of interest: How do you start X and the Squeezeplay GUI manually? )
Many ways to do it, you just need to get a shell as the user. Next time this happens to you, pop in a usb keyboard, login at the console with your regular user (of normally) so your on the right display.

I suspect the easiest is something like this (from memory, not near a device to double check).

Code: Select all

sudo -s -u squeezeplay
or

Code: Select all

sudo -s
su squeezeplay
then

Code: Select all

startx
That should get you going as it will start X and that users X environment setup runs up the rest of the system.
If it starts, and everything works as normal you could reasonably suspect it is might be the systemd service (startx is the service name, it is added by of-settings to run as the squeezeplay user) that is the snag.
jogglerhase
Posts: 172
Joined: Wed Aug 08, 2012 3:02 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by jogglerhase »

DJWillis wrote: Mon Jan 24, 2022 9:56 pm
jogglerhase wrote: Mon Jan 24, 2022 10:49 am Out of interest: How do you start X and the Squeezeplay GUI manually? )
Many ways to do it, you just need to get a shell as the user. Next time this happens to you, pop in a usb keyboard, login at the console with your regular user (of normally) so your on the right display.

I suspect the easiest is something like this (from memory, not near a device to double check).

Code: Select all

sudo -s -u squeezeplay
or

Code: Select all

sudo -s
su squeezeplay
then

Code: Select all

startx
That should get you going as it will start X and that users X environment setup runs up the rest of the system.
If it starts, and everything works as normal you could reasonably suspect it is might be the systemd service (startx is the service name, it is added by of-settings to run as the squeezeplay user) that is the snag.
Thanks again, DJWillis.
I will try that next time my Joggler shows the problem.

One question:
Do I really need to use an keyboard connected to the Joggler to startx on the physical screen, or can I do the described sequence also via telnet?
(I am asking, since my Joggler is installed in a wall and getting to the USB slots is a bit difficult....)
User avatar
DJWillis
Posts: 18
Joined: Wed Aug 24, 2011 8:39 pm

Re: Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

jogglerhase wrote: Wed Jan 26, 2022 5:18 pm One question:
Do I really need to use an keyboard connected to the Joggler to startx on the physical screen, or can I do the described sequence also via telnet?
(I am asking, since my Joggler is installed in a wall and getting to the USB slots is a bit difficult....)
It comes down to getting X to start on the right display (obviously SSH.telnet, you have a console but no display environment).
Normally, if you used X over SSH you would forward the X session over the network to another display (such as the one on your laptop).

It can be done, it just won't be clean. something like

Code: Select all

export DISPLAY=localhost:0.0 
startx
Should work once you have sudo'ed into the squeexeplay user. I'll test it later as it has been a while.
Post Reply