Forwarding audio elsewhere on Linux

From: Configuring Sound on Linux/Pulse Audio/Remote server – Wikibooks, open books for an open world

RTP

RTP streams use multicast IP adresses like 224.0.0.56 (default) and UDP datagrams for transport. Multicasts are generally not allowed in Internet (blocked by ISPs). RTP is designed for low latency.

Server

 $ pactl load-module module-rtp-recv

Client

VLC
RTP docs

TCP

Only uncompressed audio is supported.

Configuring the Server

This process is rather simple. You will need to load module-native-protocol-tcp. You can optionally specify an auth-ip-acl to permit/blacklist anonymous connections from specific ips or IP ranges (to list more than one, separate by semicolon).

$ pactl load-module module-native-protocol-tcp auth-ip-acl=192.168.1.138

Configuring the Client

Simply set the environmental variable PULSE_SERVER to the destination and PulseAudio will redirect the stream over tcp to the provided destination.

$ PULSE_SERVER=192.168.1.146 totem

Note, the audio server is the workstation where the audio speakers actually are

And from https://superuser.com/questions/231920/forwarding-audio-like-x-in-ssh

While it is possible to use X applications remotely by using -X switch in ssh, the sound is being played in remote machine’s speaker only. For example if I view a film in VLC/Totem only video is visible and I can’t hear the audio. Is there a way to forward audio too? [without digging through Pulse-audio’s setup, I mean; Like how ssh understands X forwarding by itself.]

The easy way: Run paprefs, go to Network Server and check Enable network access to local sound devices.

Whenever you SSH with X11 forwarding enabled, PulseAudio programs use X11 to discover your sound server (use pax11publish or xprop -root PULSE_SERVER to see for yourself). Just tell PulseAudio to listen for network connections (paprefs as described above), and all X11 programs will be able to use it.

(Other users will not have access to your sound server, unless you allow it yourself in paprefs. The authentication data is carried over in the X11 PULSE_COOKIE property, or you can copy ~/.pulse_cookie manually.)

Note however, that the PulseAudio stream is not encrypted this way, so it is okay for use at home, but not over the Internet.


The slightly more complicated way: Enable network access as above, but tunnel PulseAudio over SSH TCP forwarding. Use pax11publish to discover your PulseAudio port (usually 4713), connect with ssh -R 24713:localhost:4713, then run export PULSE_SERVER="tcp:localhost:24713". This will be slightly slower due to SSH overhead, but is safe to use over the Internet.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.