Author: lslezak
Date: Tue Apr 24 16:19:16 2012
New Revision: 68019
URL: http://svn.opensuse.org/viewcvs/yast?rev=68019&view=rev
Log:
- reimplemented driver reloading ("rcalsasound reload" does not
work with systemd) (bnc#751689)
Added:
trunk/sound/sound/src/alsadrivers (with props)
trunk/sound/sound/src/joystickdrivers (with props)
Modified:
trunk/sound/package/yast2-sound.changes
trunk/sound/sound/src/Joystick.ycp
trunk/sound/sound/src/Makefile.am
trunk/sound/sound/src/routines.ycp
trunk/sound/sound/src/sound_write.ycp
trunk/sound/sound/src/volume_routines.ycp
trunk/sound/yast2-sound.spec.in
Modified: trunk/sound/package/yast2-sound.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/package/yast2-sound.changes?rev=68019&r1=68018&r2=68019&view=diff
==============================================================================
--- trunk/sound/package/yast2-sound.changes (original)
+++ trunk/sound/package/yast2-sound.changes Tue Apr 24 16:19:16 2012
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Tue Apr 24 14:16:09 UTC 2012 - lslezak@suse.cz
+
+- reimplemented driver reloading ("rcalsasound reload" does not
+ work with systemd) (bnc#751689)
+
+-------------------------------------------------------------------
Thu Mar 29 16:04:11 CEST 2012 - jsuchome@suse.cz
- merge proofread texts
Modified: trunk/sound/sound/src/Joystick.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/Joystick.ycp?rev=68019&r1=68018&r2=68019&view=diff
==============================================================================
--- trunk/sound/sound/src/Joystick.ycp (original)
+++ trunk/sound/sound/src/Joystick.ycp Tue Apr 24 16:19:16 2012
@@ -14,6 +14,9 @@
import "Mode";
import "Service";
+ import "Directory";
+
+ const string joy_cmd = Directory::bindir + "/joystickdrivers";
/**
* joystick config datastructure (list of maps)
@@ -282,7 +285,9 @@
* Stop joystick service
*/
global define boolean Stop() ``{
- return Service::Stop("joystick");
+ string cmd = joy_cmd + " unload";
+ y2milestone("Executing: %1", cmd);
+ return SCR::Execute(.target.bash, cmd) == 0;
}
/**
@@ -298,7 +303,11 @@
global define boolean StartAndEnable() ``{
if (start == "enable")
- Service::Start("joystick");
+ {
+ string cmd = joy_cmd + " load";
+ y2milestone("Executing: %1", cmd);
+ SCR::Execute(.target.bash, cmd);
+ }
Service::Adjust("joystick", start);
return true;
Modified: trunk/sound/sound/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/Makefile.am?rev=68019&r1=68018&r2=68019&view=diff
==============================================================================
--- trunk/sound/sound/src/Makefile.am (original)
+++ trunk/sound/sound/src/Makefile.am Tue Apr 24 16:19:16 2012
@@ -38,7 +38,7 @@
PulseAudio.ycp \
Joystick.ycp
-ybin_SCRIPTS = copyfonts
+ybin_SCRIPTS = copyfonts alsadrivers joystickdrivers
YCPCFLAGS = -I.
Added: trunk/sound/sound/src/alsadrivers
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/alsadrivers?rev=68019&view=auto
==============================================================================
--- trunk/sound/sound/src/alsadrivers (added)
+++ trunk/sound/sound/src/alsadrivers Tue Apr 24 16:19:16 2012
@@ -0,0 +1,188 @@
+#!/bin/sh
+#
+# This script is based on the original /etc/init.d/alsasound
+# and /usr/bin/setup-pulseaudio script.
+#
+# It was modified to a standalone script which works with systemd.
+#
+# From /etc/init.d/alsasound file:
+#
+# Copyright (c) by Jaroslav Kysela
+#
+# 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.
+#
+# Modified to visually fit into SuSE 6.0+ by Philipp Thomas
+# further improvements by Bernd Kaindl, Olaf Hering and Takashi Iwai.
+#
+#
+# Transformed to a standalone script by Ladislav Slezak, 2012
+#
+
+alsactl=/usr/sbin/alsactl
+asoundcfg=/var/lib/alsa/asound.state
+aconnect=/usr/bin/aconnect
+
+. /etc/sysconfig/sound
+
+#
+# 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
+ echo "Loading module $t"
+ /sbin/modprobe $t
+ done < /proc/asound/seq/drivers
+ IFS="$OLDIFS"
+ fi
+}
+
+get_drivers() {
+ /sbin/modprobe -c | \
+ grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | sort -u | \
+ while read a b card; do
+ echo $card
+ done
+}
+
+#
+# insert all sound modules
+#
+load_modules() {
+ module_loaded=0
+ drivers=`get_drivers`
+ for i in $drivers; do
+ if [ $i != off ]; then
+ echo "Loading module $i"
+ /sbin/modprobe $i && module_loaded=1
+ fi
+ done
+
+ 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 "Starting sound driver..."
+ load_modules && start_rest
+}
+
+do_kill() {
+ fuser $* /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 $* /dev/snd/* >/dev/null 2>&1
+ fi
+}
+
+terminate() {
+ #
+ # Kill processes holding open sound devices
+ #
+ do_kill -TERM -k
+ sleep 1
+ do_kill -k
+
+ #
+ # 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
+mute_system() {
+ /usr/bin/amixer set Master mute >/dev/null 2>&1
+}
+
+#
+# remove all sound modules
+#
+unload_modules() {
+ mute_system
+ mod=$(grep -m1 -E '^(snd[^ ]*|ac97_bus) [0-9]+ 0' /proc/modules)
+ while [ -n "$mod" ]; do
+ mod=${mod%% *}
+ echo "Removing module $mod"
+ /sbin/modprobe -r $mod
+ mod=$(grep -m1 -E '^(snd[^ ]*|ac97_bus) [0-9]+ 0' /proc/modules)
+ done
+}
+
+unload_all() {
+ echo "Shutting down sound driver..."
+
+ pa_disabled="no"
+ if grep -q "^[ \t]*autospawn[ \t]*=[ \t]*yes" /etc/pulse/client.conf; then
+ echo "Temporarily disabling PulseAudio autospawn"
+ sed -i -e "s|^[ \t]*autospawn.*|autospawn = no|g" /etc/pulse/client.conf
+ pa_disabled="yes"
+ fi
+
+ terminate
+ unload_modules
+
+ if [ $pa_disabled == "yes" ]; then
+ echo "Reenabling PulseAudio autospawn"
+ sed -i -e "s|^[ \t]*autospawn.*|autospawn = yes|g" /etc/pulse/client.conf
+ fi
+}
+
+stop_all() {
+ if [ -d /proc/asound ]; then
+ $alsactl -g -f $asoundcfg store
+ unload_all
+ echo
+ fi
+}
+
+# See how we were called.
+case "$1" in
+ load)
+ start_all
+ ;;
+ unload)
+ test -d /proc/asound && unload_all
+ ;;
+ reload)
+ stop_all
+ start_all
+ ;;
+ *)
+ echo "Usage: $0 {load|unload|reload}"
+ echo
+ echo "This script loads/unloads ALSA kernel drivers configured in modprobe"
+ echo "configuration (usually stored in /etc/modprobe.d/50-sound.conf file)."
+ exit 1
+ ;;
+esac
+
Added: trunk/sound/sound/src/joystickdrivers
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/joystickdrivers?rev=68019&view=auto
==============================================================================
--- trunk/sound/sound/src/joystickdrivers (added)
+++ trunk/sound/sound/src/joystickdrivers Tue Apr 24 16:19:16 2012
@@ -0,0 +1,87 @@
+#! /bin/bash
+#
+# This script is based on the original /etc/init.d/joystick initscript/
+#
+# It was modified to a standalone script which works with systemd.
+#
+# From /etc/init.d/joystick file:
+# Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany.
+#
+# Author: Takashi Iwai , 2001
+#
+# Transformed to a standalone script by Ladislav Slezak, 2012
+#
+
+. /etc/sysconfig/joystick
+
+alsactl=/usr/sbin/alsactl
+if [ -x /sbin/lsmod ]; then
+ lsmod=/sbin/lsmod
+else
+ lsmod=/bin/lsmod
+fi
+
+# load joystick drivers
+function load () {
+ # first load joydev module
+ if [ -z "${JOYSTICK_MODULE_0}${JOYSTICK_MODULE_1}${JOYSTICK_MODULE_2}${JOYSTICK_MODULE_3}" ]; then
+ echo "No joystick configured"
+ return
+ fi
+
+ /sbin/modprobe joydev
+ for js in 0 1 2 3; do
+ # load gameport module
+ eval jsmod=\$GAMEPORT_MODULE_$js
+ if [ -n "$jsmod" -a "$jsmod" != off ]; then
+ echo "Loading gameport module $jsmod"
+ /sbin/modprobe $jsmod >/dev/null 2>&1
+ fi
+ # load joystick moulde
+ eval jsdev=\$JOYSTICK_MODULE_$js
+ eval jsdev_opts=\$JOYSTICK_MODULE_OPTION_$js
+ if [ -n "$jsdev" -a "$jsdev" != off ]; then
+ echo "Loading joystick module $jsdev"
+ /sbin/modprobe $jsdev $jsdev_opts >/dev/null 2>&1
+ fi
+ done
+}
+
+function unload () {
+ for js in 0 1 2 3; do
+ # remove gameport module
+ eval jsmod=\$GAMEPORT_MODULE_$js
+ if [ -n "$jsmod" -a "$jsmod" != off ]; then
+ echo "Removing gameport module $jsmod"
+ /sbin/modprobe -r $jsmod
+ fi
+ # remove joystick moulde
+ eval jsdev=\$JOYSTICK_MODULE_$js
+ if [ -n "$jsdev" -a "$jsdev" != off ]; then
+ echo "Removing joystick module $jsdev"
+ /sbin/modprobe -r $jsdev
+ fi
+ done
+}
+
+# See how we were called.
+case "$1" in
+ load)
+ echo "Loading joystick drivers..."
+ load
+ ;;
+ unload)
+ # Stop daemons.
+ echo "Removing joystick drivers..."
+ unload
+ ;;
+ reload)
+ unload
+ load
+ ;;
+ *)
+ echo "Usage: $0 {load|unload|reload}"
+ exit 1
+ ;;
+esac
+
Modified: trunk/sound/sound/src/routines.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/routines.ycp?rev=68019&r1=68018&r2=68019&view=diff
==============================================================================
--- trunk/sound/sound/src/routines.ycp (original)
+++ trunk/sound/sound/src/routines.ycp Tue Apr 24 16:19:16 2012
@@ -947,8 +947,9 @@
y2milestone("Device unmounted: %1", umount_device(mpoint));
// restart ALSA after SoundFont copy
- y2milestone("Restarting ALSA: %1",
- SCR::Execute(.target.bash, "/etc/init.d/alsasound reload"));
+ string cmd = Directory::bindir + "/alsadrivers reload";
+ y2milestone("Executing: %1", cmd);
+ SCR::Execute(.target.bash, cmd);
}
// step4:
Modified: trunk/sound/sound/src/sound_write.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/sound_write.ycp?rev=68019&r1=68018&r2=68019&view=diff
==============================================================================
--- trunk/sound/sound/src/sound_write.ycp (original)
+++ trunk/sound/sound/src/sound_write.ycp Tue Apr 24 16:19:16 2012
@@ -73,10 +73,14 @@
import "Package";
import "Mode";
import "Report";
+ import "Directory";
import "Sound";
import "Joystick";
+ const string joy_cmd = Directory::bindir + "/joystickdrivers";
+ const string alsa_cmd = Directory::bindir + "/alsadrivers";
+
define void logmixer(string when) {
// log mixer settings
y2milestone("Mixer (%1): %2", when, SCR::Execute(.target.bash_output, "/usr/bin/amixer"));
@@ -259,12 +263,16 @@
if (!Sound::write_only)
{
// stop joystick before restarting ALSA
- SCR::Execute(.target.bash, "/etc/init.d/joystick stop", $[]);
+ string cmd = joy_cmd + " unload";
+ y2milestone("Executing: %1", cmd);
+ SCR::Execute(.target.bash, cmd);
// restart ALSA
if (size(configuredcards) > 0)
{
- SCR::Execute(.target.bash, "/etc/init.d/alsasound reload", $[]);
+ cmd = alsa_cmd + " reload";
+ y2milestone("Executing: %1", cmd);
+ SCR::Execute(.target.bash, cmd);
}
}
Modified: trunk/sound/sound/src/volume_routines.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/volume_routines.ycp?rev=68019&r1=68018&r2=68019&view=diff
==============================================================================
--- trunk/sound/sound/src/volume_routines.ycp (original)
+++ trunk/sound/sound/src/volume_routines.ycp Tue Apr 24 16:19:16 2012
@@ -195,8 +195,9 @@
if (Sound::use_alsa)
{
- SCR::Execute (.target.bash,
- "/etc/init.d/alsasound unload > /dev/null 2>&1", $[]);
+ string cmd = Directory::bindir + "/alsadrivers unload";
+ y2milestone("Executing: %1", cmd);
+ SCR::Execute(.target.bash, cmd);
boolean aoa_used = false;
foreach(map card, Sound::modules_conf,
Modified: trunk/sound/yast2-sound.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/yast2-sound.spec.in?rev=68019&r1=68018&r2=68019&view=diff
==============================================================================
--- trunk/sound/yast2-sound.spec.in (original)
+++ trunk/sound/yast2-sound.spec.in Tue Apr 24 16:19:16 2012
@@ -48,6 +48,8 @@
@desktopdir@/sound.desktop
@desktopdir@/joystick.desktop
@ybindir@/copyfonts
+@ybindir@/alsadrivers
+@ybindir@/joystickdrivers
@moduledir@/Sound.*
@moduledir@/Joystick.*
@moduledir@/PulseAudio.*
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org