#!/bin/sh

/sbin/modprobe --ignore-install "$@" || exit $?

. /etc/sysconfig/sound

case "$1" in
    snd)
	/sbin/modprobe --quiet --use-blacklist snd-ioctl32
	test "$LOAD_OSS_EMUL_MODULES" = "yes" && \
	    /sbin/modprobe --quiet --use-blacklist snd-mixer-oss
	test "$LOAD_SEQUENCER" = "yes" && \
	    /sbin/modprobe --quiet --use-blacklist snd-seq
	;;
    snd-pcm|snd_pcm)
	test "$LOAD_OSS_EMUL_MODULES" = "yes" && \
	    /sbin/modprobe --quiet --use-blacklist snd-pcm-oss
	;;
    snd-seq|snd_seq)
	if [ -r /proc/asound/seq/drivers ]; then
	    OLDIFS="$IFS"
	    IFS=","
	    while read t x c; do
		/sbin/modprobe --quiet --use-blacklist $t
	    done < /proc/asound/seq/drivers
	    IFS="$OLDIFS"
	fi
	test "$LOAD_OSS_SEQ_MODULE" = "yes" && \
	    /sbin/modprobe --quiet --use-blacklist snd-seq-oss
	;;
esac

exit 0
