PulseAudio (Português)

From ArchWiki
Revision as of 23:48, 2 December 2010 by MasT3R (Talk | contribs) (Tradução parcial da versão inglesa do dia 02/12/2010. Provavelmente precisa de revisão, mas acabar a tradução é mais importante.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

PulseAudio é um servidor de áudio para sistemas POSIX e Win32. Seu recurso mais básico é mixar o som de diferentes programas juntos, permitindo a reprodução de diversos sons de uma vez.

Instalação

Todos os pacotes são do repositório community, então você precisa habilitá-lo primeiro. Depois para instalar o PulseAudio:

# pacman -S pulseaudio

Opcionalmente você pode instalar alguns frontends escritos em GTK:

# pacman -S paprefs pavucontrol

Executando

O PulseAudio pode ser iniciado usando:

$ pulseaudio --start

Ou se você usa o X11:

$ start-pulseaudio-x11

Você pode parar o PulseAudio usando:

$ pulseaudio --kill

Note que em alguns Desktops Environments como o KDE e o GNOME, o PulseAudio será iniciado durante o login. Veja a sessão Desktop Environments para mais detalhes.

Configuração dos Backends

ALSA

Para aplicativos que não suportam o PulseAudio mas suportam o ALSA é recomendado instalar o plugin do PulseAudio para o ALSA. O jeito mais simples de fazê-lo é instalando o pacote pulseaudio-alsa.

# pacman -S pulseaudio-alsa

Esse pacote inclui o Template:Filename necessário para configurar o ALSA para usar o PulseAudio.

Se você usa o Arch x86_64 e quer ter som em programas 32-bits (como o Wine), lembre-se de instalar o lib32-libpulse e o lib32-alsa-plugins também.

Para evitar que aplicativos usem a emulação do OSS via ALSA e assim transpassando o PulseAudio (prevenindo outros aplicativos de tocar som), remova o módulo Template:Codeline executando:

# rmmod snd_pcm_oss

Depois, coloque o módulo na lista negra (blacklist) adicionando Template:Codeline na parte MODULES do arquivo Template:Filename.

OSS

Existem várias maneiras de fazer programas que só funcionam com OSS rodarem no PulseAudio:

osspd

Esse é o jeito mais simples.

Instale o ossp e inicie-o digitando:

# /etc/rc.d/osspd start

Depois, adicione-o na linha DAEMONS do arquivo Template:Filename.

padsp wrapper

Se você tem um programa que usa o OSS você pode fazê-lo funcionar com o PulseAudio iniciando-o com o padsp:

$ padsp OSSprogram

Alguns exemplos:

$ padsp aumix
$ padsp sox foo.wav -t ossdsp /dev/dsp

Se você preferir você pode renomear seu programa OSS e substituí-lo com um script como esse: Template:File

GStreamer

Para fazer o GStreamer usar o PulseAudio, execute Template:Filename (parte do pacote gnome-media) e selecione Servidor de som PulseAudio tanto na Saída como Entrada padrão. Alternativamente, isso pode ser feito setando as variáveis Template:Codeline para pulsesink e Template:Codeline para pulsesrc no gconf2:

 $ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink
 $ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc

Algumas aplicações (como o Rhythmbox) ignoram a propriedade audiosink, usando a propriedade musicaudiosink, que não pode ser configurada usando o Template:Filename e precisa ser setada manualmente usando o Template:Filename ou Template:Filename:

 $ gconftool-2 -t string --set /system/gstreamer/0.10/default/musicaudiosink pulsesink

OpenAL

OpenAL deve usar o PulseAudio por padrão, mas você pode configurar explicitamente para usá-lo em: Template:File

libao

Edite o arquivo de configuração do libao: Template:File

PortAudio

A versão atual do PortAudio no repositório community não suporta o PulseAudio. Isso pode ser arrumado compilando o PortAudio do ABS e aplicando esse patch a patch ao código.

ESD

PulseAudio substitui o enlightened sound daemon (ESD). Enquanto o PulseAudio estiver rodando, clientes ESD devem ser capazes de usá-lo sem configurações adicionais.

Desktop Environments

X11 geral

Inicie o PulseAudio depois do X usando:

$ start-pulseaudio-x11

Isso vai iniciar o PulseAudio e os plugins do X11.

No KDE você pode usar o comando:

$ start-pulseaudio-kde

Isso permite que você veja cada um dos dispositivos de áudio no Configurações do sistema->Multimídia.

Se você usa o GNOME ou KDE, o PulseAudio será iniciado automaticamente.

X11 bell

Para fazer o PulseAudio tocar um som quando um evento do X11 acontecer (ex.: fazer seu terminal fazer 'Ping!' ao invés de 'Beep!'), adicione o seguinte no Template:Filename:

load-sample-lazy x11-bell /usr/share/sounds/freedesktop/stereo/dialog-error.ogg
load-module module-x11-bell sample=x11-bell 

Você também pode usar outro som. Template:Filename faz parte do pacote sound-theme-freedesktop.

GNOME

Para obter tntegração completa do GNOME com o PulseAudio você deve instalar os seguintes pacotes:

  • gnome-media-pulse
  • gnome-settings-daemon-pulse
  • libcanberra-pulse

Eles fazem parte do grupo pulseaudio-gnome.

KDE 3

PulseAudio não é um substituto para o aRts. Se você usa o KDE3 não é possível usar o PulseAudio por enquanto.

KDE 4 e Qt4

Se você instalou o PulseAudio, tudo que você precisa fazer é ir em "Configurações do sistema -> Multimídia -> Phonon -> Preferência do dispositivo" e mudar tudo para PulseAudio.

Applications

Audacious

Audacious natively supports PulseAudio. In order to use it, in Audacious you should set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.

mpd

If you don't want to use the libao output, there is a PulseAudio enabled version of mpd called mpd-pulse in the AUR.

# yaourt -S mpd-pulse

Alternatively, you can rebuild the original updated package from ABS modifying the PKGBUILD, using --enable-pulse:

# yaourt -Sb mpd 

You will need to configure mpd to use PulseAudio.


If you run a system-wide daemon, you will need to add the mpd user to the pulse-access group in order for mpd to connect to the daemon.

On a desktop, running mpd as yourself and not using the mpd user is preferred.

MPlayer

MPlayer natively supports PulseAudio output with the "-ao=pulse" option. It can also be configured to default to PulseAudio output, in Template:Filename for per-user, or Template:Filename for system-wide: Template:File

Alternative configurations

Surround sound systems

Many people have a surround card, but have speakers for just two channels, so PulseAudio cannot really default to a surround setup. To enable all the channels, edit Template:Filename: uncomment the default-sample-channels line (i.e. remove the semicolon from the beginning of the line) and set the value to 6 if you have a 5.1 setup, or 8 if you have 7.1 setup etc.

# Default
default-sample-channels=2
# For 5.1
default-sample-channels=6
# For 7.1
default-sample-channels=8

After doing the edit, you will need to restart Pulseaudio.

Advanced ALSA Configuration

In order for ALSA to use PulseAudio it needs a special Template:Filename (system wide settings) (recommended) or Template:Filename (settings on a per user basis): Template:File

If you omit the last two groups, Pulseaudio will not be used by default. You will then need to change the ALSA device to "pulse" in the applications that you use to make it work.

ALSA Monitor source

To be able to record from a monitor source (a.k.a. "What-U-Hear", "Stereo Mix"), use Template:Codeline to find out the name of the source in Pulseaudio (e.g. Template:Codeline). Then add lines like the following to Template:Filename or Template:Filename:

pcm.pulse_monitor {
  type pulse
  device alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
}

ctl.pulse_monitor {
  type pulse
  device alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
}

Now you can select Template:Codeline as a recording source.

PulseAudio over network

One of PulseAudio's magnificent features is the possibility to stream audio from clients over TCP to the server running the PulseAudio daemon, allowing sound to be streamed through your LAN.

To accomplish this, one needs to enable module-native-protocol-tcp, and copy the pulse-cookie to the clients.

TCP support (networked sound)

To enable the TCP module, add this to (or uncomment, if already there) Template:Filename:

load-module module-native-protocol-tcp

To allow remote connections to the TCP module, you also have to remember to unblock the service in Template:Filename with the following line:

pulseaudio-native: ALL

Zeroconf (Avahi) publishing

For the remote Pulseaudio server to appear in the PulseAudio Device Chooser (Template:Filename), you will also need to add the Template:Filename to the DAEMONS in rc.conf on both server and clients.

Switching the PulseAudio server used by local X clients

To switch between servers on the client from within X, the Template:Codeline command can be used. For example, to switch from the default server to the server at hostname foo:

$ pax11publish -e -S foo

Or to switch back to the default:

$ pax11publish -e -r

Note that for the switch to become apparent, the programs using Pulse must be restarted.

Pulseaudio through JACK

The JACK-Audio-Connection-Kit is popular for audio work, and is widely supported by Linux audio applications. It fills a similar niche as Pulseaudio, but with more of an emphasis on professional audio work. In particular, audio applications such as Ardour and Audacity (recently) work well with Jack.

Pulseaudio provides module-jack-source and module-jack-sink which allow Pulseaudio to be run as a sound server above the JACK daemon. This allows the usage of per-volume adjustments and the like for the apps which need it, play-back apps for movies and audio, while allowing low-latency and inter-app connectivity for sound-processing apps which connect to JACK. However, this will prevent Pulseaudio from directly writing to the sound card buffers, which will increase overall CPU usage.

To just try PA on top of jack you can have PA load the necessary modules on start:

pulseaudio -L module-jack-sink -L module-jack-source

To use pulseaudio with JACK, JACK must be started up before Pulseaudio, using whichever method you prefer. Pulseaudio then needs to be started loading the 2 relevant modules. Edit Template:Filename, and change the following region:

### Load audio drivers statically (it is probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Alternatively use the static hardware detection module (for systems that
### lack udev support)
load-module module-detect
.endif

to the following:

### Load audio drivers statically (it is probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink
load-module module-jack-source
load-module module-jack-sink

### Automatically load driver modules depending on the hardware available
#.ifexists module-udev-detect.so
#load-module module-udev-detect
#.else
### Alternatively use the static hardware detection module (for systems that
### lack udev support)
#load-module module-detect
#.endif

Basically, this prevents module-udev-detect from loading. module-udev-detect will always try to grab your sound-card (JACK has already done that, so this will cause an error). Also, the jack source and sink must be explicitly loaded.

QjackCtl with Startup/Shutdown Scripts

Using the settings listed above you can use QjackCtl to execute a script upon startup and shutdown to load/unload PulseAudio. Part of the reason you may wish to do this is that the above changes disable PulseAudio's automatic hardware detection modules. This particular setup is for using PulseAudio in an exclusive fashion with JACK, though the scripts could be modified to unload and load an alternate non-JACK setup, but killing and starting PulseAudio while programs might be using it would become problematic.

The following example could be used and modified as necessary as a startup script that daemonizes PulseAudio and loads the padevchooser program (optional, needs to be built from AUR) called Template:Filename:

#!/bin/bash
#Load PulseAudio and PulseAudio Device Chooser

pulseaudio -D
padevchooser&

as well as a shutdown script to kill PulseAudio and the Pulse Audio Device Chooser, as another example called Template:Filename also in the home directory:

#!/bin/bash
#Kill PulseAudio and PulseAudio Device Chooser

pulseaudio --kill
killall padevchooser

Both scripts need to be made executable:

chmod +x jack_startup jack_shutdown

then with QjackCtl loaded, click on the Setup button and then the Options tab and tick both "Execute Script after Startup:" And "Execute Script on Shutdown:" and put either use the ... button or type the path to the scripts (assuming the scripts are in the home directory) Template:Filename and Template:Filename making sure to save the changes you have made.

Pulseaudio through OSS

Add the following to Template:Filename:

 load-module module-oss

Then start Pulseaudio as usual. You should have sinks and sources for your OSS devices.

Pulseaudio from within a chroot (ex. 32-bit chroot in 64-bit install)

Since a chroot sets up an alternative root for the running/jailing of applications, pulseaudio must be installed within the chroot itself (Template:Codeline within the chroot environment).

Pulseaudio, if not set up to connect to any specific server (this can be done in Template:Filename, through the PULSE_SERVER environment variable, or through publishing to the local X11 properties using module-x11-publish), will attempt to connect to the local pulse server, failing which it will spawn a new pulse server. Each pulse server has a unique ID based on the machine-id value in Template:Filename. To allow for chrooted apps to access the pulse server, the following directories must be mounted within the chroot:-

/var/run
/var/lib/dbus
/tmp
~/.pulse

Template:Filename should also be mounted for efficiency and good performance. Note that mounting /home would normally also allow sharing of the Template:Filename folder.

For specific direction on accomplishing the appropriate mounts, please refer to the wiki on installing a bundled 32-bit system, especially the additional section specific to Pulseaudio.

Troubleshooting

No sound after install

No cards

If PulseAudio starts, run Template:Codeline. If no cards are reported, make sure that your ALSA devices are not in use:

$ fuser -v /dev/snd/*
$ fuser -v /dev/dsp

Make sure any applications using the pcm or dsp files are shut down before restarting PulseAudio.

Muted audio device

If you experience no audio output via any means while using ALSA as your default device, you may have to unmute your sound card. To do this, you will want to launch alsamixer and make sure each column has a green 00 under it (this can be toggled by pressing 'm')

$ alsamixer -c 0

Sometimes the snd_pcsp driver conflicts with the snd_hda_intel driver (for those of you using Intel cards) and no sound output is experienced. To fix this, you can blacklist the snd_pcsp driver in the MODULES array of Template:Filename (by appending Template:Codeline).

Daemon startup failed

Try resetting PulseAudio. To do that:

$ pulseaudio --kill
$ killall pulseaudio
$ killall -9 pulseaudio
$ rm -rf ~/.pulse*
$ rm -rf /tmp/pulse*

Afterwards, start PulseAudio again.

padevchooser

If you cannot launch the PulseAudio Device Chooser, first (re)start the Avahi daemon as follows:

$ /etc/rc.d/avahi-daemon restart

Glitches and high CPU usage since 0.9.14

The PulseAudio sound server has been rewritten to use timer-based audio scheduling instead of the traditional interrupt-driven approach. Timer-based scheduling may expose issues in some Alsa drivers. To turn timer-based scheduling off, replace the line:

load-module module-udev-detect 

in Template:Filename by:

load-module module-udev-detect tsched=0

Choppy sound

Choppy sound in pulsaudio can result from wrong settings for the sample rate in /etc/pulse/daemon.conf. Try changing the line

; default-sample-rate = 44100

to

default-sample-rate = 48000

and restart the pulsaudio server by executing

pulseaudio --kill && pulseaudio --start

Volume adjustment doesn't work properly

You might wan't to check

/usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common

Realtime scheduling

If rtkit doesn't work, you can manually set up your system to run PulseAudio with realtime scheduling, which can help performance. To do this, add the following lines to Template:Filename:

@pulse-rt - rtprio 9
@pulse-rt - nice -11

Afterwards, you need to add your user to the Template:Codeline group:

# gpasswd -a <user> pulse-rt

Veja também

Links externos