[Pkg-alsa-devel] [Debian ALSA CVS] debian/alsa-driver/debian (alsa-base.init changelog)

Thomas Hood jdthood-guest@haydn.debian.org
Wed, 08 Sep 2004 07:34:00 -0600


    Date: Wednesday, September 8, 2004 @ 07:34:00
  Author: jdthood-guest
    Path: /cvsroot/pkg-alsa/debian/alsa-driver/debian

Modified: alsa-base.init changelog

Clean up alsa initscript; do alsactl restore in the background


----------------+
 alsa-base.init |  124 +++++++++++++++++++++++++++++--------------------------
 changelog      |    7 +--
 2 files changed, 70 insertions(+), 61 deletions(-)


Index: debian/alsa-driver/debian/alsa-base.init
diff -u debian/alsa-driver/debian/alsa-base.init:1.52 debian/alsa-driver/debian/alsa-base.init:1.53
--- debian/alsa-driver/debian/alsa-base.init:1.52	Mon Sep  6 15:43:25 2004
+++ debian/alsa-driver/debian/alsa-base.init	Wed Sep  8 07:33:56 2004
@@ -9,8 +9,8 @@
 
 if [ "$(id -u)" != "0" ] && [ "$1" != "--help" ] &&
    [ "$1" != "help" ] && [ ! -z "$1" ]; then
-    echo "$0: To $1 ALSA, you must be root."
-    exit 1
+	echo "$0: To $1 ALSA, you must be root."
+	exit 1
 fi
 
 # Default settings
@@ -19,94 +19,102 @@
 
 [ -f /etc/default/alsa ] && . /etc/default/alsa
 
+restore_mixer_settings()
+{
+	# ALSA mixer settings should really be restored via the module loader
+	sleep 5
+	if msg="$(alsactl restore 2>&1)"; then
+		return 0
+	else
+		echo
+		echo "${0}: Error running alsactl: $msg"
+		return 1
+	fi
+}
+
 start()
 {
-	# ALSA mixer settings should be restored via the module loader
-#	printf "Restoring ALSA mixer settings..."
-#	sleep 5
-#	if alsactl restore > /dev/null 2>&1; then
-#	    echo "done."
-#	    return 0
-#	else
-#	    echo "failed. Run 'alsactl restore' manually to view error messages."
-#	    return 1
-#	fi
+	printf "Starting ALSA..."
+	restore_mixer_settings &
+	echo "done."
+	return 0
 }
 
 stop()
 {
 	if [ "$alsactl_store_on_shutdown" != "never autosave" ]; then
-	    if runlevel | grep -E "^$runlevels_save " > /dev/null 2>&1 \
-	    || runlevel | grep -E " $runlevels_save\$" > /dev/null 2>&1; then
-		printf "Storing ALSA mixer settings..."
-		if alsactl store > /dev/null 2>&1; then
-		    sleep 1
-		    echo "done."
-		    return 0
-		else
-		    echo "failed."
-		    return 1
+		if runlevel | grep -E "^$runlevels_save " > /dev/null 2>&1 \
+		   || runlevel | grep -E " $runlevels_save\$" > /dev/null 2>&1
+		then
+			printf "Storing ALSA mixer settings..."
+			if alsactl store > /dev/null 2>&1; then
+				sleep 1
+				echo "done."
+				return 0
+			else
+				echo "failed."
+				return 1
+			fi
 		fi
-	    fi
 	fi
 }
 
 force_stop()
 {
 	set_procs_using_sound() {
-	    procs_using_sound="$(lsof +D /dev -F rt | awk '/^p/ {pid=$1} /^t/ {type=$1} /^r0x(74|e)..$/ && type == "tCHR" {print pid}' | cut -c 2- | uniq)"
+		procs_using_sound="$(lsof +D /dev -F rt | awk '/^p/ {pid=$1} /^t/ {type=$1} /^r0x(74|e)..$/ && type == "tCHR" {print pid}' | cut -c 2- | uniq)"
 	}
 	set_procs_using_sound
 	if [ "$procs_using_sound" ] ; then
-	    printf "Terminating processes: "
-	    for attempt in 1 2 3 ; do
-		printf "${procs_using_sound}..."
-		kill $procs_using_sound || :
-		sleep 1
+		printf "Terminating processes: "
+		for attempt in 1 2 3 ; do
+			printf "${procs_using_sound}..."
+			kill $procs_using_sound || :
+			sleep 1
+			set_procs_using_sound
+			[ "$procs_using_sound" ] || break
+		done
+		# Either no more procs using sound or attempts ran out
+		if [ "$procs_using_sound" ] ; then
+			printf "(with SIGKILL) ${procs_using_sound}..."
+			kill -9 $procs_using_sound || :
+			sleep 1
+		fi
 		set_procs_using_sound
-		[ "$procs_using_sound" ] || break
-	    done
-	    # Either no more procs using sound or attempts ran out
-	    if [ "$procs_using_sound" ] ; then
-		printf "(with SIGKILL) ${procs_using_sound}..."
-		kill -9 $procs_using_sound || :
-		sleep 1
-	    fi
-	    set_procs_using_sound
-	    if [ "$procs_using_sound" ] ; then
-		echo "failed."
-		return 1
-	    fi
-	    echo "done."
+		if [ "$procs_using_sound" ] ; then
+			echo "failed."
+			return 1
+		fi
+		echo "done."
 	fi
 	stop || :
 	rmmod=""
 	case "$(modprobe --version 2>&1)" in
-	    modprobe*) rmmod="rmmod -r" ;;
-	    module-init-tools*) rmmod="modprobe -r" ;;
+		modprobe*) rmmod="rmmod -r" ;;
+		module-init-tools*) rmmod="modprobe -r" ;;
 	esac
 	printf "Unloading sound driver modules..."
 	for i in $(lsmod | awk '/^snd/ {print $1}'); do
-	    $rmmod $i >/dev/null 2>&1 || :
+		$rmmod $i >/dev/null 2>&1 || :
 	done
 	if [ "$(lsmod | awk '/^snd/ {print $1}')" ] ; then
-	    echo "failed."
-	    return 1
+		echo "failed."
+		return 1
 	else
-	    echo "done."
-	    return 0
+		echo "done."
+		return 0
 	fi
 }
 
 case "$1" in
-    start) start ;;
-    stop) stop ;;
-    restart) stop ; start ;;
-    reload) stop && start ;;
-    force-stop) force_stop ;;
-    force-restart) force_stop ; start ;;
-    force-reload) force-stop && start ;;
-    *)
+	start) start ;;
+	stop) stop ;;
+	restart) stop ; start ;;
+	reload) stop && start ;;
+	force-stop) force_stop ;;
+	force-restart) force_stop ; start ;;
+	force-reload) force-stop && start ;;
+	*)
 	echo "Usage: /etc/init.d/alsa {start|stop|restart|reload|force-stop|force-reload}" >&2
 	exit 3
 	;;
Index: debian/alsa-driver/debian/changelog
diff -u debian/alsa-driver/debian/changelog:1.273 debian/alsa-driver/debian/changelog:1.274
--- debian/alsa-driver/debian/changelog:1.273	Wed Sep  8 07:02:35 2004
+++ debian/alsa-driver/debian/changelog	Wed Sep  8 07:33:56 2004
@@ -32,6 +32,7 @@
     - Update Catalan Debconf translation.
   * Thomas Hood:
     - /etc/init.d/alsa:
+      + Clean up indentation
       + Don't fail if kill fails because of disappeared process
         (Closes: #269494)
       + Tell the user if processes couldn't be stopped or if
@@ -41,9 +42,9 @@
       + On restart, attempt start even if stop fails
       + On force-reload, start after force-stop
       + Don't pad '...' with spaces (as per policy 9.4)
-      + Don't restore mixer levels in the start method.  In order
-        to avoid lost races this is now done by the module loader
-        (see #268221).  (Closes: #270419)
+      + On start, attempt to restore mixer levels in the background.
+        In order to avoid lost races this should really be done by the
+        module loader (see #268221).  (Closes: #270419)
     - /etc/default/alsa
       + Try to improve comments some more
     - /etc/apm/event.d/alsa