Luca wrote:
> Luca wrote:
>   
>> Hi!
>>
>> I'm having a problem with alsa and oss emulation, when I start kcontrol
>> to enter the sound system menu on the general tab the test sound works
>> but the test midi no, (error message in the console ALSA lib
>> seq_hw.c:457:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or
>> directory), the output in the console for these two test is this:
>> server status: running, autosuspend disabled
>> real-time status: real-time
>> server buffer time: 46.4399 ms
>> buffer size multiplier: 1
>> minimum stream buffer time: 46.4399 ms
>> auto suspend time: 0 s
>> audio method: alsa
>> sampling rate: 44100
>> channels: 2
>> sample size: 16 bits
>> duplex: full
>> device: default
>> fragments: 2
>> fragment size: 4096
>> server status: busy
>> real-time status: real-time
>> server buffer time: 46.4399 ms
>> buffer size multiplier: 1
>> minimum stream buffer time: 46.4399 ms
>> auto suspend time: 0 s
>> audio method: alsa
>> sampling rate: 44100
>> channels: 2
>> sample size: 16 bits
>> duplex: full
>> device: default
>> fragments: 2
>> fragment size: 4096
>>
>> I added a specific rule to 15-alsa.rules to load a SF2 file on startup
>> and added the entries for oss emulation in modprobe.conf.
>> KinfoCenter about the sound tells the following:
>> Installed drivers: Type 10:  ALSA emulation
>> Card config: Audigy 2 ZS [SB0350](rev.4, serial:0x20021102) at 0xd000,
>> irq 217
>> M Audio Audiophile 24/96 at 0xe800, irq 193
>> Audio devices: NOT ENABLED IN CONFIG
>> Synth devices: NOT ENABLED IN CONFIG
>> Midi devices: 0: Audigy MPU-401 (UART)
>> 1: M Audio Audiophile 24/96 MIDI
>> Timers: 31: system timer
>> Mixers: NOT ENABLED IN CONFIG
>> However in the kcontrol center in the hardware tab I selected ALSA as
>> sound, but in the midi section in gave no output for the midi device and
>> don't let me use the mapper midi.
>>
>> Attached are the specific files.
>>
>> Bye,
>> Luca
>>   
>> ------------------------------------------------------------------------
>>
>> blacklist emu10k1
>> blacklist eth1394
>>
>> alias char-major-116 snd
>>
>> options snd-emu10k1 index=0
>> options snd-ice1712 index=1
>> options snd-via82xx index=2
>>
>> # qnJ_.t3RdoeOdN+4:SB Audigy
>> alias snd-card-0 snd-emu10k1
>> # lgGW.oA8Yuvq001D:M-Audio Delta Audiophile
>> alias snd-card-1 snd-ice1712
>> # Ssy1.wXN6pYJ5d_9:VT8233/A/8235/8237 AC97 Audio Controller
>> alias snd-card-2 snd-via82xx
>>
>> alias char-major-14 soundcore
>> alias sound-slot-0 snd-emu10k1
>> alias sound-service-0-0 snd-mixer-oss
>> alias sound-service-0-1 snd-seq-oss
>> alias sound-service-0-3 snd-pcm-oss
>> alias sound-service-0-8 snd-seq-oss
>> alias sound-service-0-12 snd-pcm-oss
>>
>> alias eth0 ns83820
>>
>>   
>> ------------------------------------------------------------------------
>>
>> #!/bin/sh -e
>>
>> CARD=${DEVNAME##/dev/snd/hwC}
>> CARD=${CARD%%D0}
>>
>> case $PHYSDEVDRIVER in
>> EMU10K1_Audigy)
>>   echo -en "\xf0\x00\x20\x21\x61\x00\x00\x00\x7f\x00\xf7" > 
>> /dev/snd/midiC${CARD}D1
>>   /etc/alsa.d/load-soundfont $CARD CT4MGM.SF2
>>   ;;
>> sbawe)
>>   /etc/alsa.d/load-soundfont $CARD default.bnk default.sf2 default.sbk 
>> gu11-rom.sf2 GU11-ROM.SF2
>>   ;;
>> esac
>>
>> exit 0
>>   
>> ------------------------------------------------------------------------
>>
>> #!/bin/sh -e
>>
>> CARD=$1
>> shift
>>
>> test -x /usr/bin/asfxload || exit 0
>>
>> . /etc/sysconfig/sound
>>
>> load_sf () {
>>   for d in /usr/share/sounds/sf2 \
>>            /usr/share/sfbank \
>>            /usr/local/lib/sfbank \
>>            /usr/share/sfbank/creative \
>>            /usr/local/lib/sfbank/creative \
>>            ; do
>>     if [ -r $d/$1 ]; then
>>       /usr/bin/asfxload -Dhw:${CARD},2 $d/$1
>>       return 0
>>     fi
>>   done
>>   return 1
>> }
>>
>> case $SOUNDFONT_FILES in
>> /*)
>>   if [ -r "$SOUNDFONT_FILES" ]; then
>>       /usr/bin/asfxload -Dhw:${CARD},2 $SOUNDFONT_FILES
>>       exit 0
>>   fi
>>   ;;
>> esac
>>
>> for file in $SOUNDFONT_FILES $* ; do
>>   if load_sf $file ; then
>>      break
>>   fi
>> done
>> exit 0
>>   
>>     
> Oops in the previous mail I forgot to attach the alsa.rules, here attached.
>   
> ------------------------------------------------------------------------
>
> # Give the audio group ownership of sound devices
> SUBSYSTEM=="sound",       GROUP="audio"
> SUBSYSTEM=="snd",         GROUP="audio"
>
> # ALSA Devices
> # When a sound device is detected, restore the volume settings
> KERNEL=="controlC[0-9]*", ACTION=="add", RUN+="/usr/sbin/alsactl restore %n"
> KERNEL=="controlC[0-9]*",  NAME="snd/%k"
> KERNEL=="hw[CD0-9]*",      NAME="snd/%k"
> KERNEL=="pcm[CD0-9cp]*",   NAME="snd/%k"
> KERNEL=="midi[CD0-9]*",    NAME="snd/%k"
> KERNEL=="timer",           NAME="snd/%k"
> KERNEL=="seq",             NAME="snd/%k"
> KERNEL=="hwC0D0", DRIVERS=="EMU10K1_Audigy", RUN+="/etc/alsa.d/udev-soundfont"
>   
I've managed for the missing devices however I have no sound except from
the kttsd, and audio cds. Now from the kcontrolcenter audio system the
test sound works, the test midi outputs no sound, in the hardware tab I
choose as device audio ALSA, I enabled full duplex, frequency 44100 Hz,
high quality and form the midi devices I choose Emu10k1 WaveTable
Emu10k1 Port 0 - ALSA device.
I made some changes to the scripts.

I attach all the relevant scripts.

Luca
# Give the audio group ownership of sound devices
SUBSYSTEM=="sound",       GROUP="audio"
SUBSYSTEM=="snd",         GROUP="audio"

# ALSA Devices
# When a sound device is detected, restore the volume settings
KERNEL=="controlC[0-9]*", ACTION=="add", RUN+="/usr/sbin/alsactl restore %n"
KERNEL=="controlC[0-9]*",  NAME="snd/%k"
KERNEL=="hw[CD0-9]*",      NAME="snd/%k"
KERNEL=="pcm[CD0-9cp]*",   NAME="snd/%k"
KERNEL=="midi[CD0-9]*",    NAME="snd/%k"
KERNEL=="timer",           NAME="snd/%k"
KERNEL=="seq",             NAME="snd/%k"
KERNEL=="hwC?D2", DRIVER=="EMU10K1_Audigy", RUN+="/etc/alsa.d/udev-soundfont"
blacklist emu10k1
blacklist eth1394

alias char-major-116 snd

options snd-emu10k1 index=0
options snd-ice1712 index=1
options snd-via82xx index=2

# qnJ_.t3RdoeOdN+4:SB Audigy
alias snd-card-0 snd-emu10k1
# lgGW.oA8Yuvq001D:M-Audio Delta Audiophile
alias snd-card-1 snd-ice1712
# Ssy1.wXN6pYJ5d_9:VT8233/A/8235/8237 AC97 Audio Controller
alias snd-card-2 snd-via82xx

alias char-major-14 soundcore
alias sound-slot-0 snd-emu10k1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

alias eth0 ns83820

options snd-emu10k1 enable=1 index=0
options snd-ice1712 enable=1 index=1
options snd-via82xx enable=1 index=2

# qnJ_.t3RdoeOdN+4:SB Audigy
alias snd-card-0 snd-emu10k1
# lgGW.oA8Yuvq001D:M-Audio Delta Audiophile
alias snd-card-1 snd-ice1712
# Ssy1.wXN6pYJ5d_9:VT8233/A/8235/8237 AC97 Audio Controller
alias snd-card-2 snd-via82xx

alias sound-slot-0 snd-emu10k1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
#!/bin/sh -e

CARD=$1
shift

test -x /usr/bin/asfxload || exit 0

. /etc/sysconfig/sound

load_sf () {
  for d in /usr/share/sounds/sf2 \
           /usr/share/sfbank \
           /usr/local/lib/sfbank \
           /usr/share/sfbank/creative \
           /usr/local/lib/sfbank/creative \
           ; do
    if [ -r $d/$1 ]; then
      /usr/bin/asfxload -Dhw:${CARD},2 $d/$1
      return 0
    fi
  done
  return 1
}

case $SOUNDFONT_FILES in
/*)
  if [ -r "$SOUNDFONT_FILES" ]; then
      /usr/bin/asfxload -Dhw:${CARD},2 $SOUNDFONT_FILES
      exit 0
  fi
  ;;
esac

for file in $SOUNDFONT_FILES $* ; do
  if load_sf $file ; then
     break
  fi
done
exit 0
#!/bin/sh -e

CARD=${DEVNAME##/dev/snd/hwC}
CARD=${CARD%%D2}

case $PHYSDEVDRIVER in
EMU10K1_Audigy)
  echo -en "\xf0\x00\x20\x21\x61\x00\x00\x00\x7f\x00\xf7" > 
/dev/snd/midiC${CARD}D1
  /etc/alsa.d/load-soundfont $CARD CT4MGM.SF2
  ;;
sbawe)
  /etc/alsa.d/load-soundfont $CARD default.bnk default.sf2 default.sbk 
gu11-rom.sf2 GU11-ROM.SF2
  ;;
esac

exit 0
# /etc/rc.status
# Definition of boot script return messages
#
#   The bootscripts should use the variables rc_done and rc_failed to
#   report whether they failed or succeeded.  See /etc/init.d/skeleton for
#   an example how the shell functions rc_status and rc_reset are used.
#
#   These functions make use of the variables rc_done and rc_failed;
#   rc_done_up and rc_failed_up are the same as rc_done and rc_failed
#   but contain a terminal code to move up one line before the output
#   of the actual string. (This is particularly useful when the script
#    starts a daemon which produces user output with a newline character)
#
#   The variable rc_reset is used by the master resource control script
#   /etc/init.d/rc to turn off all attributes and switch to the standard
#   character set.
#
#    \033          ascii ESCape
#    \033[<NUM>G   move to column <NUM> (linux console, xterm, not vt100)
#    \033[<NUM>C   move <NUM> columns forward but only upto last column
#    \033[<NUM>D   move <NUM> columns backward but only upto first column
#    \033[<NUM>A   move <NUM> rows up
#    \033[<NUM>B   move <NUM> rows down
#    \033[1m       switch on bold
#    \033[31m      switch on red
#    \033[32m      switch on green
#    \033[33m      switch on yellow
#    \033[m        switch off color/bold
#    \017          exit alternate mode (xterm, vt100, linux console)
#    \033[10m      exit alternate mode (linux console)
#    \015          carriage return (without newline)
#

# Do _not_ be fooled by non POSIX locale
LC_ALL=POSIX
export LC_ALL

# Seek for terminal size and, if needed, set default size
if test -z "$LINES" -o -z "$COLUMNS" ; then
    eval `exec 3<&1; stty size <&3 2>/dev/null | (read L C; \
          echo LINES=${L:-24} COLUMNS=${C:-80})`
fi
test $LINES   -eq 0 && LINES=24
test $COLUMNS -eq 0 && COLUMNS=80
export LINES COLUMNS

# Make sure we have /sbin and /usr/sbin in PATH
case ":$PATH:" in 
    *:/sbin:*)
        ;;
    *)
        PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
        export PATH
        ;;
esac

if test -t 1 -a "$TERM" != "raw" -a "$TERM" != "dumb" && stty size <&1 > 
/dev/null 2>&1 ; then
         esc=`echo -en "\033"`
        extd="${esc}[1m"
        warn="${esc}[1;31m"
        done="${esc}[1;32m"
        attn="${esc}[1;33m"
        norm=`echo -en "${esc}[m\017"`
        stat=`echo -en "\015${esc}[${COLUMNS}C${esc}[10D"`

     rc_done="${stat}${done}done${norm}"
  rc_running="${stat}${done}running${norm}"
   rc_failed="${stat}${warn}failed${norm}"
   rc_missed="${stat}${warn}missing${norm}"
  rc_skipped="${stat}${attn}skipped${norm}"
     rc_dead="${stat}${warn}dead${norm}"
   rc_unused="${stat}${extd}unused${norm}"
  rc_unknown="${stat}${attn}unknown${norm}"
  rc_done_up="${esc}[1A${rc_done}"
rc_failed_up="${esc}[1A${rc_failed}"
    rc_reset="${norm}${esc}[?25h"
     rc_save="${esc}7${esc}[?25l"
  rc_restore="${esc}8${esc}[?25h"
    function rc_cuu () { test $1 -eq 0 && return; echo -en "\033[${1}A"; }
    function rc_cud () { test $1 -eq 0 && return; echo -en "\033[${1}B"; }
    function rc_timer_on () {
        # Draw seconds of running timout to column.
        # Two arguments: timeout in seconds and offset
        local n=$1
        local c=$2
        (trap "exit 0" TERM
         while test $((n--)) -gt 0; do
            sleep 1;
            if test $n -gt 9 ; then
                echo -en "\015${esc}[${c}C(${n}s) "
            else
                echo -en "\015${esc}[${c}C( ${n}s) "
            fi
        done) & _rc_timer_pid=$!
    }
    function rc_timer_off () {
        if test -n "$_rc_timer_pid" ; then
            kill -TERM $_rc_timer_pid > /dev/null 2>&1
        fi
        unset _rc_timer_pid
    }
else
         esc=""
        extd=""
        warn=""
        done=""
        attn=""
        norm=""
        stat=""

     rc_done="..done"
  rc_running="..running"
   rc_failed="..failed"
   rc_missed="..missing"
  rc_skipped="..skipped"
     rc_dead="..dead"
   rc_unused="..unused"
  rc_unknown="..unknown"
  rc_done_up="${rc_done}"
rc_failed_up="${rc_failed}"
    rc_reset=""
     rc_save=""
  rc_restore=""
    function rc_cuu () { return; }
    function rc_cud () { return; }
    function rc_timer_on  () { return; }
    function rc_timer_off () { return; }
fi

_rc_service=${0##*/[SK][0-9][0-9]}
_rc_status=0
_rc_status_all=0
_rc_todo=$1
function rc_check ()
{
    _rc_status_ret=$?
    test $_rc_status_ret -eq 0 || _rc_status=$_rc_status_ret
    test $_rc_status     -eq 0 || _rc_status_all=$_rc_status
    return $_rc_check_ret
}
function rc_reset ()
{
    _rc_status=0
    _rc_status_all=0
    rc_check
    return 0
}

if   test "$_rc_todo" = "status" ; then
function rc_status ()
{
    rc_check
    _rc_status_ret=$_rc_status
    local i
    for i ; do
        case "$i" in
        -v|-v[1-9]|-v[1-9][0-9])
            local vrt=""
            local out=1
            local opt="en"

            test -n "${i#-v}" && vrt="$vrt${esc}[${i#-v}A" || opt="e"
            case "$_rc_status" in
            0)  vrt="$vrt$rc_running";          ;; # service running
            1)  vrt="$vrt$rc_dead"   ; out=2    ;; # service dead (but has pid 
file)
            2)  vrt="$vrt$rc_dead"   ; out=2    ;; # service dead (but has lock 
file)
            3)  vrt="$vrt$rc_unused" ;          ;; # service not running
            4)  vrt="$vrt$rc_unknown";          ;; # status is unknown
            esac
            echo -$opt "$rc_save$vrt$rc_restore" 1>&$out

            # reset _rc_status to 0 after verbose case
            _rc_status=0 ;;
        -r) rc_reset ;;
        -s) echo -e "$rc_skipped" ; rc_failed 3 ;;
        -u) echo -e "$rc_unused"  ; rc_failed 3 ;;
        *)  echo "rc_status: Usage: [-v[<num>] [-r]|-s|-u]" 1>&2 ; return 0 ;;
        esac
    done
    return $_rc_status_ret
}
elif test -n "$_rc_todo" ; then
function rc_status ()
{
    rc_check
    test "$_rc_status" -gt 7 && rc_failed 1
    _rc_status_ret=$_rc_status
    case "$_rc_todo" in
    stop)
        # program is not running which
        # is success if we stop service
        test "$_rc_status" -eq 7 && rc_failed 0 ;;
    esac
    local i
    for i ; do
        case "$i" in
        -v|-v[1-9]|-v[1-9][0-9])
            local vrt=""
            local out=1
            local opt="en"

            test -n "${i#-v}" && vrt="$vrt${esc}[${i#-v}A" || opt="e"
            case "$_rc_status" in
            0)  vrt="$vrt$rc_done"   ;          ;; # success
            1)  vrt="$vrt$rc_failed" ; out=2    ;; # generic or unspecified 
error
            2)  vrt="$vrt$rc_failed" ; out=2    ;; # invalid or excess args
            3)  vrt="$vrt$rc_missed" ; out=2    ;; # unimplemented feature
            4)  vrt="$vrt$rc_failed" ; out=2    ;; # insufficient privilege
            5)  vrt="$vrt$rc_skipped"; out=2    ;; # program is not installed
            6)  vrt="$vrt$rc_unused" ; out=2    ;; # program is not configured
            7)  vrt="$vrt$rc_failed" ; out=2    ;; # program is not running
            *)  vrt="$vrt$rc_failed" ; out=2    ;; # unknown (maybe used in 
future)
            esac
            echo -$opt "$rc_save$vrt$rc_restore" 1>&$out

            # reset _rc_status to 0 after verbose case
            _rc_status=0 ;;
        -r) rc_reset ;;
        -s) echo -e "$rc_skipped" 1>&2 ; rc_failed 5 ;;
        -u) echo -e "$rc_unused"  1>&2 ; rc_failed 6 ;;
        *)  echo "rc_status: Usage: [-v[<num>] [-r]|-s|-u]" 1>&2 ; return 0 ;;
        esac
    done
    return $_rc_status_ret
}
else
function rc_status ()
{
    rc_check
    _rc_status_ret=$_rc_status
    local i
    for i ; do
        case "$i" in
        -v|-v[1-9]|-v[1-9][0-9])
            local vrt=""
            local out=1
            local opt="en"

            test -n "${i#-v}" && vrt="$vrt${esc}[${i#-v}A" || opt="e"
            case "$_rc_status" in
            0)  vrt="$vrt$rc_done"  ;           ;; # success
            *)  vrt="$vrt$rc_failed"; out=2     ;; # failed
            esac
            echo -$opt "$rc_save$vrt$rc_restore" 1>&$out

            # reset _rc_status to 0 after verbose case
            _rc_status=0 ;;
        -r) rc_reset ;;
        -s) echo -e "$rc_skipped"  ; return 0 ;;
        -u) echo -e "$rc_unused"   ; return 0 ;;
        *)  echo "rc_status: Usage: [-v[<num>] [-r]|-s|-u]" 1>&2 ; return 0 ;;
        esac
    done
    return $_rc_status_ret
}
fi

function rc_failed ()
{
    rc_reset
    case "$1" in
    [0-7]) _rc_status=$1 ;;
    "")    _rc_status=1
    esac
    rc_check
    return $_rc_status
}

function rc_exit ()
{
    exit $_rc_status_all
}

function rc_confirm()
{
    local timeout="30"
    local answer=""
    local ret=0

    case "$1" in
    -t) timeout=$2; shift 2 ;;
    esac
    local message="$@, (Y)es/(N)o/(C)ontinue? [y] "
    : ${REDIRECT:=/dev/tty}

    while true ; do
        read -t ${timeout} -n 1 -p "${message}" answer < $REDIRECT > $REDIRECT 
2>&1
        case "$answer" in
        [yY]|"") ret=0; break ;;
        [nN])    ret=1; break ;;
        [cC])    ret=2; break ;;
        *)       echo; continue
        esac
    done
    echo
    return $ret
}

function rc_active ()
{
    local x
    for x in /etc/rc.d/init.d/*.d/S[0-9][0-9]${1} ; do
        test -e $x || break
        return 0
    done
    return 1
}

function rc_splash()
{
    return 0
}

## Path:        Hardware/Soundcard
## Description: Additional options for the sound system.
## Type:        yesno
## Default:     yes
## ServiceReload: alsasound
#
# Load ALSA sequencer modules at boot-up? (yes/no)
# Sequencer modules are necessary only for handling MIDI devices.
# If you don't need MIDI, leave here no.
#
LOAD_SEQUENCER="yes"

## Type:        string
## Default:     ""
#
# The file name of SoundFont file to be loaded at boot
# If you need to load a specific SoundFont file for SB AWE32, SB Live!
# and Audigy series, set the file name (or path) of the file here.
#
SOUNDFONT_FILES="/usr/share/sounds/sf2/CT4MGM.SF2"

## Type:        yesno
## Default:     yes
#
# Load OSS-emulation modules at boot-up? (yes/no)
# OSS-emulation modules are needed If you use OSS applications
# with ALSA drivers.  This option specifies whether these modules are
# loaded at boot-time by alsasound init script.
# Safe to leave yes here.
#
LOAD_OSS_EMUL_MODULES="yes"

## Type:        yesno
## Default:     no
#
# Load OSS-sequencer emulation module at boot-up? (yes/no)
# OSS-sequencer emulation module is needed If you use old /dev/sequencer
# or /dev/music.  The default is "no" since there are little
# applications using these interfaces.
#
LOAD_OSS_SEQ_MODULE="yes"
#!/bin/sh

. /etc/sysconfig/rc.status
. /etc/sysconfig/sound

rc_reset

alsactl=/usr/sbin/alsactl
asoundcfg=/etc/asound.state
aconnect=/usr/bin/aconnect
lsmod=/bin/lsmod

#
# insert sequencer modules
#
load_sequencer() {
  test "$LOAD_SEQUENCER" = "yes" && modprobe -q snd-seq
  if [ x"$LOAD_SEQUENCER" = xyes -a -r /proc/asound/seq/drivers ]; then
    OLDIFS="$IFS"
    IFS=","
    while read t x c; do
      /sbin/modprobe $t
    done < /proc/asound/seq/drivers
    IFS="$OLDIFS"
  fi
}

get_drivers() {
  if [ -f /etc/modprobe.d/sound ]; then
    cat /etc/modprobe.d/sound
  else
    /sbin/modprobe -c
  fi | \
    grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | sort | \
    while read a b card; do
        echo $card
    done
}

#
# insert all sound modules
#
load_modules() {
  module_loaded=0
  c=""
  drivers=`get_drivers`
  for i in $drivers; do
    if [ $i != off ]; then
      if [ x$c = x ]; then
        echo -n ": "
        c=1
      fi
      echo -n " ${i##snd-}"
      /sbin/modprobe $i && module_loaded=1
    fi
  done
  rc_status -v -r
  test $module_loaded -eq 0 && return 1
  return 0
}

#
# rest of start action
#
start_rest() {
  load_sequencer
  if [ x"$LOAD_OSS_EMUL_MODULES" = xyes ]; then
    /sbin/modprobe snd-pcm-oss
    test x"$LOAD_OSS_SEQ_MODULE" = xyes && /sbin/modprobe snd-seq-oss
  fi
}

# manual load and force to store the status
start_all() {
    echo -n "Starting sound driver"
    load_modules && start_rest
    # hack - in case the mixer isn't restored
    (sleep 1; $alsactl -F -f $asoundcfg restore >/dev/null 2>&1)
    rc_status
}

terminate() {
  #
  # Kill processes holding open sound devices
  #
  fuser -k /dev/admmidi* /dev/adsp* /dev/amidi* /dev/audio* /dev/dmfm* \
     /dev/dmmidi* /dev/dsp* /dev/dspW* /dev/midi* /dev/mixer* /dev/music \
     /dev/patmgr* /dev/sequencer* /dev/sndstat >/dev/null 2>&1
  if [ -d /dev/snd ]; then
    fuser -k /dev/snd/* >/dev/null 2>&1
  fi
  #
  # remove all sequencer connections if any
  #
  if [ -f /proc/asound/seq/clients -a -x $aconnect ]; then
    $aconnect --removeall
  fi
}

# mute master to avoid clicks at unload/shutdown
unmute_system() {
  /usr/bin/amixer set Master mute >/dev/null 2>&1
}

#
# remove all sound modules
#
unload_modules() {
  unmute_system
  $lsmod | grep -E "^snd" | grep -Ev "(snd-page-alloc|snd_page_alloc)" | while 
read m s; do
     /sbin/rmmod $m
  done
}

unload_all() {
    echo -n "Shutting down sound driver"
    terminate
    unload_modules
    rc_status -v
}

stop_all() {
    if [ -d /proc/asound ]; then
        $alsactl -f $asoundcfg store
        unload_all
    fi
}

# See how we were called.
case "$1" in
  start)
        if [ "$PREVLEVEL" = "N" ]; then
            test -d /proc/asound && start_rest
        else
            start_all
        fi
        ;;
  stop)
        if [ "$RUNLEVEL" = "6" ]; then
            if [ -d /proc/asound ]; then
                $alsactl -f $asoundcfg store
                unmute_system
            fi
        else
            stop_all
        fi
        ;;
  unload)
        test -d /proc/asound && unload_all
        ;;
  reload|restart)
        stop_all
        start_all
        ;;
  status)
        if [ -d /proc/asound ]; then
          echo -n "ALSA sound driver loaded."
          rc_status -v
        else
          echo -n "ALSA sound driver not loaded."
          rc_status -u
        fi
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|reload|unload|status}"
        exit 1
esac

rc_exit

-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to