Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Strange Little Issue with Default ALSA Card
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Apr 02, 2013 2:29 pm    Post subject: Strange Little Issue with Default ALSA Card Reply with quote

I record audio (principally Atlanta Braves games) on one of my home servers using a little script launched with a cron job. I use
  • amixer to unmute the line input, mute the speaker output, set levels, and enable capture,
  • arecord to actually capture the audio, and
  • sox to compress it after the recording is done.
Some time between the last day of the regular season (October 3, 2012) and opening day (April 1, 2013), the ALSA subsystem forgot which sound card was the default, which is really strange because I only have one sound card. The symptoms were
  • The calls to amixer were failing because the named subdevices were not found.
  • Just as an aside, alsamixer also did not see the card until selected manually, at which point the subdevices were visible and controllable.
There seems to be a phantom "default" sound card with extremely limited features that doesn't control any real devices.

I found a solution on the old external Gentoo Wiki. I had to set the default sound card in /etc/asound.conf, like so
Code:
pcm.!default { type hw card AU8830 }
ctl.!default { type hw card AU8830 }
(where AU8830 is the name of my sound card). After that, my recording script worked again, seeing the subdevices properly.

My question is, what changed? The /etc/asound.conf file isn't mentioned in the Gentoo Linux ALSA Guide, and further I've never needed it before.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Tue Apr 02, 2013 3:21 pm    Post subject: Re: Strange Little Issue with Default ALSA Card Reply with quote

John R. Graham wrote:
which is really strange because I only have one sound card.

It is not because you get a single "sound-card" that you necessarily get a single device. (ls -ails /dev/snd)
John R. Graham wrote:
There seems to be a phantom "default" sound card with extremely limited features that doesn't control any real devices.

I cannot tell if the alsa loopback driver qualifies as member of a JRG-Phantom_Class sound card but "extremely limited features" could fit.
John R. Graham wrote:
My question is, what changed?


From what you report, I suspect that in the times you mention, you built your kernel with CONFIG_SND_ALOOP (device drivers/sound card support/advanced linux sound architecture/generic sound devices/generic loopback driver) which replaced your "real sound device" as alsa device #0 (It did on my system the first time I built my kernel with that driver in 2.6.37 times) and, as alsa device #0 is the default-default sound device...
(by default-default, I mean in the absence of any /etc/asound.conf or $HOME/.asoundrc in which you can set the default alsa device as you rightly did)
_________________


Last edited by aCOSwt on Tue Apr 02, 2013 3:47 pm; edited 2 times in total
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Apr 02, 2013 3:28 pm    Post subject: Reply with quote

aCOSwt,

Thanks very much. I'll look into your suggestions as soon as I get home today. I preserved all my old kernel .config files, so I should be able to get a definitive answer.

I do know that
Code:
cat /proc/asound/cards
only showed one sound card, but perhaps the loopback driver doesn't show up there.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Tue Apr 02, 2013 3:31 pm    Post subject: Reply with quote

John R. Graham wrote:
I do know that
Code:
cat /proc/asound/cards
only showed one sound card, but perhaps the loopback driver

So do not waste time with my explanation, it is not the correct one. The alsa loopback driver should show in /proc/asound/cards.

EDIT : So... when you can, please post the output of
Code:
ls -ails /proc/asound | grep card0

EDIT2 : BTW, of course your sound card is driven by the in-kernel statically built driver ?
_________________
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Apr 02, 2013 11:45 pm    Post subject: Reply with quote

aCOSwt wrote:
So... when you can, please post the output of...
Code:
~ # ls -ails /proc/asound | grep card0
4026533008 0 lrwxrwxrwx   1 root root 5 Apr  2 19:39 au8830 -> card0
4026532195 0 dr-xr-xr-x   8 root root 0 Apr  2 19:39 card0
aCOSwt wrote:
BTW, of course your sound card is driven by the in-kernel statically built driver ?
In kernel sound drivers, all built as modules. As far as I know, you'd really have to go out of your way to use the alsa-driver package any more: it's no longer in the tree.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
syn0ptik
Apprentice
Apprentice


Joined: 09 Jan 2013
Posts: 267

PostPosted: Wed Apr 03, 2013 12:25 am    Post subject: Reply with quote

you can add this somewhere in init.d/alsasound script and make a symlinks...
Code:
sed -n -e 's/P*\([[:digit:]]\)-\([[:digit:]]\)-\([[:digit:]]\)\: PCM \([[:lower:]]\).*/ln -s \/dev\/pcmC\1D\2\4 \/dev\/snd\/pcmC\1D\2\4
/p' /proc/asound/timers | sh
sed -n -e 's/\([[:digit:]]\)\([[:digit:]]\)-\([[:digit:]]\)\([[:digit:]]\).*/ln -s \/dev\/hwC\2D\4 \/dev\/snd\/hwC\2D\4 /p' /proc/asound
/hwdep | sh
awk '{if($1~/[0-9]/){print "ln -s /dev/controlC"$1" /dev/snd/controlC"$1}}'  /proc/asound/cards | sh
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Apr 03, 2013 1:20 am    Post subject: Re: Strange Little Issue with Default ALSA Card Reply with quote

John R. Graham wrote:
(October 3, 2012) and opening day (April 1, 2013)

I would guess that you updated the kernel, and the kernel's ALSA code was flaky.

I'm staying with the 3.4 kernels - I wasn't impressed by my brief check of the 3.6 kernels (weird ALSA messages when starting to play sound) and 3.8 (kernel panic during bootup).

Also, opensuse has a huge number of patches (currently 53) in their "alsa" package. I've pinched all of them - seems to work OK.
_________________
Improve your font rendering and ALSA sound
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Wed Apr 03, 2013 8:02 am    Post subject: Reply with quote

John R. Graham wrote:
4026533008 0 lrwxrwxrwx 1 root root 5 Apr 2 19:39 au8830 -> card0

John R. Graham wrote:
Code:
pcm.!default { type hw card AU8830 }
ctl.!default { type hw card AU8830 }


Can you test after changing this for
Code:
pcm.!default { type hw card 0 }
ctl.!default { type hw card 0 }

(You will need to logout/login after changing)
_________________
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Apr 03, 2013 11:52 am    Post subject: Reply with quote

No change. Also no change if the /etc/asound.conf file is completely gone (except that my problem reappears).

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Wed Apr 03, 2013 2:22 pm    Post subject: Reply with quote

John R. Graham wrote:
No change. Also no change if the /etc/asound.conf file is completely gone (except that my problem reappears).

Do you mean that your problem reappears when, in /etc/asound.conf, replacing card AU8830 by card 0 ?
_________________
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Apr 03, 2013 3:03 pm    Post subject: Reply with quote

No, I mean that, under no circumstances does the output of your test command change, regardless of what I put in the asound.conf. It even doesn't change of asound.conf doesn't exist but, when asound.conf doesn't exist, my problem recurs (as would be expected, since I used asound.conf to set the default card).

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Thu Apr 04, 2013 9:05 am    Post subject: Reply with quote

John R. Graham wrote:
No, I mean that, under no circumstances does the output of your test command change, regardless of what I put in the asound.conf. It even doesn't change of asound.conf doesn't exist but, when asound.conf doesn't exist, my problem recurs (as would be expected, since I used asound.conf to set the default card).

Yes.
asound.conf has no impact over the determination of cards ids
asound.conf only defines plugins / aliases that are not permanent over the system's life. They are only valid within a login session.

cards ids are permanent over the system's life.

When drivers are statically built, the kernel is responsible for assigning the card's ids. And then Alsa understands id 0 as being the system's default card.
Application that output to /input from [Alsa-default] do not really output to /input from [Alsa-default]. They actually output to /input from [user's-Alsa-default].
That [user's-Alas-default] is some sort of alias that the user may define matching any particular card in /etc/asound.conf (system-wide setting) or ~/.asoundrc (user local setting)
In absence of any of these, [user's-Alsa-default]=[Alsa-default].

So, what you experience means that either whoever responsible for loading the drivers did things wrong and did not correctly assign id 0 to your AU8830, (It does not appear so yet) OR Alsa no longer understands id 0 as being the system's default card. (I am not aware of such an earthquake)

That is why I was now interested to know if you can reproduce your problem with an asound.conf explicitly redirecting to what the "real default" should be. That is making your /etc/asound.conf look like
Code:
pcm.!default { type hw card 0 }
ctl.!default { type hw card 0 }


BTW, make sure you do not get any $HOME/.asoundrc (which can override /etc/asound.conf settings).

BTW, you can also post the cat of /etc/modprobe.d/alsa.conf

BTW <joke-mode>I had understood we were both belonging to the same generation of ancient-geeks... you know... the one which believed that it is heretic to bring a system into userspace with undriven hardware...) :wink: </joke-mode>

Well, more seriously... if you get time to waste, you can retry your experience after rebuilding the SND_AU8830 driver statically...

<joke-mode>as it should be</joke-mode>
_________________


Last edited by aCOSwt on Thu Apr 04, 2013 11:36 am; edited 2 times in total
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Thu Apr 04, 2013 10:30 am    Post subject: Reply with quote

Just to make sure, you did really check /proc/asound/cards still show 1 card only ?
It looks stupid to ask that, but many times, i check things and assume they don't change.
I know i didn't add any new soundcard in my computer, but fail because the new nvidia card introduce sound
A good source for your problem : http://alsa.opensrc.org/FAQ026 You might like the ending paragraph with environment to change default device.
I would specially do the check aplay -L as i see so many "virtual" cards in it.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Thu Apr 04, 2013 11:29 am    Post subject: Reply with quote

krinn wrote:
many times, i check things and assume they don't change.

I always read krinn's posts assuming krinn does'nt change. Shouldn't I ? :? :D
_________________
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Thu Apr 04, 2013 11:39 am    Post subject: Reply with quote

And you're right, i don't change anything, but time do that for me :)
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Thu Apr 04, 2013 11:43 am    Post subject: Reply with quote

aCOSwt wrote:
Yes.
asound.conf has no impact over the determination of cards ids
asound.conf only defines plugins / aliases that are not permanent over the system's life. They are only valid within a login session.
I have empirically determined that its effect is even more ephemeral than that. I can delete asound.conf, releaunch alsamixer, and the problem reappears. So, asound.conf appears to be read by an instance of the ALSA APIs when a userspace program initialize them.

aCOSwt wrote:
That is why I was now interested to know if you can reproduce your problem with an asound.conf explicitly redirecting to what the "real default" should be. That is making your /etc/asound.conf look like
Code:
pcm.!default { type hw card 0 }
ctl.!default { type hw card 0 }
Sorry if I was unclear before. This was the experiment you asked me to run initially and I didn't report the results very unambiguously, it seems. With the modification you recommended above, the problem is also completely solved (which I called "no change"), just like my version.

aCOSwt wrote:
BTW, make sure you do not get any $HOME/.asoundrc (which can override /etc/asound.conf settings).
Confirmed that no .asoundrc exists for any user.

aCOSwt wrote:
BTW, you can also post the cat of /etc/modprobe.d/alsa.conf
Sure.
Code:
# --- BEGIN: Generated by ALSACONF, do not edit. ---
# --- ALSACONF version 1.0.25 ---
alias char-major-116 snd
alias char-major-14 soundcore
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
alias snd-card-0 snd-au8830
alias sound-slot-0 snd-au8830
# --- END: Generated by ALSACONF, do not edit. ---
- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.


Last edited by John R. Graham on Thu Apr 04, 2013 12:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Thu Apr 04, 2013 11:47 am    Post subject: Reply with quote

krinn wrote:
Just to make sure, you did really check /proc/asound/cards still show 1 card only ?
It looks stupid to ask that, but many times, i check things and assume they don't change.
I know i didn't add any new soundcard in my computer, but fail because the new nvidia card introduce sound
A good source for your problem : http://alsa.opensrc.org/FAQ026 You might like the ending paragraph with environment to change default device.
I would specially do the check aplay -L as i see so many "virtual" cards in it.
I checked that first off. Only one sound card reported:
Code:
ceres etc # cat /proc/asound/cards
 0 [au8830         ]: au8830 - Aureal Vortex au8830
                      Aureal Vortex au8830 at 0xfeb80000 irq 17
Thanks. I'll look into your recommended reading. :wink:

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Thu Apr 04, 2013 12:38 pm    Post subject: Reply with quote

OK, I think I get it.

Can you confirm a coincidence between the problem you report and the upgrade from alsa-lib-1.0.24 to alsa-lib-1.0.25 ?

At least does it occur only since you upgraded ?

Irrespective of this, well, I would swear you don't, but, could you confirm you never use pulseaudio (for whatever purpose) ?
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum