Making Squeezelite play well with KODI under Linux

The default settings for Squeezelite on Linux require it capture your sound card and hoard all audio for itself. This can be frustrating when the computer’s audio is shared with other programs.

Sharing is caring

The good news is that the latest version of Squeezelite (1.8) can be configured to release the sound card when it is not playing music. The bad news is that the Ubuntu software center has version 1.4 as of this writing. This is a problem for my Ubuntu-based KODIbuntu boxes. You may be able to find a .deb or a PPA with the latest, but I prefer to break out the terminal and get my hands dirty. Thanks to gene1wood on GitHub, we have a map.

First we install the old version of squeezelite and some build dependencies

Now that we have the latest version we need to configure it to share the sound card. Open /etc/default/squeezelite in your favorite editor and add the -C option to SB_EXTRA_ARGS. Don’t forget to uncomment it by removing the # at the beginning of the line.

sudo nano /etc/default/squeezelite

SB_EXTRA_ARGS="-C 3"

Press Ctrl+x to close and Y to save. These options tell Squeezelite to release the sound card 3 seconds after it has stopped playing. Restart the service and test it out

sudo service squeezelite restart

Choose your own adventure

I also had issues with squeezelite playing on the wrong sound card. I’m sure there is a way to set the default sound card, but since this post is about squeezelite, let’s work with that. To get a list of available sound devices run the following command.

squeezelite -l

This command will produce a lot more devices than you might expect. You should be able to stick to the any devices that start with “hw:” and ignore everything else. If, for example, I wanted squeezelite to send audio to the second HDMI port on my NVIDIA graphics card. I would use this one

The text on the left is the device identifier. In my example: “hw:CARD=NVidia,DEV=8”. We can now enter that ID into /etc/default/squeezelite. Once again, remember to uncomment the line and add your device ID.

SL_SOUNDCARD="hw:CARD=NVidia,DEV=8"

Save the file and restart the service.

sudo service squeezelite restart

Starting up smoothly

While Squeezelite is now happy to let other programs take turns with the sound card, it still needs exclusive access to the sound card when it is first started in order to determine the capabilities of the card. This, again, was a problem on my KODI boxes where KODI is given exclusive control during the boot process. To work around this we need to tell Squeezelite the maximum sample rate supported by the sound card so that it does not need to look it up.

We can find out the max sample rate supported by the sound card by running squeezelite in debug mode. For this to work, Squeezelite will need access to the sound card so make sure nothing else is using the sound card, then run:

squeezelite -d output=debug

Press Ctrl+C to stop it after a few seconds. We’re looking for the line that contains “supported rates” followed by a bunch of numbers.

We now return to /etc/default/squeezelite and add the max rate information as follows. Replace 192000 with the number from your machine.

sudo nano /etc/default/squeezelite

SB_EXTRA_ARGS="-C 3 -r 192000"

Save the file and restart the service

sudo service squeezelite restart

Hopefully you can now painlessly play music on your machine via squeezebox, KODI or another music player. I’ve found that switching between programs can take 10-20 seconds sometimes so if the music does not start instantly, wait a minute before you give up on it.