I wasn’t clear, I think. I don’t want to send Kodi’s output to snapcast, just the A2DP sink. I don’t have any music configured in Kodi, just video.
I was able to get it working as I had wanted to over the weekend - so in case it comes up for anybody else, it was a three step process:
- Define a named pipe in snapcast - refer to the snapcast documentation for more info there:
source = pipe:///tmp/bluefifo?name=Bluetooth
- Create /etc/asound.conf with the following, or I suppose you could just append this to an existing asound.conf:
pcm.bluetooth {
type plug
slave.pcm rate48000Hz
}
pcm.rate48000Hz {
type rate
slave {
pcm writeFile # Direct to the plugin which will write to a file
format S16_LE
rate 48000
}
}
pcm.writeFile {
type file
slave.pcm null
file "/tmp/bluefifo"
format "raw"
}
- Edit /lib/systemd/system/bluealsa-aplay.service to redirect the output of bluealsa-aplay to the “bluetooth” pcm device in the asound.conf instead of the system-wide default pcm device:
[Unit]
Description=A2DP Playback
After=bluealsa.service syslog.service
Requires=bluealsa.service
StopWhenUnneeded=true
[Service]
ExecStartPre=/bin/sleep 3
ExecStart=/usr/bin/bluealsa-aplay -D bluetooth --profile-a2dp 00:00:00:00:00:00
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=A2DP-Playback
Restart=on-failure
[Install]
WantedBy=bluetooth.target
I suppose if you’re not also running the snapcast client on the OSMC system you could just define the pcm device as the default device (pcm.!default instead of pcm.bluetooth) and then you wouldn’t have to edit the service file. But in my case I am, and that worked up to a point. As soon as I unmuted the snapcast client on the OSMC system it fed its output right back into the named pipe which made things interesting to say the least. Defining another pcm device worked around that issue.
None of this seems to affect OSMC’s audio output in any way.