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
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wYzWEttyro,guid=28e3a1c77f077a230071a5974be666db
$ 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.)

  1. DocX
    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. petr_p
    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.

  3. July 7th, 2014 at 03:47 | #3

    Good blog you have got here.. It’s difficult to find high
    quality writing like yours nowadays. I seriously appreciate
    people like you! Take care!!

  4. July 15th, 2014 at 09:29 | #4

    If you are going for best contents like me, just pay a visit this website every day as
    it offers feature contents, thanks

  5. August 15th, 2014 at 05:25 | #6

    If you want to build teamwork, you will definitely want to practice together, of
    course. So, strap on all your paintball load and
    gear up those paintball guns! If” scenarios, and more, work on offensive and defensive strategies, code words, “what-.
    Learn from the opposition together with your own teammates.
    Tightly discover other paintball participants to build up new and winning strategies for future
    online games. Does the opposition group discuss more than your
    crew does? Do they really appear far more structured?
    Watching the way your foes come together can help improve your team’s overall performance.
    If your team is lacking in that area, take a look at your opponents paintball gear and see.
    This can tremendously result your gameplay

  6. August 15th, 2014 at 21:31 | #7

    Hey there. I was considering adding a backlink back to your website since
    both of our websites are based around the same subject.

    Would you prefer I link to you using your website address: http://log.or.cz/?p=86&cpage=1 or
    website title: Pasky’s Log » pulseaudio. Please let me know at your earliest convenience.
    Cheers

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