#!/bin/sh # Load the mixer settings and OSS compatibility (if enabled) for ALSA. # (the Advanced Linux Sound Architecture) # A function to load the ALSA mixer settings: . /usr/share/alsa/utils.sh load_alsa_mixer() { if [ -r /var/lib/alsa/asound.state ]; then echo "Loading ALSA mixer settings: /usr/sbin/alsactl restore" /usr/sbin/alsactl restore else # It's possible a user might not want to set a default sound state. # In that case, do this: touch /var/lib/alsa/no.asound.state if [ ! -r /var/lib/alsa/no.asound.state ]; then echo "Setting default ALSA mixer settings." # set default mixer volumes for ALSA preinit_levels all sanify_levels all echo "Storing default ALSA mixer settings: /usr/sbin/alsactl store" /usr/sbin/alsactl store fi fi } # If udev or something else has loaded the ALSA modules, then # simply load the mixer settings and make sure the OSS compat # modules are loaded (if enabled): if [ -d /proc/asound ]; then if [ -x /etc/rc.d/rc.alsa-oss ]; then sh /etc/rc.d/rc.alsa-oss fi load_alsa_mixer else # If there are ALSA modules defined in /etc/modprobe.d/*, but # ALSA is not yet loaded, then load the modules now: DRIVERS=$(modprobe -c | grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | tr -s "[[:blank:]]" " " | cut -d " " -f 3) if [ ! "$DRIVERS" = "" ]; then echo "Loading ALSA kernel modules." for module in $DRIVERS; do modprobe $module done fi # If ALSA is now up, then load the mixer settings and OSS modules (if enabled): if [ -d /proc/asound ]; then if [ -x /etc/rc.d/rc.alsa-oss ]; then sh /etc/rc.d/rc.alsa-oss fi load_alsa_mixer fi fi