# Pulseaudio

## comprookie2000

I am currently using pulseaudio-0.9.15-r51

on a ~amd64 system

Getting Started

First thing I did was add pulseaudio to the global USE in /etc/make.conf

Installation

Next go ahead and get your system up to date.

```

emerge --sync

emerge -avND world

etc-update (or dispatch-conf)

revdep-rebuild 

```

Next lets get pulseaudio installed.

```

echo "media-sound/pulseaudio X alsa avahi dbus hal tcpd -gnome" >> /etc/portage/package.use

emerge -av pulseaudio paprefs pavucontrol padevchooser pavumeter

emerge gst-plugins-pulse

gpasswd -a USER pulse-access

echo "media-plugins/alsa-plugins pulseaudio" >> /etc/portage/package.use

emerge alsa-plugins

```

create ~/.asoundrc file

```

pcm.!default {

    type pulse

}

ctl.!default {

    type pulse

}

```

Configure Pulseaudio

Configure puleaudio by editing the files inside /etc/pulse/

```

client.conf  daemon.conf  default.pa  system.pa

```

I removed all the commented lines for easier viewing.

The first file has everything commented out.

/etc/pulse/daemon.conf

```

use-pid-file = yes

nice-level = -11

no-cpu-limit = no

default-sample-rate = 48000

```

/etc/pulse/default.pa

```

.nofail

load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav

load-sample-lazy pulse-coldplug /usr/share/sounds/startup3.wav

load-sample-lazy pulse-access /usr/share/sounds/generic.wav

.fail

load-module module-device-restore

load-module module-stream-restore

load-module module-card-restore

load-module module-augment-properties

.ifexists module-hal-detect.so

load-module module-hal-detect

.else

load-module module-detect

.endif

.ifexists module-bluetooth-discover.so

load-module module-bluetooth-discover

.endif

.ifexists module-esound-protocol-unix.so

load-module module-esound-protocol-unix

.endif

load-module module-native-protocol-unix

load-module module-zeroconf-publish

.ifexists module-gconf.so

.nofail

load-module module-gconf

.fail

.endif

load-module module-default-device-restore

load-module module-rescue-streams

load-module module-always-sink

load-module module-suspend-on-idle

load-module module-console-kit

load-module module-position-event-sounds

load-module module-cork-music-on-phone

```

/etc/pulse/system.pa

```

.ifexists module-hal-detect.so

load-module module-hal-detect

.else

load-module module-detect

.endif

.ifexists module-esound-protocol-unix.so

load-module module-esound-protocol-unix

.endif

load-module module-native-protocol-unix

load-module module-stream-restore

load-module module-device-restore

load-module module-default-device-restore

load-module module-rescue-streams

load-module module-always-sink

load-module module-suspend-on-idle

load-module module-position-event-sounds

```

Gnome Settings

Set esd to use pulse by :

```

eselect esd list

eselect esd set 2  

```

if pulse audio is number 2.

gnome-volume-control

```

gnome-volume-control

```

select your input and output devices

gstreamer-properties

```

gstreamer-properties

```

select PulseAudio Sound Server

If system sounds like login and logout are not working you can test with;

```

esdplay /usr/share/sounds/login.wav

```

I had to add this to ~./bashrc

```

if [ ! -e /tmp/.esd-${UID} ]; then

    ln -s /tmp/.esd /tmp/.esd-${UID}

fi

```

KDE Setup

I contacted the KDE herd and it is as simple as;

KDE's phonon engine is using either media-libs/xine-lib or gstreamer as a

backend. You need to install either/both of them with pulseaudio USE flag

(media-libs/xine-lib is a default one).

In KDE all you need to do, is go to system-settings -> Multimedia, move

pulseaudio to the top of your list (the only annoying part is, that you need

to do it for each section - Notification, Music, Video, etc - as KDE can use

different audio outputs for everything). That's pretty much it.

Sound and Video Configuration

Important

plugdev dbus

Also either the pulse user needs to be in plugdev, or ;

pulseaudio needs to install a dbus policy file to allow access.

http://pulseaudio.org/ticket/582

audacity

I even have audacity working with dmix for output.

mplayer

I also edited /etc/mplayer/mplayer.conf

```

vo=gl

ao=alsa

fontconfig=1

subfont-osd-scale=4

subfont-text-scale=3

unrarexec=/usr/bin/unrar

```

I set up mplayer to use alsa and it is working so no need to change it to pulse at this time.

user mode vs system mode

This may help to explain user mode / system mode;

http://www.pulseaudio.org/wiki/WhatIsWrongWithSystemMode

Changlog

flameeyes is the expert on pulseaudio so I like to check his changelogs for insight  :Smile: 

```

22 Jun 2009; Diego E. Pettenò  <flameeyes@gentoo.org>

-pulseaudio-0.9.15.ebuild, +pulseaudio-0.9.15-r1.ebuild,

+pulseaudio-0.9.15-r50.ebuild:

Resume with the doubled ebuild for pulseaudio: -r0 to -r49 will keep the

ebuilds without systemwide support, -r50 to -r99 will have it. The reason

for this is that the systemwide support requires OpenRC, which we won't

have stable anytime soon. Still, it requires libtool 2.2, so... 

```

Guides I used

http://duckzland.ismywebsite.com/about/pulseaudio-and-gentoo/

http://pulseaudio.org/wiki/PerfectSetup

http://en.gentoo-wiki.com/wiki/PulseAudio

http://fedorasolved.org/Members/fenris02/pulseaudio-fixes-and-workarounds

http://ubuntuforums.org/showthread.php?t=789578

Tips

At this point in time it is known that the following ALSA sound drivers are broken in regards to "glitch-free" PA: 

    * Some snd-intel8x0 supported chips http://mailman.alsa-project.org/pipermail/alsa-devel/2009-February/014975.html #396 (Seems to be fixed by https://bugzilla.redhat.com/show_bug.cgi?id=472339)

    * All newer Creative chips (snd-emu*) #435

    * snd-intel-hda on some chips (seems to be fixed by https://bugzilla.redhat.com/show_bug.cgi?id=485734)

    * Some snd-ice1712 supported chips #334

    * snd-ens1371 http://mailman.alsa-project.org/pipermail/alsa-devel/2009-February/014929.html

    * snd_es1938 

Possible workarounds to make PA work on these chips are:

    * Disabling glitch-free mode. I.e. pass tsched=0 to the alsa modules or module-hal-detect 

/etc/pulse/default.pa

```

### Automatically load driver modules depending on the hardware available

.ifexists module-hal-detect.so

load-module module-hal-detect tsched=0

.else

```

When the PulseAudio ALSA plugins are active, you must explicitly specify your hardware device in alsamixer (marked in blue above), otherwise it will open the PulseAudio mixer.

My main soundcard

```

alsamixer -Dhw

```

My usb Microphone

```

alsamixer -Dhw:1

```

----------

## casidiablo

Wow... this is so freaking great. I just installed PulseAudio some days ago; had I known about this great guide I'd have saved a bunch of time.

Even tough, I have saved this as favorite.

Thank you so much!

----------

## ursusca

Hello comprookie2000,

Thanks for sharing it. I've installed pulseaudio today following your guide. 

Everything seems to run fine but after typing "skype" in the terminal I got the following message

...  

E: conf-parser.c: [/etc/pulse/client.conf:37] Unknown lvalue 'nice-level'.

E: shm.c: shm_open() failed: Permission denied

*** PULSEAUDIO: Unable to connect: Connection refused

E: conf-parser.c: [/etc/pulse/client.conf:38] Unknown lvalue 'no-cpu-limit'.

E: shm.c: shm_open() failed: Permission denied

...

I've commented all your recommendations from /etc/pulse/daemon.conf. After typing "skype" in the terminal I got the following message:

E: shm.c: shm_open() failed: Permission denied

*** PULSEAUDIO: Unable to connect: Connection refused

E: shm.c: shm_open() failed: Permission denied

*** PULSEAUDIO: Unable to connect: Connection refused

E: shm.c: shm_open() failed: Permission denied

*** PULSEAUDIO: Unable to connect: Connection refused

.....

My skype doesn't work properly now. I can't find "Pulse Audio Server" in skype's options.

Please help

Regards,

----------

## comprookie2000

I don't use skype so can not be of much help, I hope something from   The Perfect Setup #skype  will help. Let us know how it goes and if you have any questions about what they are talking about, ask away. Good Luck with skype.

----------

## luispa

Hi, I was using pulseaudio-0.9.15-r2 on a ~amd64 system, pretty stable. Yesterday I upgraded to 0.9.19 and sound is breaking. Have you updated recently to newer version?

Luis

----------

## comprookie2000

Here is what I am currently using;

```

[ebuild   R   ] media-sound/pulseaudio-0.9.21-r50  

USE="X alsa asyncns avahi bluetooth caps dbus glib hal ipv6 tcpd udev 

-doc -gnome -jack -libsamplerate -lirc (-oss) -test" 

```

Still working pretty good, sometimes I have to run alsaconf after an emerge -uND world. I also have to run pavucontrol as a user sometimes if sound stops or does not sound perfect, but that seems to only happen when I am using a bunch of different sound applications or change usb sound devices. I use a couple different microphones and headsets. Make sure when you run paprefs as user there is nothing checked. I can not remember changing any of the configuration files. If you want to paste your config files, I like this way;

```

 wgetpaste -n dabbott -l Bash .asoundrc

```

Your paste can be seen here: http://dpaste.com/132782/

I can check them out. Let me know how you make out, I am trying to become more knowledgeable in the setting up of pulseaudio because once it becomes widely used there will be many people without sound because of the learning curve from straight alsa with or without esd or arts. Pulseaudio does seem to get better for me with each release, I have it working with everything including audacity now. Sometimes I do lose dmix, dmix is alsa's native mixer that I have to use with audacity. Sometimes when I go to edit a sound file and go to play it the clip will play super fast or stop. I then open audacity and the slider for dmix is gone. If I make sure I close all sound app's and restart audacity it will most times show back up. On a few occasions I have had to restart X. I think flash had messed it up but not sure. Flash plays super, I can play a couple flash videos at the same time if I wanted to, but I don't push my luck. Sound in Linux is still not where I would like it to be.

----------

## luispa

Thank you for your feedback.  By the way, I moved to the latest too: 0.9.21-r50. My setup has been working nicely allways and started to fail just with the update to 0.9.19, and continued to fail with the latest 0.9.21-r50. System sounds, skype, vmware (workstation 7 w/alsa) all starting to play and inmediately stopping, like few miliseconds sounds... 

I've this setup: 

```
 audio card    ---\                             /------ native pulse apps

                   --- alsa/udev --- pulseaudio 

 webcam w/ mic  --/     driver                  \------ alsa ----- native alsa apps

```

Then I either config apps to use ALSA or Pulse, and everything goes through pulseaudio (daemon run as user). I'm using Gnome. 

Thank you for your comments, as knowing it "should" work is good  :Smile: . So, I've been testing a bit and I found the "tsched=0" in my config, which is something I added long ago due to issues I had. Just tested removing it, everything seems to work well again, but still testing. 

See my changes (default.pa):

```
#load-module module-alsa-sink device=hw:0,0 sink_name=altavoces tsched=0

load-module module-alsa-sink device=hw:0,0 sink_name=altavoces

```

Running out of time now, but as soon as I finish the tests and confirm that's the issue I'll post more information, my config, etc.

Thanks again, 

Luis

----------

## luispa

Had some more time. Initial tests shows everything is back to normal.

What I did: 

 *Quote:*   

>  - Recompiled everything that uses pulseaudio (no change, same issue)
> 
>  - Removed "dsched=0" (this one solved the problem)
> 
> 

 

Setup: 

```
 audio card    ---\                             /------ native pulse apps

                   --- alsa/udev --- pulseaudio

 webcam w/ mic  --/     driver                  \------ alsa ----- native alsa apps 

```

- Main Audio: Intel Corporation 82801JI (ICH10 Family) HD Audio Controller

- Used for microphone: USB Logitech WebCam

- Used for TDT Capture: Cinergy HT PCI

Config Pulseaudio:

[*] /etc/pulse/default.pa. Static Configuration, DON'T use HAL, so I assign what I want in the order I want.

[*] /etc/pulse/daemon.conf

[*] I start the daemon from Gnome session with: /usr/bin/start-pulseaudio-x11

Config ALSA:

[*] /etc/modprobe.d/alsa.conf. Fixed cards numbers (same order allways)

[*] .asoundrc. Alsa plays through Pulseaudio

Then, I configure apps to play using Pulse or ALSA.

Luis

----------

## luispa

 *comprookie2000 wrote:*   

> 
> 
> Still working pretty good, sometimes I have to run alsaconf after an emerge -uND world. I also have to run pavucontrol as a user sometimes if sound stops or does not sound perfect, but that seems to only happen when I am using a bunch of different sound applications or change usb sound devices. I use a couple different microphones and headsets. Make sure when you run paprefs as user there is nothing checked. I can not remember changing any of the configuration files. If you want to paste your config files, I like this way;
> 
> 

 

Have you tried not using HAL?, I prefer to configure it manually so I get everything allways in the same place, take a look at my config. 

Btw, Are you running pulseaudio daemon in system-wide mode?.  Not in my case, and working pretty well, note that I'm using Gnome (not your case) and it re-launches it inmediately if process dies for whatever reason

Luis

----------

## Dr.Willy

After reading this guide I got interested in PulseAudio and google'd a bit. 

Ok. Now what I got is that it is kinda like ALSA or OSS exept different. There was one question however which I couldn't answer: Why would I want to install it?  :Razz: 

I assume some PA users visit this thread, so I'd like to know: What awesome stuff can it do that others can't and what are its coolest features?

Enlighten me.

----------

## luispa

 *Dr.Willy wrote:*   

> Why would I want to install it? 
> 
> 

 

Good question  :Smile: . 

I decided to install it long ago. By the time I didn't know much about ALSA, Pulseaudio solved some problems, i.e. multiple sounds at the same time from different apps didn't work for me w/ ALSA.

However, after I made lots of tests trying to understand the whole options, I made a good ALSA setup and discovered that it works pretty well and indeed I wouldn't need PA for my setup. 

I use it because I like my setup and it's already there working pretty well. Also like the GUI apps it offers and the fact that everything goes through it, so troubleshooting is easier (for me).

On the other hand, probably in a different case with the need for multiple features and complex configs I guess it offers much more functionality than ALSA, however I doubt the majority needs such setups, so w/ ALSA should be enough.

OSS is a no-go, in my opinion, not all apps support it and config/troubleshooting is more difficult (more low level). 

My 2cent's: ALSA or Pulse for normal needs, and probably Pulse for "advanced" needs.

Luis

----------

## Bircoph

 *Dr.Willy wrote:*   

> Why would I want to install it?

 

I removed it completely from my system. ALSA is high configurable and sufficient for my needs, so I do not want an additional layer for my system. PulseAudio is not ALSA replacement, it is waste of CPU and memory resources for nothing.

As far as I understand the idea of PulseAudio, it tries to dynamically adjust sound levels of all applications running depending on what are you doing now. I do not need this, really. I do not use sound alerts in my instant messengers or mail clients, because I do not want them to interrupt my work when I do not need them, so nothing can interrupt my movie viewing.

And I really hate additional layers actually needed for nothing useful like pulseaudio, hal, consolekit. They are just eaters of your system resources and any program may be easy written without them.

----------

## HB2

Thanks  !   :Wink: 

----------

## Dr.Willy

that ... doesn't sound quite encouraging so far

----------

## Mageta

 *Bircoph wrote:*   

>  *Dr.Willy wrote:*   Why would I want to install it? 
> 
> I removed it completely from my system. ALSA is high configurable and sufficient for my needs, so I do not want an additional layer for my system. PulseAudio is not ALSA replacement, it is waste of CPU and memory resources for nothing.
> 
> As far as I understand the idea of PulseAudio, it tries to dynamically adjust sound levels of all applications running depending on what are you doing now. I do not need this, really. I do not use sound alerts in my instant messengers or mail clients, because I do not want them to interrupt my work when I do not need them, so nothing can interrupt my movie viewing.
> ...

 

Well, as long as your apps ONLY use native alsa (you activated the use flag and/or you configured them like this), there should rly be no reason to install pulse. On my old laptop I used to handle it like this.

With a new enough kernel and a good conf., even multiple apps could play their sound through alsa and everyone was happy (IF there were only apps who used alsa).

But.. if there is an evil app who still uses oss or esd or something ugly like this.. your whole alsa-setup is blown up. I never got this to work, alsa-apps + oss-apps at the same time (oh and it is easy to get this done. Once I wanted to play heroes3 with a friend and we both used teamspeak2. HA!.. games without sound are lame..). Theoretically this should work with pulse (I should test this sometimes).

But I agree with your opinion that all these additional layers are resource-killing monsters.

@Dr.Willy:

As far as I understood it.. all "old" and current sound-systems, like alsa, oss, esd,... provided devices within /dev/ (like /dev/dsp is/was provided by oss), with which your apps could speak, if they wanted to play something that you should hear (some sounds  :Wink: ). But while one app was playing something through one of these provided devices no other app could use it (the second app keeps silent). This is like it was in my case, with heroes3+teamspeak2.

With use of pulse, this should not happen anymore. All these devices in /dev/ keep existing and all the old apps can keep using their depreciated interfaces (like oss  :Wink:  ). BUT if an app connects to one of these devices the communication gets redirected to pulse and pulse tells the app "you can use me now and you can use me alone" but it handles the specific app in its own stream. Meanwhile other apps can do the same request on the same device and get also handled by pulse. All can play their sound, at the same time. Even "alsa-devices" can be handled like this (all new apps, which are alrdy using alsa natively).

That should be the main purpose for using some daemons like pulse. If you have no old software or you never use 2 sound playing application at the same time, you will never need pulse. It would be like hal on an pentium1-based system.. 

regards,

- mageta

----------

## ursusca

 *comprookie2000 wrote:*   

> I don't use skype so can not be of much help, I hope something from   The Perfect Setup #skype  will help. Let us know how it goes and if you have any questions about what they are talking about, ask away. Good Luck with skype.

 

Hi comprookie2000,

Thank you for attention to my question. net-im/skype 2.1.0.81 works fine.  :Smile: 

----------

## kiboko

Great post! Helped me figure it all out.

----------

