Valid HTML 4.01 Transitional
Prev: X.509 Client Certificates on Firefox for Android Next: Why Doesn't My Device Sync to ownCloud?
(Index)
Jim Carter's Bugfixes

Setting PulseAudio's Default Device

James F. Carter
2013-12-16
Symptom:

I bought a sound device and I want PulseAudio to use it but I can't find how to influence PulseAudio to use other than its system default device.

Specifically, it's a Pioneer SMM301 "Digital USB Speaker System", which has an audio chip embedded in one speaker, rather than just drawing power from USB and taking an analog audio signal from the host's own audio chip. However, the same issue would arise with any sound device including PCI.

What's happening:

This is a documentation problem. What is obvious to an experienced PulseAudio developer, is unfathomable to a normal user.

I went through Fedora's How to Debug PulseAudio Problems. I prepared as if submitting a bug report, even though I expected that the problem would not be found in the actual code. Here are some points from the report:

Time to bring out the heavy guns. I ran:
strace -f -o pulseaudio.str pulseaudio -v
But I failed to spot the key configuration file in 12180 lines of stuff.

How to fix:

Searching on Google with keywords: pulseaudio connect client sink. I got a hit: PulseAudio Examples on the Arch Linux wiki, dated 2012-02-xx. Execute pacmd from the pulseaudio-utils package:
pacmd list-sinks | less

In the output look for index: $N (Mine is #1.) Then edit /etc/pulse/default.pa or ~/.pulse/default.pa and insert/alter the set-default-sink command. Apparently the sink number was once accepted, but of course the numbering cannot be guaranteed repeatable, so now it wants the sink's name. In my case:
set-default-sink alsa_output.usb-Burr-Brown_from_TI_USB_Audio_DAC-00-DAC.analog-stereo

Pulseaudio reads only one of /etc/pulse/default.pa or ~/.pulse/default.pa, not overriding system defaults from the user's file. In the recommended case that you put your default into ~/.pulse/default.pa, you should first copy /etc/pulse/default.pa to ~/.pulse/default.pa (or else handcraft a complete PulseAudio configuration).

You need to restart pulseaudio for this to take effect. And it works! (Very loudly.) Use pavucontrol to adjust the volume for your player app.

Alternatively for an ad-hoc change, execute pavucontrol (from package pavucontrol) from the command line, or in the desktop menu system look in the Multimedia category for PulseAudio Volume Control. Look on the Playback tab for the stanza for your player. In the first row is a widget with the name of the sink it is connected to. Click it: it's a listbox and you can re-route the client to a different sink (or source). You can also adjust the volume, specifically for that client.

It turns out that you don't have to edit ~/.pulse/default.pa after all. In PulseAudio Volume Control's Output Devices tab, each one has an icon of a checkmark with a tooltip saying Set as Fallback. It's like a radiobutton and the selected one's background is subtly darker than the othrs. Select your preferred device, and it will be used if other devices are unplugged or if an app is not specifically configured to use a specific device.

The last piece of the puzzle will be to get the mixer applet to control PulseAudio's volume, as it would for ALSA output. This is the XFCE Audio Mixer (/usr/lib64/xfce4/panel/plugins/libmixer.so from package xfce4-panel-plugin-mixer). Presumably the Gnome or KDE mixers would be similar.

There are now multiple ways to control the volume: the panel mixer icon, the panel mixer properties GUI (PulseAudio or ALSA device), PulseAudio Volume control's playback (application) stanza, its stanza for the output device, and the ncurses alsamixer program. A change made to any of these will be propagated to all the others.


Prev: X.509 Client Certificates on Firefox for Android Next: Why Doesn't My Device Sync to ownCloud?
(Index)