[Pkg-alsa-devel] Bug#849203: libasound2: ALSA_PCM_DEVICE environment variable is ignored

Leszek Godlewski lg at inequation.org
Fri Dec 23 14:54:46 UTC 2016


Package: libasound2
Version: 1.1.2-1
Severity: normal

Dear Maintainer,

I have a PC with two on-board Intel HD Audio chips using the same driver. One of them outputs SPDIF to the HDMI connector, the other - to a separate SPDIF/analog jack. These chips are visible as separate cards:

inequation at BrixPro:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: ALC269VC Digital [ALC269VC Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

For most applications, the HDMI output is preferred and is set to be the default:

inequation at BrixPro:~$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
hdmi:CARD=HDMI,DEV=0
    HDA Intel HDMI, HDMI 0
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=1
    HDA Intel HDMI, HDMI 1
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=2
    HDA Intel HDMI, HDMI 2
    HDMI Audio Output
dmix:CARD=HDMI,DEV=3
    HDA Intel HDMI, HDMI 0
    Direct sample mixing device
dmix:CARD=HDMI,DEV=7
    HDA Intel HDMI, HDMI 1
    Direct sample mixing device
dmix:CARD=HDMI,DEV=8
    HDA Intel HDMI, HDMI 2
    Direct sample mixing device
dsnoop:CARD=HDMI,DEV=3
    HDA Intel HDMI, HDMI 0
    Direct sample snooping device
dsnoop:CARD=HDMI,DEV=7
    HDA Intel HDMI, HDMI 1
    Direct sample snooping device
dsnoop:CARD=HDMI,DEV=8
    HDA Intel HDMI, HDMI 2
    Direct sample snooping device
hw:CARD=HDMI,DEV=3
    HDA Intel HDMI, HDMI 0
    Direct hardware device without any conversions
hw:CARD=HDMI,DEV=7
    HDA Intel HDMI, HDMI 1
    Direct hardware device without any conversions
hw:CARD=HDMI,DEV=8
    HDA Intel HDMI, HDMI 2
    Direct hardware device without any conversions
plughw:CARD=HDMI,DEV=3
    HDA Intel HDMI, HDMI 0
    Hardware device with all software conversions
plughw:CARD=HDMI,DEV=7
    HDA Intel HDMI, HDMI 1
    Hardware device with all software conversions
plughw:CARD=HDMI,DEV=8
    HDA Intel HDMI, HDMI 2
    Hardware device with all software conversions
default:CARD=PCH
    HDA Intel PCH, ALC269VC Analog
    Default Audio Device
sysdefault:CARD=PCH
    HDA Intel PCH, ALC269VC Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    Front speakers
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Digital
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    Direct sample mixing device
dmix:CARD=PCH,DEV=1
    HDA Intel PCH, ALC269VC Digital
    Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=1
    HDA Intel PCH, ALC269VC Digital
    Direct sample snooping device
hw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=1
    HDA Intel PCH, ALC269VC Digital
    Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=1
    HDA Intel PCH, ALC269VC Digital
    Hardware device with all software conversions
inequation at BrixPro:~$ cat /etc/asound.conf
defaults.pcm.card 0
defaults.pcm.device 3

However, for some applications, I'd rather have their playback directed to the jack (i.e. card #1). The ALSA environment variables ALSA_PCM_CARD and ALSA_PCM_DEVICE should be doing the trick; and while ALSA_PCM_CARD does work, ALSA_PCM_DEVICE does not. See /usr/share/alsa/alsa.conf.

What makes me suspect that is the case is this piece of an mplayer failed playback log:

inequation at BrixPro:~$ ALSA_PCM_CARD=1 ALSA_PCM_DEVICE=0 mplayer test.mp3
(...)
[AO_ALSA] alsa-lib: pcm_hw.c:1601:(snd_pcm_hw_open) open '/dev/snd/pcmC1D3p' failed (-2): No such file or directory
(...)

Please note the device path that refers to device #3, which is set as default in my asound.conf. Calling the same command line with ALSA_PCM_CARD=0 succeeds, although the audio plays on the HDMI output, which confirms my suspicion that card switching works, but device switching doesn't. I've actually written a script that tries ALSA_PCM_DEVICE from 0 to 100, and the result is always the same, which makes me quite convinced that the variable is being ignored.

A hacky, dirty workaround for the issue is to make a symlink from /dev/snd/pcmC1D0p to /dev/snd/pcmC1D3p. Playback works as expected then, but the symlink is ugly.

I simply expect to be able to pick the ALSA device via environment variables.

I'm on current ALSA package from testing.

Regards,

Leszek

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.7.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=pl_PL.UTF-8, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libasound2 depends on:
ii  libasound2-data  1.1.2-1
ii  libc6            2.24-5

libasound2 recommends no packages.

Versions of packages libasound2 suggests:
pn  libasound2-plugins  <none>

-- no debconf information



More information about the Pkg-alsa-devel mailing list