This is my preferred, working solution. It is based on: pulsertp-multiroom
https://github.com/mada3k/pulsertp-multiroom/blob/master/scripts/pulsertpm-start.sh
I am using this to send audio to multiple receivers (different rooms). There are two lines, noted below, which make the sender a receiver too and solve this question. They are:
- module-rtp-send with the sender's only IP address
- module-rtp-recv with the sender's only IP address
The advantage of this approach is that all receivers (including the one on the sender) stay in sync. That was not the case when combining syncs as in my other answer.
After editing to enter the correct IP addresses, I run this script on the sender when ready to start up RTP unicasting:
#!/bin/bash
#
# PulseRTP-multiroom
# Loads RTP sender modules to setup multiroom audio at request
#
# Notes
# * If you have issues, and have multiple network interfaces, add source_ip= with you prefered local IP
# * mtu=1408 is good initial value. It makes room for 352 PCM frames in 16/44.1k.
#
pa_rtp_mtu=1408
pa_sink="rtpsink1"
echo "timedatectl status:"
timedatectl status --no-pager | grep 'NTP service: active'
if [[ $? -ne 0 ]]; then
timedatectl set-ntp true
sleep 2
timedatectl status --no-pager | grep 'NTP service: active'
if [[ $? -ne 0 ]]; then
echo "WARNING: NTP service not active"
else
echo "timedatectl status OK"
fi
fi
pacmd list-modules | grep module-native-protocol-unix
if [ $? -ne 0 ]; then
pactl load-module module-native-protocol-unix
fi
pacmd list-modules | grep module-default-device-restore
if [ $? -ne 0 ]; then
pactl load-module module-default-device-restore
fi
pacmd list-modules | grep module-rescue-streams
if [ $? -ne 0 ]; then
pactl load-module module-rescue-streams
fi
pacmd list-modules | grep module-always-sink
if [ $? -ne 0 ]; then
pactl load-module module-always-sink
fi
pacmd list-modules | grep module-intended-roles
if [ $? -ne 0 ]; then
pactl load-module module-intended-roles
fi
pacmd list-modules | grep module-suspend-on-idle
if [ $? -ne 0 ]; then
load-module module-suspend-on-idle
fi
#hardcoded addresses of each receiver:
pactl load-module module-rtp-send source=${pa_sink}.monitor mtu=${pa_rtp_mtu} destination_ip=192.168.0.1 #this is the sender's IP address (see below)
pactl load-module module-rtp-send source=${pa_sink}.monitor mtu=${pa_rtp_mtu} destination_ip=192.168.0.2
pactl load-module module-rtp-send source=${pa_sink}.monitor mtu=${pa_rtp_mtu} destination_ip=192.168.0.3
pactl load-module module-rtp-send source=${pa_sink}.monitor mtu=${pa_rtp_mtu} destination_ip=192.168.0.4
pactl load-module module-rtp-send source=${pa_sink}.monitor mtu=${pa_rtp_mtu} destination_ip=192.168.0.5
On each receiver:
pactl load-module module-rtp-recv sap_address=192.168.0.X
Use the receiver's actual IP address, e.g., 192.168.0.2
Finally, on the sender, make it a receiver too:
pactl load-module module-rtp-recv sap_address=192.168.0.1
You can make the configuration on the receivers permanent by editing /etc/pulse/default.pa
To stop RTP casting to the receivers, run this script on the sender:
#!/bin/bash
#
# PulseRTP-Multiroom
# Unloads RTP sender modules to avoid unnecessary bandwidth hogging
#
pa_sink="rtpsink1"
IFS=$'\n'
for rtpn in `pactl list modules short|grep ${pa_sink}`; do
PAM_ID=`echo $rtpn|awk '{print $1}'`
pactl unload-module $PAM_ID
echo " * unload-module id $PAM_ID done"
done
For starting and stopping music play, no changes are needed on the receivers. Their config can be made permanent. I did not have the need to make any permanent config changes on the sender with my modified version of the start script above.
module-rtp-recv
on the sender, too?module-rtp-recv
on the sender. I'll try that. Thanks. However, my bigger problem now is that each receiver is out of sync by a full second or more.module-rtp-recv
on the sender did not solve the issue for me. Is that something that you have used? If you are sure it works, I'll keep trying with that method.