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.

3. May 12th, 2013 at 21:32 | #3

When I initially commented I appear to have clicked on the -Notify me when new comments
are added- checkbox and now whenever a comment is added I recieve
four emails with the exact same comment. Is there an easy method you can remove me from that service?
Cheers!

4. May 15th, 2013 at 07:15 | #4

Fantastic website you have here but I was curious about if you knew of any forums that cover the same
topics discussed in this article? I’d really love to be a part of online community where I can get advice from other experienced people that share the same interest. If you have any suggestions, please let me know. Appreciate it!

5. June 5th, 2013 at 19:02 | #5

Hey! This post could not be written any better! Reading through
this post reminds me of my good old room mate! He always kept
Pretty sure he will have a good read. Thanks for sharing!

6. July 27th, 2013 at 04:10 | #6

Aw, this was an exceptionally good post. Spending some time
and actual effort to make a really good article… but what can I say… I put things off a
whole lot and never manage to get anything done.

7. July 29th, 2013 at 19:15 | #7

I am actually grateful to the owner of this website who has
shared this wonderful paragraph at at this place.

8. July 29th, 2013 at 19:21 | #8

Howdy! This post could not be written any better! Going through this post reminds me
I am going to send this information to him.

Pretty sure he will have a great read. I appreciate you for sharing!

9. August 10th, 2013 at 14:49 | #9

Excellent weblog here! Also your website a lot up fast! What web host
I desire my site loaded up as quickly as yours
lol

10. September 10th, 2013 at 23:25 | #10

Hey there I am so grateful I found your webpage, I really
found you by error, while I was browsing on Google for something else,
Regardless I am here now and would just like to say kudos for a marvelous post
and a all round exciting blog (I also love the theme/design),
I don’t have time to look over it all at the moment but I have
book-marked it and also included your RSS feeds, so when I have time I will be back to read a lot
more, Please do keep up the fantastic jo.

11. September 26th, 2013 at 09:05 | #11

I am curious to find out what blog system you’re utilizing?
I’m having some minor security issues with my latest website and I would like to find something more secure.
Do you have any suggestions?

12. November 15th, 2013 at 01:22 | #12

I do not know if it’s just me or if everyone else encountering issues with
your site. It looks like some of the text in your content are running
off the screen. Can somebody else please comment
and let me know if this is happening to them too?
This may be a issue with my browser because I’ve had this happen before.
Appreciate it

13. November 24th, 2013 at 19:10 | #13

Thank you for another informative web site. Where else may just I
get that kind of information written in such a perfect method?

I’ve a mission that I’m just now working on, and I
have been on the glance out for such information.

14. December 4th, 2013 at 16:14 | #14

Great post! We will be linking to this particularly great article on
our site. Keep up the great writing.

15. December 7th, 2013 at 03:36 | #15

This piece of writing will assist the internet users for building up new web site or even a weblog
from start to end.

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