It is not possible to use 'hw:0' device after changing default sound card

Bug #38793 reported by Pēteris Krišjānis
10
Affects Status Importance Assigned to Milestone
alsa-lib (Ubuntu)
Incomplete
Medium
Martin Pitt

Bug Description

I have two sound cards, VIA 8235 (on-board) and EWS88MT (multichannel). According to ALSA, first one is VIA and second one EWS, but I have my speaker system hooked on EWS. As gstreamer-based Totem and Rhythmbox uses default sound card as defined by ALSA, I change default in System > Preferences > Sound to EWS (gnome-sound-properties). This calls asoundconf and defines default sound card in ~/.asoundrc.asoundconf (which is then included in ~/.asoundrc, where all ALSA settings goes for user). So far so good and PCM device 'default' works in both combinations, Totem and Rhythmbox works just fine.

However, changing default sound card, and creating these files screws up 'hw:0', etc. definitions. Before change I can record using 'arecord -D hw:0 -f cd test.wav' without problems, after change and creation of files I get this:
pecisk@blackcatstudio:~$ arecord -vv -D hw:0 -f cd test.wav
ALSA lib confmisc.c:1107:(snd_func_refer) Unable to find definition 'defaults.pcm.device'
ALSA lib conf.c:3493:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib confmisc.c:242:(snd_func_getenv) error evaluating default
ALSA lib conf.c:3493:(_snd_config_evaluate) function snd_func_igetenv returned error: No such file or directory
ALSA lib conf.c:3951:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2099:(snd_pcm_open_noupdate) Unknown PCM hw:0
arecord: main:544: audio open error: No such file or directory

For additional info I provide different output from /proc/asound/*:

pecisk@blackcatstudio:~$ cat /proc/asound/cards
0 [V8235 ]: VIA8233 - VIA 8235
                     VIA 8235 with ALC650E at 0xd800, irq 5
1 [UART ]: MPU-401 UART - MPU-401 UART
                     MPU-401 UART at 0x330, irq 10
2 [EWS88MT ]: ICE1712 - TerraTec EWS88MT
                     TerraTec EWS88MT at 0xe000, irq 5

pecisk@blackcatstudio:~$ cat /proc/asound/pcm
00-00: VIA 8235 : VIA 8235 : playback 4 : capture 1
00-01: VIA 8235 : VIA 8235 : playback 1 : capture 1
02-00: ICE1712 multi : ICE1712 multi : playback 1 : capture 1
02-01: ICE1712 consumer : ICE1712 consumer : playback 1 : capture 1
02-02: ICE1712 consumer (DS) : ICE1712 consumer (DS) : playback 6

Revision history for this message
Pēteris Krišjānis (pecisk-gmail) wrote :

Also .asoundrc and asoundrc.asoundconf:
# ALSA library configuration file

# Include settings that are under the control of asoundconf(1).
# (To disable these settings, comment out this line.)
</home/pecisk/.asoundrc.asoundconf>
___________________________________________
# ALSA library configuration file managed by asoundconf(1).
#
# MANUAL CHANGES TO THIS FILE WILL BE OVERWRITTEN!
#
# Manual changes to the ALSA library configuration should be implemented
# by editing the ~/.asoundrc file, not by editing this file.
!defaults.pcm.card EWS88MT

Revision history for this message
Daniel T Chen (crimsun) wrote :

End result is the same root cause as for #31699, missing parameter section in alsa-lib's conffiles.

Changed in alsa-utils:
assignee: nobody → pitti
status: Unconfirmed → Needs Info
Revision history for this message
Daniel T Chen (crimsun) wrote : Malone #31699 (alsa-utils: asoundconf: gnome-control-center && default sound card)
Download full text (4.5 KiB)

Martin et al.,

I've done some further debugging for Malone #31699, and it appears that
the current fix for #35540 is insufficient (partially my fault). Some
applications expect defaults.pcm.device and defaults.pcm.subdevice,
which must be integers due to /usr/share/alsa/alsa.conf's use of
igetenv for .DEV and .SUBDEV. So to make all audio applications play
nicely together, we need to enumerate the following variables in
~/.asoundrc.asoundconf:

!defaults.pcm.card <string>
!defaults.ctl.card <string>
defaults.pcm.device <integer>
defaults.pcm.subdevice <integer>
[pcm.device <integer>]

Here's the breakdown: defaults.pcm.card and defaults.ctl.card can be
strings (as ``asoundconf list'', in which case the ! is required) or
integers (in which case the ! shouldn't appear). Currently gnome-
control-center sets these two variables, and most apps play nicely.
However, apps like jackd normally require a specific device (implying
that its subdevice must also be set), in which case defaults.pcm.device
and defaults.pcm.subdevice must also be set. The good news is that we
can get away with setting defaults.pcm.subdevice -1 (per definition in
/usr/share/alsa/alsa.conf) always, since apps will override it as
necessary.

I've currently been testing an ~/.asoundrc.asoundconf, and the above
variables for my current sound card configuration (only one on-board
Intel ICH6; the external USB M-Audio Transit is not present) are as
follows:

!defaults.pcm.card ICH6
!defaults.ctl.card ICH6
defaults.pcm.device 0
defaults.pcm.subdevice -1
pcm.device 1

so that I can use the on-board ICH6 by default and still use jackd with
either the onboard or the external usb sound device.

I've tested using both amixer and jackd with the above block (both with
and without pcm.device 1) as follows:

amixer && amixer -c0 && amixer -c1
jackd -d alsa && jackd -d alsa -dhw:0 && jackd -d alsa -dhw:1

The first two invocations of each program (i.e., amixer && amixer -c0
and jackd -d alsa && jackd -d alsa -dhw:0) work exactly as expected. I
am able to list the values of the mixer and successfully invoke jackd.
With pcm.device 1 present in ~/.asoundrc.asoundconf, I am able to
invoke the last set of each program (i.e., amixer -c1 and
jackd -d alsa -dhw:1) with the expected result that there is no such
device. I also receive identical results without pcm.device 1 present
in ~/.asoundrc.asoundconf.

The reason I mention additional "pcm.device"s is because of the
previously mentioned situation where a user may have multiple sound
cards detected and wish to have GNOME use a different default card from
say, jackd.

So, recap, and conclude with what we need to do to resolve #31699 and
its unfortunate duplicates:

At the very least ~/.asoundrc.asoundconf needs to have values for:

defaults.pcm.card
defaults.ctl.card
defaults.pcm.device
defaults.pcm.subdevice

I suggest we use the nominal default of -1 for defaults.pcm.subdevice,
continue using the strings for !defaults.{ctl,pcm}.card, and use an
integer for defaults.pcm.device. This means that gnome-control-center's
debian/patches/23_default_soundcard_selector.patch needs to be modified
such that set_default_card() also sets defaults.pcm.device and
...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.