kevin liu wrote:
> Then thanks so much.:-)
>
> On Dec 3, 2007 11:10 PM, Yan Seiner <[EMAIL PROTECTED]> wrote:
>
>> kevin liu wrote:
>>
>>> Dear:
>>> I want to use snd-usb-audio to drive my usb audio stream interface.
>>> Just now, I got the correct tv program sound by accident using the
>>> driver.
>>> I even don't know how I did that, but after I unplugged my tv card
>>> and plugged
>>> again, the driver doesn't work again
>>> I am going crazy by Linux sound system.
>>> Anybody give me any clue?
>>>
>>>
>> Sure, but it will have to be later today. I've just set up a mutiple
>> soundcard system, so I think I have a clue or two.
>>
OK, the problem is that the kernel assigns card numbers based on
whatever it wants, so the cards can move around each time you boot the
system.
You can try to do all sorts of stuff with modules, but I like to deal
with it in userspace.
So once the system boots, you need to find out where your cards went. I
have a system with 3 cards, and I need to know which card went where.
The system has one on-board card, and two usb cards, so I tell the USB
cards by which bus they're plugged into.
Here's the script I use:
#!/bin/sh
echo "#automatically created sound file DO NOT EDIT" > /etc/asound_card.conf
for card in /proc/asound/card[0-7] ; do
if [[ -e $card/usbbus ]] ; then
# we have a usb sound card
if [[ `cat $card/usbbus | cut -f1 -d/` == "004" ]] ; then
# This one gets matched up with DISPLAY 0
echo SOUND1=`echo $card | sed -e s/^.*card//` >>
/etc/asound_card.conf
elif [[ `cat $card/usbbus | cut -f1 -d/` == "003" ]] ; then
# This one gets matched up with DISPLAY 1
echo SOUND2=`echo $card | sed -e s/^.*card//` >>
/etc/asound_card.conf
fi
else # we have the on-board sound
echo SOUND0=`echo $card | sed -e s/^.*card//` >>
/etc/asound_card.conf
fi
done
The script runs every time alsa is started, after the modules load. It
creates a file, /etc/asound_card.conf, with three lines:
SOUND0=x
SOUND1=y
SOUND2=z
SOUND0 is the on-board card, SOUND1 is one of the USB cards, and SOUND2
is the other USB card, and the USB cards won't ever be swapped, because
I am locating them by the physical port they're plugged into.
So now, to use the onboard card, all I do is
. /etc/asound_card.conf
ALSA_CARD=$SOUND0
to switch my card to the first USB card, I do
ALSA_CARD=$SOUND1
(Actually, I set the card for each display; I added this to
/etc/bash.bashrc:
. /etc/asound_card.conf
if [ ${DISPLAY+1} == 1 ] ; then
[[ -f /etc/asound_card.conf ]] && . /etc/asound_card.conf
export ALSA_CARD=`eval echo '$SOUND'$(echo $DISPLAY | cut -f2
-d: | cut -f1 -d.)`
export LD_PRELOAD=/usr/lib/libaoss.so
fi
so DISPLAY1 always gets SOUND1 and so on.
HTH,
--Yan
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Alsa-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-user