Comment 19 for bug 31699

Revision history for this message
Daniel T Chen (crimsun) wrote : Re: [Bug 31699] Re: Can't use other than default sound card

On Fri, May 05, 2006 at 02:54:53AM -0000, Andrew Jorgensen wrote:
> I can confirm that Daniel's fix works for me at least. I'm very happy about that! On the other hand I'm a little disappointed because part of the why we wanted to do this asoundrc trick was so that we could select the default device by name, not by number (which in the case of USB devices doesn't always stay the same). I wonder if there's some configuration trick that can be used to set these device numbers off the names rather than hardcoding them in .asoundrc*. Alsa's config files are rediculously complex, so it's possible there is a way.

Actually it's even better than what you describe. After returning home,
plugging in my external USB sound device, and testing, I've narrowed
the necessary modifications against current alsa-utils to the
following:

(1) ~/.asoundrc.asoundconf needs to contain the following:

defaults.pcm.device 0
defaults.pcm.subdevice -1

That's right, neither of those values will ever have to change! I had
overlooked that !defaults overrides defaults, so all gnome-control-
center needs to do via set_default_card() is change the values for
defaults.pcm.card and defaults.ctl.card as it's currently doing. As
long as defaults.pcm.device and defaults.pcm.subdevice are defined in
~/.asoundrc.asoundconf, we can override the card with
!defaults.pcm.card as we're currently doing.

(2) defaults.ctl.card should be changed by set_default_card(), but it
should not override ALSA's default. That is, our current rationale for
using ! for strings, which forces "!defaults.ctl.card ICH6" instead of
"defaults.ctl.card ICH6" as it should be, is incorrect. I noticed this
symptom when testing ogg123 and aplay with the new set of asoundrc
variables that I stated in the last e-mail, which results in errors of
not being able to find defaults.pcm.card and thus bailing.

So, to recap: We need to hard-code "defaults.pcm.device 0" and
"defaults.pcm.subdevice -1" in ~/.asoundrc.asoundconf. We also need to
strip the leading ! from defaults.ctl.card. With this modification,
amixer, aplay, ogg123, gst*, and jackd all play nicely. Better yet, we
retain dmix by default [0]. :)

(Apologies for the noise across five different Malone bug reports.)

[0] Well, save for USB devices, but that's a known issue in alsa-lib.
    See Malone #33736.

Thanks,
--
Daniel T. Chen <email address hidden>
GPG key: www.sh.nu/~crimsun/pubkey.gpg.asc