You are not logged in.

#1 2012-08-20 23:03:11

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Webcam screws up Alsa/Alsa only available for one program at a time

Okay, everytime I plug and/or unplug my usb webcam, alsa gives up and stops working.... or maybe it's only when I boot with the webcam hooked up... I'll have to check.  I've spent the last half an hour or so scouring the forums, google, and just about everything else looking for answers, even though I did just skim through it all. 

Here's what I get when I try to run alsamixer without my webcam

$ pnmixer
ALSA lib conf.c:1686:(snd_config_load1) _toplevel_:14:3:Unexpected char
ALSA lib conf.c:3406:(config_file_open) /home/palantir/.asoundrc may be old or corrupted: consider to remove or fix it
Mixer attach default error: No such file or directorySegmentation fault

Here's what I get with my webcam

$ pnmixer
ALSA lib conf.c:1686:(snd_config_load1) _toplevel_:14:3:Unexpected char
ALSA lib conf.c:3406:(config_file_open) /home/palantir/.asoundrc may be old or corrupted: consider to remove or fix it
pnmixer: mixer.c:905: snd_mixer_elem_set_callback: Assertion `mixer' failed.
Aborted

I have a HDA Intel, Conexant analog sound card, and a Logitech Quickcam Notebook webcam thingy, I believe.  Alsa is one of my weaker points when it comes to configuration so I'd appreciate patience and stuff like that, thanks in advanced.

Here's my .asoundrc

pcm.usb 
{ 
 type hw 
 card U0x46d0x8dd

}

pcm.!default 
{ 
 type asym
 card Intel  
 device 0 
 { 
  type plug 
  slave.pcm "dmix"
 }
 capture.pcm
 {
  type plug
  slave.pcm "usb"
 }
}

Last edited by lspci (2012-08-25 08:34:26)


Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

#2 2012-08-20 23:48:01

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Webcam screws up Alsa/Alsa only available for one program at a time

lspci wrote:

device 0
{
  type plug

As it keeps telling you, that's invalid. For an example, see my sig.

Offline

#3 2012-08-21 14:54:33

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Re: Webcam screws up Alsa/Alsa only available for one program at a time

brebs wrote:
lspci wrote:

device 0
{
  type plug

As it keeps telling you, that's invalid. For an example, see my sig.


Well, yeah, I knew that it wasn't valid, but I don't know enough about how to make it valid.  The wiki doesn't cover the inner workings of the .asoundrc file, or at least, I don't think that it does.  I just deleted my .asoundrc, but I'm not sure if that solved the problem or not, I'll check in a little bit.

I'll go through the wiki and try to find the fix information that I need.  Once I've found what fixes the webcam problem I'll post my solution.



Okay, fixed the .asoundrc problem. 

Here's my .asoundrc

defaults.pcm.card 1  # configured to use the onboard intel sound card
defaults.pcm.device 0 # configured to use the onboard sound card
defaults.ctl.card 0 # configured to use the external usb webcam for the default microphone.  (see /etc/modprobe.d/alsa.conf for sound card order)
defaults.pcm.rate_converter "samplerate_best" # enable high quality resampling.  

pcm.dmixout {
 # just pass this on to the system dmix
 type plug
 slave {
 pcm "dmix" 
 }
}

and here's my /etc/modprobe.d/alsa.conf

options snd-usb-audio index=0 
options snd-hda-intel index=1,2 

Okay, audio now works regardless of whether the webcam is plugged in--I think; I'll have to double check 'cause I'm really not 100% sure.  Alsamixer is working now, but amixer and pnmixer are both inoperable.  However, I can adjust the volume and everything using alsamixer, though this is a bit of a pain. 


Any idea what these error messages might mean?  I'll google them and stuff in a bit. 

$ amixer
Simple mixer control 'Mic',0
  Capabilities: cvolume cvolume-joined cswitch cswitch-joined penum
  Capture channels: Mono
  Limits: Capture 0 - 3
  Mono: Capture 0 [0%] [30.00dB] [on]
Simple mixer control 'Auto Gain Control',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]

$ amixer set Master 1%+
amixer: Unable to find simple control 'Master',0
$ pnmixer
pnmixer: mixer.c:905: snd_mixer_elem_set_callback: Assertion `mixer' failed.
Aborted

Last edited by lspci (2012-08-23 14:00:27)


Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

#4 2012-08-25 05:59:23

lspci
Member
From: Virginia, USA
Registered: 2012-06-09
Posts: 242

Re: Webcam screws up Alsa/Alsa only available for one program at a time

Okay, so I fixed everything and now pnmixer, alsamixer, and alsa all work together and are a happy little family.  tongue 

I don't really know what I did to fix it, though.  xD
(jk)
I'm pretty sure that it was the configuring I did. 

Here are my configuration files:

# /etc/modprobe.d/alsa.conf


options snd-usb-audio index=2
options snd-hda-intel model=INTEL index=0,1  
# /etc/asound.conf

pcm.!default {
 type hw 
 card Intel # same thing as card 0
 # card 0
 # device 0
}

ctl.!default {

 type hw
 card 2 # same thing as card 2
}

ctl.!dmixer {

 type hw
 card Intel
}

(~/.asoundrc is the same as asoundrc1, I just cat'd ~/.asoundrc into asoundrc1.) 

# ~/.asoundrc -- with usb webcam plugged up.   

pcm.usb {
 type hw 
 card U0x46d0x8dd
}
pcm.!default {
 type asym
 playback.pcm 
 {
   type plug 
   slave.pcm "dmix" 
 } 
 capture.pcm 
 { 
   type plug
   slave.pcm "usb"
 }
}

pcm.!default {

 type hw
 card 0
# device 0
 }

ctl.!default {
 type hw
 card 2 
 }

# allows more than one application to make use of the soundcard 
pcm.dsp { 
 type plug
 slave.pcm "dmix"
} 

~/\\/etc/defaults/asoundrc2

# ~/.asoundrc 

# (if the usb webcam is currently plugged in then this will actually be in ~/\\/etc/defaults/ until the usb webcam 
#> is unplugged.  Then it will be moved to ~/ so that Alsa, alsamixer, and pnmixer don't encounter errors when they try to use
#> a device that doesn't exist anymore.  

# vim filetype = alsaconf 

#pcm.usb {
# type hw 
# card U0x46d0x8dd
#}
#pcm.!default {
# type asym
# playback.pcm 
# {
#   type plug 
#   slave.pcm "dmix" 
# } 
# capture.pcm 
# { 
#   type plug
#   slave.pcm "usb"
# }
#}

pcm.!default {

 type hw
 card 0
# device 0
 }

ctl.!default {
 type hw
 card 0 
 }

# allows more than one application to make use of the soundcard 
pcm.dsp { 
 type plug
 slave.pcm "dmix"
} 

and here's a script that keeps them updated. 

#!/bin/sh
#===============================================================================
#
#          FILE: alsacat.sh
# 
#         USAGE: ./alsacat.sh 
# 
#   DESCRIPTION: 
#
#   CREATED: 08/25/2012 01:34:01 AM EDT
#
#   AUTHOR: user, palantir (lspci)
#
#===============================================================================

#if ! arecord -l | grep "card 2: U0x46d0x8dd" ; then 
#   if cat ~/.asoundrc | grep "card 2: U0x46d0x8dd" ; then 
#       cat ~/\\/etc/defaults/asoundrc2 > ~/.asoundrc ;
#   fi
#elif arecord -l | grep "card 2: U0x46d0x8dd" ; then

# was going to use if-statements, but then I realized that I can just use '&&'s instead.  

arecord -l | grep "card 2: U0x46d0x8dd" || cat ~/.asoundrc | grep "card 2: U0x46d0x8dd" && cat ~/\\/etc/defaults/asoundrc2 > ~/.asoundrc && printf "\e[1;34m:: \e[0malsa reconfigured successfully.  asoundrc2 has been cat'd into ~/.asoundrc" || printf "\e[1;31m:: \e[0malsa reconfiguration failed.  asoundrc2 could not be cat'd into ~/.asoundrc, or so I assume.  Something's wrong at any rate, so check it out!"  
# if not true then do                           this, and if this is true, then do                this and then let me know if it worked or not.  

arecord -l | grep "card 2: U0x46d0x8dd" && cat ~/.asoundrc | grep "card 2: U0x46d0x8dd" || cat ~/\\/etc/defaults/asoundrc1 > ~/.asoundrc && printf "\e[1;34m:: \e[0malsa reconfigured successfully. asoundrc1 has been cat'd into ~/.asoundrc" || printf "\e[1;31m:: \e[0malsa reconfiguration failed.  asoundrc1 could not be cat'd into ~/.asoundrc, or so I assume.  Something's wrong at any rate, so check it out!" 
# if true then do                               this, but if this is not true, then do            this and then let me know if it worked or not.  

-----------------
New problem now.  Only one application seems to be able to use the sound card at a time, and I'm not sure why.  Here's what I get when I restart Alsa. 

$ sudo rc.d force-restart alsa
:: Trying to TERM or KILL processes that are blocking ALSA...                                                                                                    [BUSY] Specified filename /dev/snd/by-path: does not exist.
Specified filename pci-0000:00:1b.0 does not exist.
Specified filename /dev/snd/by-path: does not exist.
Specified filename pci-0000:00:1b.0 does not exist.
                                                                                                                                                                 [DONE] 
:: Saving ALSA Levels                                                                                                                                            [DONE] 
:: Restoring ALSA Levels                                                                                                                                         [DONE] 
[palantir@nLorrie modprobe.d]$ sudo rc.d force-restart alsa
:: Trying to TERM or KILL processes that are blocking ALSA...                                                                                                    [BUSY] Specified filename /dev/snd/by-path: does not exist.
Specified filename pci-0000:00:1b.0 does not exist.
Specified filename /dev/snd/by-path: does not exist.
Specified filename pci-0000:00:1b.0 does not exist.
                                                                                                                                                                 [DONE] 
:: Saving ALSA Levels                                                                                                                                            [DONE] 
:: Restoring ALSA Levels              

I can run multiple instances of one program--running ncurses-vlc while running vlc for example--and both work and have sound output, but I can't run a separate program like

speaker-test -c 2 

and expect to get anything at all.  In fact, the above produces an error:

speaker-test 1.0.25

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Playback open error: -16,Device or resource busy

I've done what the wiki says about using dmix and all that stuff and none of it has helped so far.  =/  Any ideas?  I'll try googling and stuff as always.

Last edited by lspci (2012-08-25 08:39:24)


Please don't be a help vampire. | Bitbucket

Give a little more for a little less today.  smile

Offline

Board footer

Powered by FluxBB