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: 14
Joined: Wed Aug 24, 2011 8:39 pm

Dirty Hack: Running SqueezeLite alongside SqueezePlay on OF Bionic 5.4

Post by DJWillis »

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.1386-i686.tar.gz https://sourceforge.net/projects/lmsclients/files/squeezelite/linux/squeezelite-1.9.9.1386-i686.tar.gz/download
Untar

Code: Select all

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

Code: Select all

./squeezelite  -?
If you see
Squeezelite v1.9.9-1386, 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).

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.
Man in a van
Posts: 353
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: 14
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: 353
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: 353
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: 14
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: 167
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.....
Post Reply