Display MoreOk
Thanks awiouy for this awesome addon.
I've sorted this out, I'm leaving my solution for reference BUT also a request first (based on the solution to make it easier for others)
Here's the feature request first
1. Please allow selecting of player option .. (e.g. choose between ALSA and pulse , and probably pipewire at some point)
I needed to edit service snapclient.service to replace the term snapclient with "snapclient --player pulse"
Then when a particular player has been selected, list soundcards according to the player. (see step 3 of my solution)
Here's the solution ..
The problem - plugins not able to play audio if snapclient had been playing music.. (even if stopped at the time)Summary - move to pulse as audio "backend"/abstraction layer to prevent locking of the audio device..
(My experience with Pulse is usually disable it as much as possible as I do professional mixing and mastering, but here, it's really come in handy).Configs
1. autostart.sh to ensure the correct sinks are available and some other settings (to allow ac3 passthrough to my receiver)
Bash Display More#!/bin/sh pactl load-module module-null-sink sink_name="just_a_sink_1" pactl suspend-sink just_a_sink_1 pactl load-module module-allow-passthrough pactl load-module module-udev-detect pactl set-card-profile 0 output:hdmi-stereo pactl set-sink-formats 2 "pcm; ac3-iec61937; dts-iec61937; eac3-iec61937" pactl set-default-sink alsa_output.pci-0000_00_01.1.hdmi-stereo
Pretty sure lines 1 and 2 are redundant - but anyway.. it's working
As for the last line, as I don't use the "default" device in my config, so that is probably also not needed.2. Edit
/storage/.kodi/addons/service.snapclient/bin/snapclient.start
Change the invocation of snapclient to include --player pulse
Code Display MoreHOME="$ADDON_HOME" \ nice -n "$sc_n" \ snapclient \ $sc_H \ --latency "$sc_l" \ $HOST \ --port "$sc_p" \ $sc_S \ > /dev/null
To
Code Display MoreHOME="$ADDON_HOME" \ nice -n "$sc_n" \ snapclient --player pulse \ $sc_H \ --latency "$sc_l" \ $HOST \ --port "$sc_p" \ $sc_S \ > /dev/null
3. Identify correct output (as the GUI still only displays ALSA outputs)
LivingRoom:~/.kodi/addons/service.snapclient/bin # snapclient --player pulse --list
4: default
Let PulseAudio server choose the device
1: just_a_sink_1
Null Output
2: alsa_output.pci-0000_00_01.1.hdmi-stereo
Built-in Audio Digital Stereo (HDMI)
3: alsa_output.pci-0000_00_14.2.iec958-stereo
Built-in Audio Digital Stereo (IEC958)
In this case my choice is 2, which is in the first line of the config file
/storage/.kodi/userdata/addon_data/service.snapclient/settings.xml
Code Display More<settings version="2"> <setting id="sc_s">2</setting> <setting id="sc_addr">snapbuntu</setting> <setting id="sc_p">1704</setting> <setting id="sc_h">livingroom</setting> <setting id="sc_n">2</setting> <setting id="sc_l">640</setting> <setting id="sc_k">true</setting> <setting id="sc_a">true</setting> <setting id="sc_r">2</setting> </settings>
4. Make sure that Kodi is also using the same Pulse Audio device.. I did this via the GUI.. but this is from the guisettings.xml
I was able to switch between
Movie played by Kodi (AC3 passthrough)
Music played by Kodi (PCM stereo)
Video played by the youtube addon (PCM stereo)My snapserver (fed by Mopidy) was sending music the whole time and it was being played out to the speakers via my receiver connected via HDMI.
Everything played nicely for everything and the music popped up in between ..
Looking forward to the summer BBQ season.. and if the kids decide to watch a movie when the evening hits, they can do that and all the other speakers in the house will keep playing to the party.
For reference sake - the is on the generic amd64 buildThe CPU I tested with is
AMD A10-7860K Radeon R7, 12 Compute Cores 4C+8GI have the 2 core version and will test this configuration on that too (although not using HDMI for audio, but spdif, and to a 2.1 system)
Hopefully later I'll also be able to test against an unoficial Rockchip build (ordered for another entertaining area), a device I'll be running headless, so that should be interesting..
These instructions worked on my RPi3B+ too.
I had been having issues where if the system was not shut down nicely, i.e the power was cut then the audio didn't recover.
Using your autostart.sh fixed all this.
Thank you.