summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <eradicator@gentoo.org>2004-06-08 02:34:45 +0000
committerJeremy Huddleston <eradicator@gentoo.org>2004-06-08 02:34:45 +0000
commitfdefbd7ca89475985e70e0a71abb7f9cd07a041d (patch)
tree8a00a99423decff802a7322a0d9995aa40f24b84 /media-sound/alsa-utils
parentstable on amd64 (Manifest recommit) (diff)
downloadgentoo-2-fdefbd7ca89475985e70e0a71abb7f9cd07a041d.tar.gz
gentoo-2-fdefbd7ca89475985e70e0a71abb7f9cd07a041d.tar.bz2
gentoo-2-fdefbd7ca89475985e70e0a71abb7f9cd07a041d.zip
Small beautification changes to init script.
Diffstat (limited to 'media-sound/alsa-utils')
-rw-r--r--media-sound/alsa-utils/ChangeLog5
-rw-r--r--media-sound/alsa-utils/files/alsasound200
2 files changed, 119 insertions, 86 deletions
diff --git a/media-sound/alsa-utils/ChangeLog b/media-sound/alsa-utils/ChangeLog
index 24028276a059..f4511e8f6297 100644
--- a/media-sound/alsa-utils/ChangeLog
+++ b/media-sound/alsa-utils/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for media-sound/alsa-utils
# Copyright 2002-2004 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/ChangeLog,v 1.55 2004/05/31 05:00:04 eradicator Exp $
+# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/ChangeLog,v 1.56 2004/06/08 02:34:45 eradicator Exp $
+
+ 07 Jun 2004; Jeremy Huddleston <eradicator@gentoo.org> files/alsasound:
+ Small beautification changes to init script.
*alsa-utils-1.0.5 (30 May 2004)
diff --git a/media-sound/alsa-utils/files/alsasound b/media-sound/alsa-utils/files/alsasound
index 5bdb1d8875ac..22b80ef69062 100644
--- a/media-sound/alsa-utils/files/alsasound
+++ b/media-sound/alsa-utils/files/alsasound
@@ -1,5 +1,5 @@
#!/sbin/runscript
-# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound,v 1.12 2004/03/31 03:10:07 eradicator Exp $
+# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound,v 1.13 2004/06/08 02:34:45 eradicator Exp $
#
# Gentoo users: add this script to 'boot' run level.
# ==================================================
@@ -31,6 +31,10 @@
# John Mylchreest <johnm@gentoo.org>
# July 29, 2003
+# Rewritten for better support for built-in drivers
+# Jeremy Huddleston <eradicator@gentoo.org>
+# 2004.06.02
+
alsactl=/usr/sbin/alsactl
asoundcfg=/etc/asound.state
aconnect=/usr/bin/aconnect
@@ -43,74 +47,96 @@ depend() {
provide alsa-modules
}
-start() {
- if [ -d /proc/asound ] && [ -z "$(grep ' no soundcards ' /proc/asound/cards)" ] ; then
- ebegin "ALSA Detected"
- else
- ebegin "Loading ALSA drivers"
-
- DRIVERS="$(modprobe -c | grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | awk '{print $3}')"
-
- if modprobe -c | grep -q "snd.*oss$" ; then
- # Test for use of OSS
- einfo "Using ALSA OSS emulation"
- OSS="$(modprobe -l | grep "snd.*oss" | sed -e "s:\/.*\/::" -e "s:\..*::")"
- # Add oss modules to list
- for i in ${OSS}
- do
- DRIVERS="${i} ${DRIVERS}"
- done
- fi
-
- # Fall back on the automated aliases if we don't have ALSA configured properly...
- if [ -z "${DRIVERS}" ]; then
- ewarn "Could not detect custom ALSA settings. Loading all detected alsa drivers."
- DRIVERS="$(modprobe -c | grep pci: | awk '{ print $3 }' | grep snd.* | sort | uniq)"
- fi
-
- [ -z "${DRIVERS}" ] && eerror "Unable to find any ALSA drivers. Have you compiled alsa-drivers correctly?"
+load_modules() {
+ DRIVERS="$(modprobe -c | grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | awk '{print $3}')"
- for DRIVER in ${DRIVERS}
+ if modprobe -c | grep -q "snd.*oss$" ; then
+ # Test for use of OSS
+ einfo "Using ALSA OSS emulation"
+ OSS="$(modprobe -l | grep "snd.*oss" | sed -e "s:\/.*\/::" -e "s:\..*::")"
+ # Add oss modules to list
+ for i in ${OSS}
do
- if [ ! "${DRIVER}" = off ] &&
- [ -z `cut -d' ' -f1 /proc/modules | egrep "^${DRIVER}\$"` ] &&
- [ -z `cut -d' ' -f1 /proc/modules | egrep "^${DRIVER//-/_}\$"` ]; then
- einfo "Loading: ${DRIVER}"
- /sbin/modprobe ${DRIVER}
- fi
+ DRIVERS="${i} ${DRIVERS}"
done
+ fi
- sleep 1
-
- if [ -f /proc/asound/seq/drivers ] ; then
- # We want to ensure snd-seq is loaded as it is needed for things like timidity even if
- # we don't use a real sequencer.
- SEQUENCERS="snd-seq $(awk -F, '$2~/^empty$/ {print $1}' /proc/asound/seq/drivers)"
- for SEQUENCER in ${SEQUENCERS}
- do
- if [ -z `cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER}\$"` ] &&
- [ -z `cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER//-/_}\$"` ]; then
- einfo "Loading: ${SEQUENCER}"
- [ -n "${SEQUENCER}" ] && /sbin/modprobe ${SEQUENCER}
- fi
- done
+ # Fall back on the automated aliases if we don't have ALSA configured properly...
+ if [ -z "${DRIVERS}" ]; then
+ ewarn "Could not detect custom ALSA settings. Loading all detected alsa drivers."
+ DRIVERS="$(modprobe -c | grep pci: | awk '{ print $3 }' | grep snd.* | sort | uniq)"
+ fi
+
+ [ -z "${DRIVERS}" ] && eerror "Unable to find any ALSA drivers. Have you compiled alsa-drivers correctly?"
+
+ for DRIVER in ${DRIVERS}
+ do
+ if [ ! "${DRIVER}" = off ] &&
+ [ -z `cut -d' ' -f1 /proc/modules | egrep "^${DRIVER}\$"` ] &&
+ [ -z `cut -d' ' -f1 /proc/modules | egrep "^${DRIVER//-/_}\$"` ]; then
+ einfo "Loading: ${DRIVER}"
+ /sbin/modprobe ${DRIVER}
fi
+ done
- einfo "Running card-dependent scripts"
- for DRIVER in ${DRIVERS}
+ sleep 1
+
+ if [ -f /proc/asound/seq/drivers ] ; then
+ # We want to ensure snd-seq is loaded as it is needed for things like timidity even if
+ # we don't use a real sequencer.
+ SEQUENCERS="snd-seq $(awk -F, '$2~/^empty$/ {print $1}' /proc/asound/seq/drivers)"
+ for SEQUENCER in ${SEQUENCERS}
do
- TMP=${DRIVER##snd-}
- TMP=${TMP##snd_}
- [ -x "${alsascrdir}/${TMP}" ] && ${alsascrdir}/${TMP}
+ if [ -z `cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER}\$"` ] &&
+ [ -z `cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER//-/_}\$"` ]; then
+ einfo "Loading: ${SEQUENCER}"
+ [ -n "${SEQUENCER}" ] && /sbin/modprobe ${SEQUENCER}
+ fi
done
-
- [ ! -d /proc/asound ] && eerror "ERROR: Failed to load necessary drivers"
fi
+
+ einfo "Running card-dependent scripts"
+ for DRIVER in ${DRIVERS}
+ do
+ TMP=${DRIVER##snd-}
+ TMP=${TMP##snd_}
+ [ -x "${alsascrdir}/${TMP}" ] && ${alsascrdir}/${TMP}
+ done
+
+ [ ! -d /proc/asound ] && eerror "ERROR: Failed to load necessary drivers"
+}
+
+unload_modules() {
+ LOADED_MODULES="$(/sbin/lsmod | grep -E "^snd" | awk '{print $1}')"
+ for MODULE in ${LOADED_MODULES}
+ do
+ /sbin/rmmod ${MODULE} 2> /dev/null
+ done
+ /sbin/rmmod soundcore 2> /dev/null
+ /sbin/rmmod gameport 2> /dev/null
+}
+
+terminate() {
+ #
+ # Kill processes holding open sound devices
+ #
+ # DEVS=`find /dev/ -follow -type c -maxdepth 1 -print 2>/dev/null | xargs ls -dils | grep "1*1[46]," | cut -d: -f2 | cut -d" " -f2; echo /proc/asound/dev/*`
+ ossdevs="/dev/admmidi? /dev/adsp? /dev/amidi? /dev/audio* /dev/dmfm* \
+ /dev/dmmidi? /dev/dsp* /dev/dspW* /dev/midi0? /dev/mixer? /dev/music \
+ /dev/patmgr? /dev/sequencer* /dev/sndstat"
+ alsadevs="/proc/asound/dev/* /dev/sound/* /dev/snd/*"
+ fuser -k $ossdevs $alsadevs 2> /dev/null 1>/dev/null
- einfo "Restoring Mixer Levels"
+ #
+ # remove all sequencer connections if any
+ #
+ [ -f /proc/asound/seq/clients -a -x $aconnect ] && $aconnect --removeall
+}
+
+restore_mixer() {
if [ ! -r $asoundcfg ]; then
ewarn "No mixer config in $asoundcfg, you have to unmute your card!"
- eend 1
+ return 1
elif [ -x $alsactl ]; then
CARDS="$(cat /proc/asound/cards | awk '/: / { print $1 }')"
for CARDNUM in ${CARDS}
@@ -123,8 +149,33 @@ start() {
done
else
eerror -e "ERROR: Cannot find alsactl, did you forget to install media-sound/alsa-utils?"
- eend 1
+ return 1
+ fi
+
+ return 0
+}
+
+save_mixer() {
+ if [ -x $alsactl ]; then
+ $alsactl -f $asoundcfg store
+ else
+ eerror -e "ERROR: Cannot find alsactl, did you forget to install media-sound/alsa-utils?"
+ return 1
+ fi
+
+ return 0
+}
+
+start() {
+ if [ -d /proc/asound ] && [ -z "$(grep ' no soundcards ' /proc/asound/cards)" ] ; then
+ ebegin "ALSA Detected"
+ else
+ ebegin "Loading ALSA drivers"
+ load_modules
fi
+
+ einfo "Restoring Mixer Levels"
+ restore_mixer
eend 0
}
@@ -136,38 +187,17 @@ stop() {
ebegin "Unloading ALSA"
terminate
+
einfo "Storing ALSA Mixer Levels"
- if [ -x $alsactl ]; then
- $alsactl -f $asoundcfg store
- else
- eerror -e "ERROR: Cannot find alsactl, did you forget to install media-sound/alsa-utils?"
+ if ! save_mixer; then
eend 1
fi
- LOADED_MODULES="$(/sbin/lsmod | grep -E "^snd" | awk '{print $1}')"
einfo "Unloading modules"
- for MODULE in ${LOADED_MODULES}
- do
- /sbin/rmmod ${MODULE} 2> /dev/null
- done
- /sbin/rmmod soundcore 2> /dev/null
- /sbin/rmmod gameport 2> /dev/null
+ if ! unload_modules; then
+ eend 1
+ fi
+
eend 0
}
-terminate() {
- #
- # Kill processes holding open sound devices
- #
- # DEVS=`find /dev/ -follow -type c -maxdepth 1 -print 2>/dev/null | xargs ls -dils | grep "1*1[46]," | cut -d: -f2 | cut -d" " -f2; echo /proc/asound/dev/*`
- ossdevs="/dev/admmidi? /dev/adsp? /dev/amidi? /dev/audio* /dev/dmfm* \
- /dev/dmmidi? /dev/dsp* /dev/dspW* /dev/midi0? /dev/mixer? /dev/music \
- /dev/patmgr? /dev/sequencer* /dev/sndstat"
- alsadevs="/proc/asound/dev/* /dev/sound/* /dev/snd/*"
- fuser -k $ossdevs $alsadevs 2> /dev/null 1>/dev/null
-
- #
- # remove all sequencer connections if any
- #
- [ -f /proc/asound/seq/clients -a -x $aconnect ] && $aconnect --removeall
-}