[Desktop] desktop 20080919 cd: +/-

Michael Shigorin =?iso-8859-1?q?mike_=CE=C1_osdn=2Eorg=2Eua?=
Вт Сен 23 14:13:34 MSD 2008


On Tue, Sep 23, 2008 at 10:58:56AM +0600, Andrey Rahmatullin wrote:
> > > Как ты этого всего добился?
> > > У меня стабильные M 00%
> > Поставил и попробовал...
> У меня на машине (via82xx) и в virtualbox (i8x0) что после
> установки, что на LiveCD нули.

Посмотри на свежие sound-scripts.git (shrek/mike)?

Если не влом -- проверь ещё fix_alsa_levels() из аттача,
достаточно ли (это sound-scripts-0.43).

-- 
 ---- WBR, Michael Shigorin <mike на altlinux.ru>
  ------ Linux.Kiev http://www.linux.kiev.ua/
----------- следующая часть -----------
#!/bin/sh
# $Id: sound,v 1.14 2003/10/08 15:03:12 ldv Exp $
#
# sound:   This shell script launch the sound on your system.
#
# chkconfig: 2345 30 70
# description: This shell script launch the sound on your system.
# halt: yes

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

PKLVL=
SOUND_ALSA=
WORKDIR=

ChangePrintk()
{
	[ -n "$PKLVL" ] || PKLVL=`sed 's/^\(.\).*/\1/' < /proc/sys/kernel/printk`
	sysctl -w kernel.printk=0
}
	
exit_handler()
{
	local rc=$?
	trap - EXIT
	[ -z "$PKLVL" ] || sysctl -w "kernel.printk=$PKLVL"
	[ -z "$WORKDIR" ] || rm -rf -- "$WORKDIR"
	exit $rc
}

trap exit_handler SIGHUP SIGPIPE SIGINT SIGQUIT SIGTERM EXIT

LOCKFILE=/var/lock/subsys/sound

AUMIX=
[ ! -x /usr/bin/aumix ] || AUMIX=/usr/bin/aumix
[ ! -x /bin/aumix-minimal ] || AUMIX=/bin/aumix-minimal
ALSACTL=
[ -x /usr/sbin/alsactl ] && ALSACTL=/usr/sbin/alsactl

# Remove duplicate lines from unsorted input
_uniq()
{
    egrep -v '(snd[-_]card|sound[-_]slot)[-_]' \
    | awk '{  if (data[$0]++ == 0)
                  print
           }'
}

LookupDevices()
{
	egrep -qs '(sparcaudio|sound)' /proc/devices
}

LoadModule()
{
	local phrase=$1 pattern=$2 m opt=
	[ -n "$3" ] && opt='-r'
	for m in `modprobe -c |egrep "^alias $pattern " |cut -d\  -f3 |_uniq`; do
		if [ -n "$m" ] && [ "$m" != off ]; then
			action "$phrase ($m):" modprobe "$opt" "$m"
			local rc=$?
			[ $rc -eq 0 ] || return $rc
		fi
	done
}

load_alsa()
# redo with LoadModule?
{
	modprobe -c |egrep '^alias [^ ]+ snd[-_]' |cut -d\  -f3 |_uniq |\
		while read line; do
			L=1
			action "Starting ALSA sound driver $line:" modprobe $line
		done
	if [ -d /proc/asound ]; then
 		RETVAL=0 start_mixer alsa
	fi
}

start_alsa()
{
	[ -d /proc/asound ] || load_alsa
	[ -d /proc/asound ] && touch "$LOCKFILE"
}

unload_alsa()
{
	RETVAL=0 stop_mixer alsa;
	/sbin/lsmod |grep "^snd" |
		while read line; do
			/sbin/rmmod `echo $line |cut -d\  -f 1`
		done
	/sbin/rmmod soundcore 2>/dev/null
}

fix_alsa_levels()
{
	WORKDIR="`mktemp -dt alsa-state.XXXXXX`"

	"$ALSACTL" -f "$WORKDIR/old-state" store

	# provide sane default audio levels even with alsa
	awk '
/}/ \
{
	have_range = 0
	have_switch = 0
	have_volume = 0
	print
	next
}

/name[[:space:]]+.*Playback Volume/ \
{
	have_volume = 1
	print
	next
}

/name[[:space:]]+.*Playback Switch/ \
{
	have_switch = 1
	print
	next
}

{
	if (match($0, /comment\.range[[:space:]]+'"'"'([[:digit:]]+)[[:space:]]*-[[:space:]]*([[:digit:]]+)'"'"'/, f)) {
		have_range = 1
		range_min = f[1]
		range_max = f[2]
		print
		next
	}
	if (match($0, /^(.*value.*[[:space:]]+)(0|false)([[:space:]]*)$/, f)) {
		if ((f[2] == "0") && have_volume && have_range) {
			new_value = int((range_max - range_min + 1)*2/3 + range_min)
			if (new_value <= range_min)
				new_value = range_min + 1
			if (new_value >= range_max)
				new_value = range_max
			print f[1] new_value f[3]
			next
		}
		if ((f[2] == "false") && have_switch) {
			print f[1] "true" f[3]
			next
		}
	}
	print
}
' < "$WORKDIR/old-state" > "$WORKDIR/new-state"

	action "Initializing ALSA mixer settings" "$ALSACTL" -f "$WORKDIR/new-state" restore
}

start_mixer()
{
	LookupDevices || return
	# ALSA
	if [ "$1" = "alsa" -a -n "$ALSACTL" ]; then
		if [ -r /etc/asound.state ]; then
			action "Loading ALSA mixer settings:" "$ALSACTL" restore
		else 
			fix_alsa_levels
			return 0
		fi
	elif [ -n "$AUMIX" ]; then
		if [ -s /etc/.aumixrc ]; then
			action "Loading OSS mixer settings:" "$AUMIX" -f /etc/.aumixrc -L
		else
			action "Initializing OSS mixer settings:" "$AUMIX" -v90 -w90 -c90
		fi
	fi
}

stop_mixer()
{
	LookupDevices || return
	if [ "$1" = "alsa" -a -n "$ALSACTL" ]; then
		action "Saving ALSA mixer settings:" "$ALSACTL" store
	elif [ -n "$AUMIX" ]; then
		action "Saving OSS mixer settings:" "$AUMIX" -f /etc/.aumixrc -S
	fi
}

start()
{
	ChangePrintk
	# if there is alsa driver configured load it and exit.
	# FIXME: we know it's wrong since there could be OSS too.
	# TODO: for now codepaths are extremely crappy :((
	start_alsa && exit
	RETVAL=0
	LoadModule "Loading sound module" 'sound[^ ]*' || RETVAL=1
	LoadModule "Loading midi module" midi
	start_mixer oss
	touch "$LOCKFILE"
}

stop()
{
	ChangePrintk
	if [ -d /proc/asound ]; then
		unload_alsa
		rm -f "$LOCKFILE"
		return
	fi
	if [ -d /proc/asound ]; then
		stop_mixer alsa
	else
		stop_mixer oss
	fi
	LoadModule "Unloading midi module" midi REMOVE
	LoadModule "Unloading sound module" 'sound[^ ]*' REMOVE
	rm -f "$LOCKFILE"
}

restart()
{
	stop
	start
}

case $1 in
	start)
		start
		;;
	stop|condstop)
		stop
		;;
	restart|reload)
		restart
		;;
	status)
		if lsmod |egrep -qs '^(sound|snd)'; then
			echo "Sound modules loaded"
		fi
		;;
	condrestart|condreload)
		;;
	*)
		msg_usage "${0##*/} {start|stop|restart|status}"
		exit 1
esac


Подробная информация о списке рассылки Desktop