]> git.pld-linux.org Git - packages/alsa-utils.git/blobdiff - alsasound.init
up to 1.2.1
[packages/alsa-utils.git] / alsasound.init
index 9ce5c49e5d0d343eb428916346be250b8dc05dd8..6c66b7e5bd8fd4c5d638e0b9a8a944fb9abaf7f6 100644 (file)
@@ -3,8 +3,6 @@
 # alsasound    This shell script takes care of starting and stopping \
 #              ALSA sound driver.
 #
-# This script requires /usr/sbin/alsactl program from alsa-utils package.
-#
 # Copyright (c) by Jaroslav Kysela <perex@jcu.cz>
 #
 #  This program is free software; you can redistribute it and/or modify
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-if [ $(kernelverser) = "002006" ]; then
-       MODULES_CONF=/etc/modprobe.conf
-elif [ -r /etc/modules.conf ]; then
-       MODULES_CONF=/etc/modules.conf
-else
-       MODULES_CONF=/etc/conf.modules
-fi
-
 driver_start()
 {
   #
   # insert all sound modules
   #
-  if OLDLOGLEV=$(awk '{print $1}' < /proc/sys/kernel/printk 2> /dev/null); then
-       /sbin/loglevel 1
-  fi
-  awk '$1 == "alias" && $3 != "off" && ($2 ~ /^snd-card-[0-9]$/) {print $2}' < $MODULES_CONF | \
+  modprobe -c | awk '$1 == "alias" && $3 != "off" && ($2 ~ /^snd-card-[0-9]$/) {print $3}' | \
     while read line; do \
       msg_starting "sound driver: $line"
       busy
       /sbin/modprobe $line
       ok
     done
-  awk '$1 == "alias" && $3 != "off" && ($2 ~ /^sound-service-[0-9]-[0-9]+$/) {print $2}' < $MODULES_CONF | \
+  modprobe -c | awk '$1 == "alias" && $3 != "off" && ($2 ~ /^sound-service-[0-9]-[0-9]+$/) {print $3}' | \
     while read line; do \
       msg_starting "sound driver: $line"
       busy
       /sbin/modprobe $line
       ok
     done
-  if [ -n "$OLDLOGLEV" ]; then
-       /sbin/loglevel "$OLDLOGLEV"
-  fi
-  #
-  # restore driver settings
-  #
-  if [ -x /usr/sbin/alsactl ]; then
-    if [ -f /etc/asound.state ]; then
-      if [ "$(kernelver)" -lt "002006012" ]; then
-       for i in 1 2 3 4; do
-         [ -a /dev/snd/controlC0 ] && break
-         sleep 1
-       done
-      fi
-      /usr/sbin/alsactl restore
-    fi
-  else
-    show "ERROR: alsactl not found"; fail
-  fi
 }
 
 detect_stop()
@@ -86,21 +54,13 @@ detect_stop()
   #
   # remove all sound modules
   #
-  /sbin/lsmod | awk '/^snd/ { print $0 }' | while read line; do \
-     /sbin/rmmod `echo $line | cut -d ' ' -f 1`; \
+  /sbin/lsmod | awk '/^(snd|ac97_bus)/ { print $1 }' | while read module; do \
+     /sbin/rmmod $module
   done
 }
 
 driver_stop()
 {
-  #
-  # store driver settings
-  #
-  if [ -x /usr/sbin/alsactl ]; then
-    /usr/sbin/alsactl store
-  else
-    show '!!!alsactl not found!!!'; fail
-  fi
   #
   # remove all sound modules
   #
@@ -139,6 +99,11 @@ start() {
                        msg_already_running "ALSA driver"
                fi
        fi
+       # "restore" is handled via udev if running; if not, do it manually
+       if is_no "$START_UDEV" && [ -f /var/lib/alsa/asound.state ]; then
+               sleep 1
+               /sbin/alsactl restore
+       fi
 }
 
 # Stop daemons.
@@ -159,7 +124,18 @@ stop() {
        else
                msg_not_running "ALSA driver"
        fi
-fi
+}
+
+condrestart() {
+       if [ -f /var/lock/subsys/alsasound ]; then
+               stop
+               start
+       else
+               msg_not_running "ALSA driver"
+               RETVAL=$1
+       fi
+}
+
 
 # See how we were called.
 case "$1" in
@@ -169,15 +145,21 @@ case "$1" in
   stop)
        stop
        ;;
-  restart|force-reload)
+  restart)
        stop
        start
        ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
   status)
        # TODO
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
        exit 3
 esac
 
This page took 0.04648 seconds and 4 git commands to generate.