Rene´s blog

Blogging about Programming, Security, Linux, Networking and Web Apps.

Pulseaudio as network audio sender/receiver

I use Pulseaudio to send my audio to a different computer where i have a sound system plugged in,
and i switch between computers with sound stations.

This howto will help you to create you’r own OSS Network audio sender and receiver.

This is what i do on each receivers (servers)

You might want to change to your own IPv4 subnet you want allow to send audio.

mkdir $HOME/.pulse
cp /etc/pulse/default.pa $HOME/.pulse
echo "load-module module-native-protocol-tcp auth-ip-acl=;" >> $HOME/.pulse/default.pa
pulseaudio --kill
sleep 2
pulseaudio -D

On the sender (client)

On the client i create multible configurations, change to your name you want. (like home/company/friend).

mkdir $HOME/.pulse
cp /etc/pulse/client.conf $HOME/.pulse/client-nonet.conf
cp /etc/pulse/client.conf $HOME/.pulse/client-<name>.conf
echo "default-server =" >> $HOME/.pulse/client.conf

Receiver switch script (on the client)

I use this script to change between receivers, sometimes i need to call it twice to work.

mkdir $HOME/bin
source $HOME/.bashrc

cat << 'EOF' > $HOME/bin/pulseswitch

if test -z "$1"; then
  echo "USAGE: pulseswitch [nonet|<your-config>]"
  exit 1

echo "Switching to \"$1\"."
/bin/ln -fs $HOME/.pulse/client-$1.conf $HOME/.pulse/client.conf
/usr/bin/pulseaudio --kill
/usr/bin/pulseaudio -D
if [ "x$1" = "xnonet" ]; then
        echo "Unloading the net module."
        /usr/bin/pactl unload-module module-native-protocol-tcp
        echo "Loading the net module."
        /usr/bin/pactl load-module module-native-protocol-tcp
/usr/bin/pulseaudio --kill
/usr/bin/pulseaudio -D