recycledspace.com my laboratory experiment served hot by Benoit Beauchamp

My updated music setup

I’ve updated how I use part of my music system at home from the previous example here. I took inspiration from the following mopidy issue at GitHub.The big difference in how I’ve set it up before is that mopidy now use the audio output and send it to a UDP sink with the following tibits.

[audio]
output = tee name=t ! queue ! autoaudiosink t. ! queue ! udpsink host=127.0.0.1 port=5555

I then use socat to make it a fifo so that forked-daapd can stream it wherever I want. Here is the script that I use to launch it during boot.

#!/bin/bash

createFifo() {
fifo='/srv/music/mopidy.fifo' # this is where my forked-daapd will read it
rm $fifo

mkfifo "$fifo"
while :; do socat -d -d -T 1 -u UDP4-LISTEN:5555 OPEN:"$fifo"; done
}

var=`ps -C socat -F | grep [s]ocat | tr -s " " | cut -d " " -f2`
if [ -z "$var" ]; then
 createFifo
fi

Here is the breakdown of what’s happening in the previous script. I create a simple bash function to make the fifo and make sure to only run it if no other instance of socat is running. If you have another instance of socat running you probably just need to kill that particular instance if it’s not working.

I also created a simple systemd service file to load it up at boot time which I put in /etc/systemd/system/

[Unit]
Description=Startup mopidy udplink to fifo

[Service]
Type=oneshot
ExecStart=/etc/mopidy/startup.sh

[Install]
WantedBy=multi-user.target