Run Snapcast (client) as a Kodi addon/service on Libreelec 8.
Snapcast (https://github.com/badaix/snapcast) is a multi-room audio player. This addon implementation installes the snapclient, ie the 'speaker' part, as a Kodi service addon.
The addon will keep the snapclient running while Kodi is up but, as someone uses Kodi to play anything the snapclient will be disabled.
Most users will install the addon from a prebuilt release:
- Download a relase here, note: one of the service.snapcast-.zip files, not the source.
- Copy it into the RPi filesystem
- Use Kodi to install from a .zip file
The addon only instanciates snapclient running on the default alsa interface. For this to work you will probably need to make the hdmi interface visible in alsa.
To do this you need to edit config.txt (Libreelec/Openelec specific):
$ mount -o remount,rw /flash
$ nano /flash/config.txt
Append the following line at the bottom:
dtparam=audio=on
Save the file and remount:
$ mount -o remount,ro /flash
Reboot, you should now see your interfaces when doing a 'aplay -L' or '.kodi/addons/service.snapcast/bin/snapclient -l'
In Libreelec 8.2 (perhaps before) you will get a mix of the snapcast and kodi output, ie non-locking access to alsa device.
I run two snapclient instances, one for my HDMI and one for my Digi+ S/PDIF. To enable additional instances you will manually add it, check out the sample snapclient.service.sample file in .kodi/addons/service.snapcast/system.d
You can do something like (Libreelec/Openelec specific):
$ cd .kodi/addons/service.snapcast/system.d
$ cp snapclient.service.sample snapclient.service
$ systemctl enable `pwd`/snapclient.service
$ systemctl start snapclient.service
and do any configuration you want in the default/snapclient file. Note that updating the addon will remove everything in the service.snapcast directory, ie take a backup.
The snapserver is included, to run it check out the snapserver.service.sample file in .kodi/addons/service.snapcast/system.d
You can do something like:
$ cd .kodi/addons/service.snapcast/system.d
$ cp snapserver.service.sample snapserver.service
$ systemctl enable `pwd`/snapserver.service
$ systemctl start snapserver.service
and do any configuration you want in the default/snapserver file.
To compile this addon you need to:
Clone Libreelec:
$ git clone https://github.com/LibreELEC/LibreELEC.tv.git
Create submodule service.snapcast:
$ cd LibreELEC.tv/packages/addons/service
$ git submodule add https://github.com/frafall/service.snapcast.git snapcast
Build it:
$ cd Libreelec.tv
$ scripts/create_addon snapcast
- Configuration in Kodi
- Move defaults to persistent storage (through addon upgrades)
- Look into 'native' Kodi audio integration. Kodi AirTunes uses a pipe and a play command with pipe path url, can probably do the same.
- Wish for metadata support in Snapcast to be able to display in Kodi.
Thanks
Thanks to Anton Voyl (awiouy) for the wrapping of Librespot which I've used to learn about service addons.