diff options
author | Jeremy Huddleston <eradicator@gentoo.org> | 2005-04-21 09:07:45 +0000 |
---|---|---|
committer | Jeremy Huddleston <eradicator@gentoo.org> | 2005-04-21 09:07:45 +0000 |
commit | ca8fb146f9f752f8306a87b750dfbcc8a1c849b4 (patch) | |
tree | 6c2fc3c3a5ff23eb9b01dc431085607b5be72f97 /media-sound | |
parent | Missing dependancy on gnome-base/libgnomeui (diff) | |
download | gentoo-2-ca8fb146f9f752f8306a87b750dfbcc8a1c849b4.tar.gz gentoo-2-ca8fb146f9f752f8306a87b750dfbcc8a1c849b4.tar.bz2 gentoo-2-ca8fb146f9f752f8306a87b750dfbcc8a1c849b4.zip |
Cleaned up alsasound init script. Added RESTORE_ON_START and ENABLE_OSS_EMUL options.
(Portage version: 2.0.51.19)
Diffstat (limited to 'media-sound')
-rw-r--r-- | media-sound/alsa-utils/ChangeLog | 7 | ||||
-rw-r--r-- | media-sound/alsa-utils/files/alsasound | 115 | ||||
-rw-r--r-- | media-sound/alsa-utils/files/alsasound.confd | 15 |
3 files changed, 89 insertions, 48 deletions
diff --git a/media-sound/alsa-utils/ChangeLog b/media-sound/alsa-utils/ChangeLog index 27f259baf186..da2d9283cefd 100644 --- a/media-sound/alsa-utils/ChangeLog +++ b/media-sound/alsa-utils/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog for media-sound/alsa-utils # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/ChangeLog,v 1.91 2005/04/12 07:56:46 eradicator Exp $ +# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/ChangeLog,v 1.92 2005/04/21 09:07:45 eradicator Exp $ + + 21 Apr 2005; Jeremy Huddleston <eradicator@gentoo.org> files/alsasound, + files/alsasound.confd: + Cleaned up alsasound init script. Added RESTORE_ON_START and ENABLE_OSS_EMUL + options. 12 Apr 2005; Jeremy Huddleston <eradicator@gentoo.org> -alsa-utils-0.9.8.ebuild, -alsa-utils-1.0.6.ebuild: diff --git a/media-sound/alsa-utils/files/alsasound b/media-sound/alsa-utils/files/alsasound index 99f35aa9276a..a5698c50cb52 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.22 2005/01/31 21:44:54 eradicator Exp $ +# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound,v 1.23 2005/04/21 09:07:45 eradicator Exp $ # # Gentoo users: add this script to 'boot' run level. # ================================================== @@ -40,6 +40,10 @@ # # 2004.11.29 - Jeremy Huddleston <eradicator@gentoo.org> # Added save option thanks to Ben Anderson <roothorick@new.rr.com> +# +# 2005.04.21 - Jeremy Huddleston <eradicator@gentoo.org> +# Added restore option and oss option. +# Cleaned up code to use bash builtins instead of test. alsactl=/usr/sbin/alsactl asoundcfg=/etc/asound.state @@ -55,19 +59,20 @@ depend() { load_modules() { # List of drivers for each card. - DRIVERS="$(modprobe -c | grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | awk '{print $2}')" + local DRIVERS="$(modprobe -c | grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | awk '{print $2}')" # Fall back on the automated aliases if we don't have ALSA configured properly... - if [ -z "${DRIVERS}" ] && ! ([ -d /proc/asound ] && [ -z "$(grep ' no soundcards ' /proc/asound/cards)" ]); then + if [[ -z "${DRIVERS}" && ! ( -d /proc/asound && -z "$(grep ' no soundcards ' /proc/asound/cards)" ) ]] ; 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)" - [ -z "${DRIVERS}" ] && eerror "Unable to find any ALSA drivers. Have you compiled alsa-drivers correctly?" + [[ -z "${DRIVERS}" ]] && eerror "Unable to find any ALSA drivers. Have you compiled alsa-drivers correctly?" fi - if modprobe -c | grep -q "snd.*oss$" ; then + if [[ ${ENABLE_OSS_EMUL} == "yes" ]] && modprobe -c | grep -q "snd.*oss$" ; then # Test for use of OSS - OSS="$(modprobe -l | grep "snd.*oss" | sed -e "s:\/.*\/::" -e "s:\..*::")" + local OSS="$(modprobe -l | grep "snd.*oss" | sed -e "s:\/.*\/::" -e "s:\..*::")" # Add oss modules to list + local i for i in ${OSS} do DRIVERS="${DRIVERS} ${i}" @@ -82,11 +87,12 @@ load_modules() { # compatibility DRIVERS="${DRIVERS} $(modprobe -l | grep "snd.ioctl32\." | sed -e "s:\/.*\/::" -e "s:\..*::")" + local DRIVER 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 + if [[ "${DRIVER}" != "off" && + -z $(cut -d' ' -f1 /proc/modules | egrep "^${DRIVER}\$") && + -z $(cut -d' ' -f1 /proc/modules | egrep "^${DRIVER//-/_}\$") ]] ; then ebegin " Loading: ${DRIVER}" /sbin/modprobe ${DRIVER} eend $? @@ -95,12 +101,13 @@ load_modules() { sleep 1 - if [ -f /proc/asound/seq/drivers ] ; then - SEQUENCERS="$(awk -F, '$2~/^empty$/ {print $1}' /proc/asound/seq/drivers)" + if [[ -f /proc/asound/seq/drivers ]] ; then + local SEQUENCERS="$(awk -F, '$2~/^empty$/ {print $1}' /proc/asound/seq/drivers)" + local SEQUENCER for SEQUENCER in ${SEQUENCERS} do - if [ -z `cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER}\$"` ] && - [ -z `cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER//-/_}\$"` ]; then + if [[ -z $(cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER}\$") && + -z $(cut -d' ' -f1 /proc/modules | egrep "^${SEQUENCER//-/_}\$") ]] ; then ebegin " Loading: ${SEQUENCER}" /sbin/modprobe ${SEQUENCER} eend $? @@ -110,22 +117,23 @@ load_modules() { for DRIVER in ${DRIVERS} do - TMP=${DRIVER##snd-} + local TMP=${DRIVER##snd-} TMP=${TMP##snd_} - if [ -x "${alsascrdir}/${TMP}" ]; then + if [[ -x "${alsascrdir}/${TMP}" ]] ; then ebegin " Running: ${alsascrdir}/${TMP}" ${alsascrdir}/${TMP} eend $? fi done - if [ ! -d /proc/asound ] || [ ! -z "$(grep ' no soundcards ' /proc/asound/cards)" ]; then + if [[ ! -d /proc/asound || -n "$(grep ' no soundcards ' /proc/asound/cards)" ]] ; then eerror "ERROR: Failed to load necessary drivers" fi } unload_modules() { - LOADED_MODULES="$(/sbin/lsmod | grep -E "^snd" | awk '{print $1}')" + local LOADED_MODULES="$(/sbin/lsmod | grep -E "^snd" | awk '{print $1}')" + local MODULE for MODULE in ${LOADED_MODULES} do /sbin/rmmod ${MODULE} >& /dev/null @@ -134,7 +142,7 @@ unload_modules() { /sbin/rmmod gameport >& /dev/null # Return success if the modules are unloaded - test -z "$(/sbin/lsmod | grep -E "^snd" | awk '{print $1}')" + [[ -z "$(/sbin/lsmod | grep -E "^snd" | awk '{print $1}')" ]] } terminate() { @@ -142,58 +150,71 @@ 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* \ + local 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 + local alsadevs="/proc/asound/dev/* /dev/sound/* /dev/snd/*" + fuser -k ${ossdevs} ${alsadevs} >& /dev/null # # remove all sequencer connections if any # - [ -f /proc/asound/seq/clients -a -x $aconnect ] && $aconnect --removeall + [[ -f /proc/asound/seq/clients && -x ${aconnect} ]] && ${aconnect} --removeall } restore_mixer() { - if [ ! -r $asoundcfg ]; then - ewarn "No mixer config in $asoundcfg, you have to unmute your card!" - elif [ -x $alsactl ]; then - CARDS="$(cat /proc/asound/cards | awk '/: / { print $1 }')" + if [[ ${RESTORE_ON_START} == "no" ]] ; then + return 0 + fi + + ebegin "Restoring Mixer Levels" + + local val=0 + + if [[ ! -r ${asoundcfg} ]] ; then + ewarn "No mixer config in ${asoundcfg}, you have to unmute your card!" + elif [[ -x ${alsactl} ]] ; then + local CARDS="$(cat /proc/asound/cards | awk '/: / { print $1 }')" + local CARDNUM for CARDNUM in ${CARDS} do - [ -e /dev/snd/controlC0 ] || sleep 2 - [ -e /dev/snd/controlC0 ] || sleep 2 - [ -e /dev/snd/controlC0 ] || sleep 2 - [ -e /dev/snd/controlC0 ] || sleep 2 - $alsactl -f $asoundcfg restore ${CARDNUM} + [[ -e /dev/snd/controlC0 ]] || sleep 2 + [[ -e /dev/snd/controlC0 ]] || sleep 2 + [[ -e /dev/snd/controlC0 ]] || sleep 2 + [[ -e /dev/snd/controlC0 ]] || sleep 2 + ${alsactl} -f ${asoundcfg} restore ${CARDNUM} + ((val=val+$?)) done else eerror -e "ERROR: Cannot find alsactl, did you forget to install media-sound/alsa-utils?" - return 1 + val=1 fi - return 0 + eend ${val} + return ${val} } save() { ebegin "Storing ALSA Mixer Levels" + + local val=0 - if [ -x $alsactl ]; then - $alsactl -f $asoundcfg store + if [[ -x ${alsactl} ]] ; then + ${alsactl} -f ${asoundcfg} store val=$? - eend $val - return $val else eerror -e "ERROR: Cannot find alsactl." - eend 1 - return 1 + val=1 fi + + eend ${val} + return ${val} } start() { - if [ -f /proc/modules ]; then + if [[ -f /proc/modules ]] ; then ebegin "Loading ALSA modules" - if load_modules; then + if load_modules ; then eend 0 else eend 1 @@ -201,18 +222,18 @@ start() { fi fi - ebegin "Restoring Mixer Levels" - restore_mixer - eend $? + if [[ ${RESTORE_ON_START} == "yes" ]]; then + restore_mixer + fi } stop() { - if [ ! -d /proc/asound ] ; then + if [[ ! -d /proc/asound ]] ; then eerror "ALSA is not loaded" return 0 fi - if [ "${SAVE_ON_STOP}" = "yes" ]; then + if [[ ${SAVE_ON_STOP} == "yes" ]]; then save fi @@ -220,7 +241,7 @@ stop() { terminate eend 0 - if [ -f /proc/modules ]; then + if [[ -f /proc/modules ]]; then ebegin "Unloading ALSA modules" if unload_modules; then eend 0 diff --git a/media-sound/alsa-utils/files/alsasound.confd b/media-sound/alsa-utils/files/alsasound.confd index 7be75537b602..6e82cdd32e95 100644 --- a/media-sound/alsa-utils/files/alsasound.confd +++ b/media-sound/alsa-utils/files/alsasound.confd @@ -1,3 +1,18 @@ +# ENABLE_OSS_EMUL: +# Do you want to enable in-kernel oss emulation? +# no - Do not load oss emul drivers +# yes - Load oss emul drivers if they're found + +ENABLE_OSS_EMUL="yes" + +# RESTORE_ON_START: +# Do you want to restore your mixer settings? If not, your cards will be +# muted. +# no - Do not restore state +# yes - Restore state + +RESTORE_ON_START="yes" + # SAVE_ON_STOP: # Do you want to save changes made to your mixer volumes when alsasound # stops? |