Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #101121 handle multiple sound cards...
  2. if [ $PUPMODE -eq 5 ];then
  3. ## if there is more than 1 soundcard
  4. ## 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)
  5. ## ensure adjusting volume levels to all soundcards
  6. rm -f /etc/asound.state
  7. /etc/init.d/10alsa restart
  8. ## Multiple Sound Card Wizard
  9. scards=`grep '\[.*\]' /proc/asound/cards | grep -v 'pcsp' | wc -l`
  10. [ $scards -gt 1 ] && Multiple-Sound-Card-Wizard #by kirk
  11. else
  12. ## Multiple Sound Card Wizard
  13. ## Sometimes cards swap/change positions
  14. ## - A pci/usb card has been removed [Unable to open card hw:1, snd_hctl_open returned -2]
  15. ## - A card suddenly gets loaded first
  16. ## - Other reasons
  17. ## /etc/asound.conf may be wrong
  18. ## $HOME/.retrovolrc may be using the wrong device
  19. ## %% Logic to rewrite config for proper use at bootup
  20. if [ -f /var/log/mswc-selected ] ; then
  21. #card 0: V8235 [VIA 8235], device 0: VIA 8235
  22. read -r c card desc <<< "$(cat /var/log/mswc-selected)"
  23. card=${card%:}
  24. 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')
  25. 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')
  26. ncards=$(echo "$cardlist" | grep -v pcsp | wc -l)
  27. xcard=0
  28. if [ $ncards -gt 1 ] ; then
  29. ## more than 1 card, this requires processing
  30. results=$(echo "$card_list" | grep "$active_card")
  31. if [ "$results" ] ; then
  32. read -r c2 card2 desc2 <<< "$results"
  33. card2=${card2%:}
  34. #echo $card $card2
  35. if [ "$card" = "$card2" ] ; then
  36. xcard=$card ## card is in its right position
  37. else
  38. xcard=$card2 ## card has changed position
  39. fi
  40. fi
  41. fi
  42. ## apply changes
  43. #echo $xcard
  44. if [ -f /etc/asound.conf ] ; then
  45. sed -i "s|defaults.pcm.card.*|defaults.pcm.card $xcard|" /etc/asound.conf
  46. else
  47. echo "defaults.pcm.card $xcard" > /etc/asound.conf
  48. echo "defaults.pcm.device 0" >> /etc/asound.conf
  49. fi
  50. if [ -f $HOME/.retrovolrc ] ; then
  51. sed -i -e "/^card=hw/d;/#card=hw:0/a card=hw:${xcard}" $HOME/.retrovolrc
  52. fi
  53. fi
  54. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement