Home > linux > pulseaudio – quick’n’dirty playback over the network

## pulseaudio – quick’n’dirty playback over the network

The joyful lives of many Linux desktop users are clouded by many packages and frameworks that are well-intentioned and try to solve real and painful problems, but which are immature, not designed in the UNIX spirit, poorly documented and most importantly, do not really have a working implementation. Oh well. I have taken the stance of patience and ascetic acceptance of the new burdens – instead of trying to purge my systems of all that is unholy and evil, I spend that time trying to debug and fix up the problems they incur (often in vain). Sometimes I even file bugs, but that can be rather… unrewarding experience – more about that at another time.

So, I have two OpenSUSE 11.2 machines – a notebook with GNOME and a workstation with KDE 4.2 and some real speakers. My notebook uses PulseAudio semi-automagically, but after many perpetual problems with pulseaudio, phonon, java and flash, I really gave up on the workstation and turned pulseaudio off. However, it is desirable to coil up in the bed and watch a movie on the notebook while NOT listening to the notebook speakers. So I want to play sound over the network, notebook to workstation.

What to do on the notebook:

$echo default-server =$IP_of_workstation >>/etc/pulse/client.conf
$mplayer -ao pulse ... That was easy. Your girlfriend watches you type along over your head. What to do on the workstation? Surely that will also be piece of cake! $ echo load-module module-native-protocol-tcp auth-anonymous=1 >>/etc/pulse/default.pa
$pulseaudio -v Ok. Try to fire up mplayer and… it’s all silent! You stare at the log for a bit, then you see it: I: sink-input.c: Created input 0 "audio stream" on alsa_output.pci-0000_01_00.1.hdmi-stereo with sample spec s16le 2ch 44100Hz and channel map front-left,front-right But, that’s wrong! There is nothing hooked up on the HDMI! The speakers are analog. Why is it playing over the HDMI? You click around a bit, google around a bit, nothing comes up. Your girlfriend stirs impatiently. You go through the log, see that pulseaudio first sees the HDMI sink, then the analog sink. Hm. You find the set-default-sink command somewhere and do $ echo set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo >>/etc/pulse/default.pa

Pulseaudio restart. Nice red message:

E: main.c: Sink alsa_output.pci-0000_00_1b.0.analog-stereo does not exist

Aha! Pulseaudio sees HDMI right away, sets it up, _then_ finishes initializing and prints this error, and only about two seconds later it goes all “oh, look, there’s another card plugged in here!”. What the heck?

At this point, you either give up or try to google around again madly. After 10 minutes, while your girlfriend is browsing DeviantArt bored, sound finally comes from the speakers after you figure out to issue

pacmd  'set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo'

while having a running pulseaudio.

You will probably need to have a dbus connection to your pulseaudio if you want to do this. If you are setting up the workstation remotely, you need to either create your own dbus session or hook up to a running one if you are logged in physically as well. This is a very simple, user friendly step:

$ps axu ... chidori 3036 0.0 0.4 151192 16564 ? S 09:40 0:00 kdeinit4: kded4 [kdeinit] ...$ cat /proc/3036/environ | tr '\0' '\n' | grep DBUS
\$ export cat /proc/3036/environ | tr '\0' '\n' | grep DBUS

Yay, what a nice, user-friendly, easy to set up piece of software we have here.

(BTW, the movie stutters every two minutes or so anyway; another time I feel shiny and optimistic, I will try to figure out if using some compression for the network audio is possible nowadays.)

Categories: linux Tags:
1. May 24th, 2010 at 17:27 | #1

Hi,

nice guide, I had to try it. So it generaly works very well, I had no problem with selecting sink because I have only notebook with simple analog sound card. We tried this with roommate on college, both with Ubuntu 10.04. But what nice we discovered is this: when some app starts with defined remote server, it connect to them and keep connection until it close, its normal behavior, but we wanted changing local/remote playing in “realtime” without closing application (and changing conf file). We done this using “module-tunnel-sink”, which creates new virtual output sink, that is connected to remote server. So you can let all application to connect to your local server and then you can easily (by pactl or in latest ubuntu by sound-applet) change output sink in realtime ;) (see pulseaudio wiki about this module)

2. June 7th, 2010 at 09:43 | #2

I have old machines (Pentium 1) used as X11 terminals. I gave a try to pulseaudio. Not a chance: the pusleadio server consumed whole CPU and suicided with a complain about no free CPU cycles.

Thus I returned to esound that worked at acceptable level. I tested nasd too but it had bad delay or crashed spontaneously.

1. May 22nd, 2010 at 21:03 | #1
2. August 17th, 2010 at 15:55 | #2

7 − = two