3

I'm having some trouble with pulseaudio as is tradition.

When I enter X (DWM) , run google-chrome and travel to youtube.com and play a video, the headphones won't work, the sound is choppy.

speaker-test -c 2 -t wav -D plughw:2,0 results in: Playback open error: -16, Device or resource busy

When I Restart X (Logout -> Login) the audio in the browser start to magically work.

**** List of PLAYBACK Hardware Devices ****

card 0: PCH [HDA Intel PCH], device 0: ALC898 Analog [ALC898 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC898 Digital [ALC898 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Device [USB Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I have no clue what's going on, below are the messages that I receive from /var/log/messages

First login

Mar 11 20:07:31 qwerty pulseaudio[1223]: [pulseaudio] alsa-mixer.c: Volume element Speaker has 8 channels. That's too much
Mar 11 20:07:31 qwerty pulseaudio[1223]: [pulseaudio] alsa-mixer.c: Volume element Speaker has 8 channels. That's too much
Mar 11 20:07:31 qwerty pulseaudio[1223]: [pulseaudio] alsa-mixer.c: Volume element Speaker has 8 channels. That's too much
Mar 11 20:07:31 qwerty pulseaudio[1223]: [pulseaudio] alsa-mixer.c: Volume element Speaker has 8 channels. That's too much
Mar 11 20:07:31 qwerty pulseaudio[1223]: [pulseaudio] alsa-mixer.c: Volume element Speaker has 8 channels. That's too much
Mar 11 20:07:44 qwerty org.a11y.Bus[1007]: Activating service name='org.a11y.atspi.Registry'
Mar 11 20:07:44 qwerty org.a11y.Bus[1007]: Successfully activated service 'org.a11y.atspi.Registry'
Mar 11 20:07:44 qwerty org.a11y.atspi.Registry[1288]: SpiRegistry daemon is running with well-known name - org.a11y.atspi.

Second login

Mar 11 20:08:01 qwerty org.gtk.vfs.Daemon[1007]: A connection to the bus can't be made
Mar 11 20:08:01 qwerty org.gtk.vfs.Daemon[1007]: g_dbus_connection_real_closed: Remote peer vanished with error: Underlyin on an async read (g-io-error-quark, 0). Exiting.
Mar 11 20:08:01 qwerty org.a11y.Bus[1007]: g_dbus_connection_real_closed: Remote peer vanished with error: Underlying GIOS async read (g-io-error-quark, 0). Exiting.
Mar 11 20:08:01 qwerty org.a11y.atspi.Registry[1288]: g_dbus_connection_real_closed: Remote peer vanished with error: Undebytes on an async read (g-io-error-quark, 0). Exiting.
Mar 11 20:08:02 qwerty org.a11y.Bus[1007]: No protocol specified
Mar 11 20:08:17 qwerty org.a11y.Bus[1349]: Activating service name='org.a11y.atspi.Registry'
Mar 11 20:08:17 qwerty org.a11y.Bus[1349]: Successfully activated service 'org.a11y.atspi.Registry'
Mar 11 20:08:17 qwerty org.a11y.atspi.Registry[1539]: SpiRegistry daemon is running with well-known name - org.a11y.atspi.

Asound.conf

pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}

pcm.!default {
    type pulse
}

ctl.!default {
    type pulse
}

OUTPUT OF ALSA Information Script v 0.4.64

http://www.alsa-project.org/db/?f=5290b8d86207b2cba3c1e4854fea0399e7fdb9f7

If I proceed to kill all the pulseaudio processes running, and run

speaker-test -c 2 -t wav -D plughw:2,0 the audio works, but not in the browser obviously.

Now I have two options, remove pulseaudio and try to set PCM_DEVICE via environment variables which also is a pain in the a** or try to sort this pulseaudio s*** out... Hours I'd rather be spending elsewhere.

  • I'm having some trouble with pulseaudio as is tradition. +1, indeed. – jayhendren Mar 11 '16 at 19:32
2

I didn't wanna try to solve it by fixing the issue with pulseaudio, since this issue just bubbled to the surface from nowhere , i don't know what package i installed broke this, but i didn't change anything in the config files, and this issue just suddenly appeared.

What i did to solve this was to completely remove pulseaudio.

apt-get --purge remove pulseaudio*
rm -r ~/.config/pulse

Changed back to my old alsa asound.conf file and added input for device enviroment variable.

/ETC/ASOUND.CONF

defaults.pcm.!card Device
defaults.ctl.!card Device
defaults.pcm.!device { 
        @func igetenv  
                vars [ ALSA_PCM_DEVICE ]  
                default 0 
}

IT WORKS! ("Device" is the name of my USB Card)

I have to set the enviroment variables when switching to a card with multiple audio output devices.

command: > ALSA_PCM_CARD=CARD ALSA_PCM_DEVICE=DEVICE firefox

I could not set the ALSA_PCM_DEVICE without adding it to the asound.conf, it were apparently not sufficient to set it despite it beeing defined in /usr/share/alsa/alsa.conf.

The reason for that was that plughw uses ALSA_PCM_DEVICE and, if that's not set, falls back to defaults.pcm.device, while dmix (/usr/share/alsa/pcm/dmix.conf) uses just defaults.pcm.device, without checking for ALSA_PCM_DEVICE

Thats why you have to explicitly redefine defaults.pcm.!device to make it check for the ALSA_PCM_DEVICE enviroment variable

EDIT (SUMMARY CONVERSATION ON IRC - ALSA Enviroment variables)

Unless you have some unusual embedded device/driver.

Alsa should provide a similar "default"=plug->dmix->hw playback chain.

It should work out of box with no ~/.asoundrc at all.

It's just by default that chain ends on card 0 device 0.

Or, technically, it: (1) defaults to card ALSA_PCM_CARD environment, if it's not set (2) defaults to ALSA_CARD env.variable, if it's not set (3) defaults to "defaults.pcm.card" alsa variable and if that's not set (4) defaults to card 0.

So, for example, to have all apps playing to a soundcard named "PCH" you need just 2 lines in ~/.asoundrc (your user only) or /etc/asound.conf (all users):

defaults.pcm.!card PCH

defaults.ctl.!card PCH

To override that and play to a card named "Headset" you can run apps as: env ALSA_CARD=Headset some-app-here. You can see card names in cat /proc/asound/cards or aplay -l output. Technically you can use card numbers too (env ALSA_CARD=2 some-app-here), but numbers may change on reboot, so it's usually better to use names.

EDIT (SUMMARY CONVERSATION ON IRC - PulseAudio)

Pulseaudio does it differently. Instead of adding intermediate modules it adds a global pulseaudio daemon, and that daemon plays directly to "hw" pcm. All other apps are supposed to play to that daemon, because while it's running noone else can play to "hw". That's why i had "device or resource is busy".

So a typical pulseaudio playback chain is default="type pulse" module -> pulseaudio daemon -> hw. You're not supposed to use "hw" or "plughw" or "dmix" with pulseaudio - they can't work together. Instead i should have defined pcm.!default { type pulse } (actually pulseaudio usually does that for you automatically)

With pulseaudio installed you just need pcm.!default { type pulse }. And on most distributions pulseaudio does that automatically. (on archlinux it's packaged as a separate "pulseaudio-alsa" package, which basically has just this alsa config and nothing else)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.