[Pkg-alsa-devel] hardware mixing breakage
Thomas Hood
jdthood@aglu.demon.nl
Wed, 08 Sep 2004 08:33:47 +0200
--=-+pC9nyJBntLGfUc8lV1p
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Tue, 2004-09-07 at 23:21, Stefan Kombrink wrote:
> 1.)
> ("alsa stop" doesn't unload the modules / "alsa start" doesn't load
> the modules) Is it right that modprobe should take care of that?
Yes. Module loading is something that (normally) should be left up
to the module loader.
In the latest alsa packages, the initscript stop method only saves
the mixer levels.
If you want to remove snd-* modules then you can always use the
force-stop method.
I attach the latest alsa initscript from CVS so you can help us
test it. :)
I don't know how to solve your other problem. Maybe one of the
other guys has ideas.
--
Thomas
--=-+pC9nyJBntLGfUc8lV1p
Content-Disposition: attachment; filename=alsa-base.init
Content-Type: application/x-shellscript; name=alsa-base.init
Content-Transfer-Encoding: 7bit
#!/bin/sh
#
# ALSA initscript
#
set -e
PATH=/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin
if [ "$(id -u)" != "0" ] && [ "$1" != "--help" ] &&
[ "$1" != "help" ] && [ ! -z "$1" ]; then
echo "$0: To $1 ALSA, you must be root."
exit 1
fi
# Default settings
alsactl_store_on_shutdown="always autosave"
runlevels_save='[2-5]'
[ -f /etc/default/alsa ] && . /etc/default/alsa
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
}
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
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)"
}
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
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."
fi
stop || :
rmmod=""
case "$(modprobe --version 2>&1)" in
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 || :
done
if [ "$(lsmod | awk '/^snd/ {print $1}')" ] ; then
echo "failed."
return 1
else
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 ;;
*)
echo "Usage: /etc/init.d/alsa {start|stop|restart|reload|force-stop|force-reload}" >&2
exit 3
;;
esac
--=-+pC9nyJBntLGfUc8lV1p--