1 | #!/bin/sh |
---|
2 | # Load the mixer settings and OSS compatibility for ALSA. |
---|
3 | # (the Advanced Linux Sound Architecture) |
---|
4 | |
---|
5 | # A function to load the ALSA mixer settings: |
---|
6 | load_alsa_mixer() { |
---|
7 | if [ -r /etc/asound.state ]; then |
---|
8 | echo "Loading ALSA mixer settings: /usr/sbin/alsactl restore" |
---|
9 | /usr/sbin/alsactl restore |
---|
10 | else |
---|
11 | echo "ALSA warning: No mixer settings found in /etc/asound.state." |
---|
12 | echo " Sound may be muted. Use 'alsamixer' to unmute your sound card," |
---|
13 | echo " and then 'alsactl store' to save the default ALSA mixer settings" |
---|
14 | echo " to be loaded at boot." |
---|
15 | fi |
---|
16 | } |
---|
17 | |
---|
18 | # A function to load the ALSA OSS compat modules: |
---|
19 | load_alsa_oss_modules() { |
---|
20 | if ! cat /proc/modules | tr _ - | grep -wq snd-pcm-oss ; then |
---|
21 | echo "Loading OSS compatibility modules for ALSA." |
---|
22 | modprobe snd-pcm-oss |
---|
23 | modprobe snd-mixer-oss |
---|
24 | modprobe snd-seq-oss |
---|
25 | fi |
---|
26 | } |
---|
27 | |
---|
28 | # If hotplug or something else has loaded the ALSA modules, then |
---|
29 | # simply load the mixer settings and make sure the OSS compat |
---|
30 | # modules are loaded: |
---|
31 | if [ -d /proc/asound ]; then |
---|
32 | load_alsa_mixer |
---|
33 | load_alsa_oss_modules |
---|
34 | else |
---|
35 | # If there are ALSA modules defined in /etc/modules.conf, but |
---|
36 | # ALSA is not yet loaded, then load the modules now: |
---|
37 | DRIVERS=`modprobe -c | grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | awk '{ print $3 }'` |
---|
38 | if [ ! "$DRIVERS" = "" ]; then |
---|
39 | echo "Loading ALSA kernel modules." |
---|
40 | for module in $DRIVERS; do |
---|
41 | modprobe $module |
---|
42 | done |
---|
43 | fi |
---|
44 | # If ALSA is now up, then load the mixer settings and OSS modules: |
---|
45 | if [ -d /proc/asound ]; then |
---|
46 | load_alsa_mixer |
---|
47 | load_alsa_oss_modules |
---|
48 | fi |
---|
49 | fi |
---|