Lars Heineken wrote:
>On Tue, 28 May 2002 20:43:48 +0300
>ismail donmez <[EMAIL PROTECTED]> wrote:
>
>I don't know how tricky it might be to get it running on your system, but maybe
>you'll find the clue there how to save your settings ?
>
>This my /etc/init.d/alsa -script:
>
>#!/bin/bash
>#
># /etc/init.d/alsa This shell script takes care of starting and stopping
># ALSA sound driver.
>#
># This script requires /usr/sbin/alsactl program from alsa-utils package.
>#
># Copyright (c) by Jaroslav Kysela <[EMAIL PROTECTED]>
>#
># Slightly modified for Debian GNU/Linux by Wichert Akkerman.
># Masato Taruishi.
>#
># Slightly modified for Linux-Mandrake by Chmouel Boudjnah
># <[EMAIL PROTECTED]>
>#
># This program is free software; you can redistribute it and/or modify
># it under the terms of the GNU General Public License as published by
># the Free Software Foundation; either version 2 of the License, or
># (at your option) any later version.
>#
># This program is distributed in the hope that it will be useful,
># but WITHOUT ANY WARRANTY; without even the implied warranty of
># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
># GNU General Public License for more details.
>#
># You should have received a copy of the GNU General Public License
># along with this program; if not, write to the Free Software
># Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>#
>#daemon
>#
># chkconfig: 2345 70 70
># description: This shell script launch the alsa sound system on your
># system.
>
>. /etc/init.d/functions
>
>PKLVL=$(cut -f1 /proc/sys/kernel/printk)
>sysctl -w kernel.printk=0
>
>alsactl=/usr/sbin/alsactl
>
>if [ ! -f /usr/share/alsa/alsa-utils ]; then
> exit 0
>fi
>
>if [ -e /etc/sysconfig/alsa ]; then
> . /etc/sysconfig/alsa
>fi
>
>. /usr/share/alsa/alsa-utils
>
>
>function start() {
>
> found_driver="false"
> echo -n "Starting ALSA version $alsa_version:"
>
> # First load the ALSA common driver and check whether devfs properly
> # can be available when the working kernel has devfs support.
> /sbin/modprobe snd
> if [ ! -e /dev/snd ]; then
> if [ -d /proc/asound/dev ]; then
> # you are using the kernel without devfs so simply create
> # symlink
> ln -s /proc/asound/dev /dev/snd
> else
> # you are using the kernel with devfs but disabling devfs.
> /sbin/modprobe -r snd
> exit 0
> fi
> fi
>
> awk '/^((alias)|(probe)) +(sound|snd)-(slot|card)-[0-9]/ {print $3}'
>/etc/modules.conf | ( \
> while read line; do
> [[ $line != snd-* ]] && continue
> found_driver="found"
> desc=`echo $line` # | cut -d- -f 3`
> if /sbin/modprobe $line ; then # >/dev/null 2>&1; then
> echo -n " $desc"
> found_driver="detect"
> else
> echo -n " ($desc)"
> fi
> done
> case $found_driver in
> detect)
> echo -n "."
> success;echo
> ;;
> false)
> if [ $alsa_version = "none" ]; then
> echo -n " no driver installed.";
> failure;echo
> exit 1
> else
> echo -n " no sound cards defined.";
> failure;echo
> exit 1
> fi
> ;;
> found)
> success;echo
> exit 1
> ;;
> esac
> ) || exit 0
> #
>
> # Enabling sound devices for alsactl.
> get_sound_devs
> enable_sound_devs
>
>
> # restore driver settings
> #
> if [ -x $alsactl ]; then
> echo -n "Doing alsactl to restore mixer settings..."
> $alsactl restore >/dev/null 2>&1 || true
> success;echo
> fi
>}
>
>
>function startoss() {
> [ "$startosslayer" = true ] &&
> for i in mixer pcm seq ; do /sbin/modprobe snd-${i}-oss >/dev/null 2>&1 ; done
>}
>
>function detect_stop() {
> #
> # remove all sound modules
> #
> clean=0
> modprobe -r snd-seq-oss
> modprobe -r snd-pcm-oss
> modprobe -r snd-mixer-oss
> /sbin/lsmod | grep -E "^snd" | ( while read line; do \
> /sbin/rmmod `echo $line | cut -d ' ' -f 1` >/dev/null 2>&1 || clean=1; \
> done
> # remove the 2.2 soundcore module (if possible)
> /sbin/rmmod soundcore >/dev/null 2>&1 || true
> if [ $clean = 1 ]; then
> exit 1
> fi
> )
> if [ $? = 1 ]; then
> return 1
> fi
>}
>
>function stop() {
> #
> # store driver settings
> #
> if [ -x $alsactl ]; then
> echo -n "Doing alsactl to store mixer settings..."
> $alsactl store >/dev/null 2>&1 || true
> sleep 1
> success;echo
> fi
>
> echo -n "Shutting down ALSA sound driver (version $alsa_version): "
>
> # Make sure that no devices are opened while
> # we are killing the procs that have devices open
> get_sound_devs
> get_sound_devs_proc
> disable_sound_devs
> #chmod 000 $sound_devs_proc As of drivers 0.5.8a these permissions can't be changed
>
> if [ "$ALSA_KILL_MODE" = "force" ]; then
> kill_procs_using_sound_devs
> else
> get_procs_using_sound_devs
> if [ -n "$procs_using_sound_devs" ]; then
> echo -n "no. (sound is being used by pid $procs_using_sound_devs)"
> chmod 660 $sound_devs_dev
> failure;echo
> exit 0
> fi
> fi
> #
> # remove all sound modules
> #
> detect_stop
> enable_sound_devs
> #chmod 600 $sound_devs_proc As of drivers 0.5.8a these permissions can't be changed
>
> if [ ! -f /dev/.devfsd ] && [ -L /dev/snd ]; then
> rm -f /dev/snd
> fi
>
>}
>
>function detect_start() {
> #
> # run only detect module
> #
> /sbin/modprobe snd-detect >/dev/null 2>&1 || true
>}
>
># Initialize some variables.
>get_alsa_version
>
># See how we were called.
>case "$1" in
> start)
> # Start driver.
> if [ ! -d /proc/asound ]; then
> if egrep -qs "^alias( |\t)+(snd|sound)-(card|slot)-[0-9]( |\t)+snd-"
>/etc/modules.conf;then
> start && startoss
> touch /var/lock/subsys/alsa
> fi
> else
> if [ -f /proc/asound/detect ]; then
> echo -n "Shutting down ALSA sound detect module (version $alsa_version): "
> detect_stop
> success;echo
> start && startoss
> touch /var/lock/subsys/alsa
> else
> echo "ALSA driver (version $alsa_version) is already running."
> fi
> fi
> ;;
> stop)
> # Stop daemons.
> if [ -d /proc/asound ]; then
> if [ -f /proc/asound/detect ]; then
> detect_stop
> rm -f /var/lock/subsys/alsa
> else
> if stop; then
> success;echo
> rm -f /var/lock/subsys/alsa
> else
> failure;echo
> rm -f /var/lock/subsys/alsa
> fi
> fi
> else
> echo "ALSA driver isn't running."
> fi
> ;;
> status)
> if egrep -q '(sparcaudio|sound)' /proc/devices;then
> echo "Sound loaded"
> fi
> ;;
> force-stop)
> ALSA_KILL_MODE="force" $0 stop
> ;;
> condrestart)
> if [ -f /var/lock/subsys/alsa ];then
> $0 stop && $0 $start
> fi
> ;;
> restart)
> $0 stop && $0 start
> ;;
> force-reload)
> ALSA_KILL_MODE="force" $0 restart
> ;;
> force-restart)
> ALSA_KILL_MODE="force" $0 stop
> $0 start
> ;;
> *)
> echo "Usage: /etc/init.d/alsa
>{start|stop|restart|force-reload|force-stop|force-restart}"
> exit 1
>esac
>
>sysctl -w kernel.printk=$PKLVL
>exit 0
>
>
>
>
>>I use slackware so i think i have to create it myself so what should be
>>the exact syntax ?
>>
>>
>>
>>
I ripped the alsactl part and added to my init script now it works fine.
Thnx a lot!
>
>
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
Alsa-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-user