Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #101121 handle multiple sound cards...
- if [ $PUPMODE -eq 5 ];then
- ## if there is more than 1 soundcard
- ## sometimes only 1 card is configured when 10alsa runs for the 1st time (if if takes too much time to load, then it is a total failure)
- ## ensure adjusting volume levels to all soundcards
- rm -f /etc/asound.state
- /etc/init.d/10alsa restart
- ## Multiple Sound Card Wizard
- scards=`grep '\[.*\]' /proc/asound/cards | grep -v 'pcsp' | wc -l`
- [ $scards -gt 1 ] && Multiple-Sound-Card-Wizard #by kirk
- else
- ## Multiple Sound Card Wizard
- ## Sometimes cards swap/change positions
- ## - A pci/usb card has been removed [Unable to open card hw:1, snd_hctl_open returned -2]
- ## - A card suddenly gets loaded first
- ## - Other reasons
- ## /etc/asound.conf may be wrong
- ## $HOME/.retrovolrc may be using the wrong device
- ## %% Logic to rewrite config for proper use at bootup
- if [ -f /var/log/mswc-selected ] ; then
- #card 0: V8235 [VIA 8235], device 0: VIA 8235
- read -r c card desc <<< "$(cat /var/log/mswc-selected)"
- card=${card%:}
- active_card=$(echo $desc | sed -e 's|\[||g' -e 's|\]||g' -e 's|\,||g' -e 's|\:||g' -e 's|\/||g' -e 's|\\||g' -e 's|\-||g')
- card_list=$(aplay -l | grep card | sed -e 's|\[||g' -e 's|\]||g' -e 's|\,||g' -e 's|\:||g' -e 's|\/||g' -e 's|\-||g')
- ncards=$(echo "$cardlist" | grep -v pcsp | wc -l)
- xcard=0
- if [ $ncards -gt 1 ] ; then
- ## more than 1 card, this requires processing
- results=$(echo "$card_list" | grep "$active_card")
- if [ "$results" ] ; then
- read -r c2 card2 desc2 <<< "$results"
- card2=${card2%:}
- #echo $card $card2
- if [ "$card" = "$card2" ] ; then
- xcard=$card ## card is in its right position
- else
- xcard=$card2 ## card has changed position
- fi
- fi
- fi
- ## apply changes
- #echo $xcard
- if [ -f /etc/asound.conf ] ; then
- sed -i "s|defaults.pcm.card.*|defaults.pcm.card $xcard|" /etc/asound.conf
- else
- echo "defaults.pcm.card $xcard" > /etc/asound.conf
- echo "defaults.pcm.device 0" >> /etc/asound.conf
- fi
- if [ -f $HOME/.retrovolrc ] ; then
- sed -i -e "/^card=hw/d;/#card=hw:0/a card=hw:${xcard}" $HOME/.retrovolrc
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement