[RFC] alsa i udev
lobo@chello.pl
lobo w chello.pl
Pią, 16 Gru 2005, 01:42:49 CET
Witam!
Od pewnego czasu używam już udeva, i udało mi się zwalczyć niedogodności
jakie wynikają z jego stosowania w przypadku alsy. Podczas jednej z
dyskusji na users z Jakubem Cłapą, zostałem poproszony o dopieszczenie
swoich rozwiązań i przygotowania tego dla PLD. Przygotowałem więc zestaw
skryptów do obsługi alsy w udevie, razem ze specem. Pakiet składa się z
następujących plików.
1. alsa.rules
Plik wywołujący mój skrypt w momencie dodania/usunięcia urządzeń
/dev/snd/controlC*
2. alsa.sh
Skrypt, który odtwarza ustawienia miksera, oraz w zależności od ustawień
w /etc/sysconfig/alsa_udev ładuje dodatkowe moduły i/lub odpala
dodatkowe skrypty.
3. alsasave.init
Jest to przerobiony sktypt z alsa-utils-init, który ma za zadanie
zachowywanie ustawień miksera podczas zamknięcia systemu.
4 i 5. spec oraz plik konfiguracyjny.
Na wszelki wypadek w alsa.sh dodałem również obsługę zdażenia remove.
Nie działa to dla kart pci, ale możliwe, że zadziała dla dzwięku na usb.
Proszę o komentarze i ewentualne dodanie ro zasobów cvs.
--
Pozdrawiam
Przemysław Białek
-------------- następna część ---------
SUBSYSTEM=="sound", KERNEL=="controlC*", RUN+="/etc/udev/scripts/alsa.sh %n"
-------------- następna część ---------
Załącznik, który nie był tekstem został usunięty...
Name: alsa.sh
Type: application/x-sh
Size: 618 bytes
Desc: nie znany
Url : /mailman/pipermail/pld-devel-pl/attachments/20051216/d2523616/alsa.sh
-------------- następna część ---------
# set this to yes if you want to load oss emulation
# OSS_EMULATION=yes
# list additional modules for first sound card
# MODULES_0=""
# postinstal script for first sound card
# POST_INSTALL_0=""
-------------- następna część ---------
#!/bin/sh
#
# alsasave This shell script takes care of stopping ALSA sound driver.
#
# This script requires /usr/sbin/alsactl program from alsa-utils package.
#
# Copyright (c) by Jaroslav Kysela <perex w jcu.cz>
#
# 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.
#
#
# For PLD Linux Distribution:
# chkconfig: 2345 80 14
# description: ALSA driver
#
# Source function library.
.. /etc/rc.d/init.d/functions
alsactl=/usr/sbin/alsactl
detect_stop()
{
#
# remove all sound modules
#
/sbin/lsmod | awk '/^snd/ { print $0 }' | while read line; do \
/sbin/rmmod `echo $line | cut -d ' ' -f 1`; \
done
}
driver_stop()
{
#
# store driver settings
#
if [ -x $alsactl ]; then
$alsactl store
else
show '!!!alsactl not found!!!'; fail
fi
}
# See how we were called.
case "$1" in
start)
#Not Needed, its for udev
;;
stop)
# Stop daemons.
if [ -d /proc/asound ]; then
show "Shutting down sound driver:"
busy
if [ -f /proc/asound/detect ]; then
detect_stop
else
driver_stop
fi
(rmmod isapnp; rmmod soundcore) 2> /dev/null
ok
else
msg_not_running "ALSA driver"
fi
;;
save)
driver_stop
;;
status)
# TODO
;;
*)
msg_usage "$0 {start|stop|save|status}"
exit 3
esac
exit 0
-------------- następna część ---------
# $Revision:$, $Date:$
Summary: udev rules and scripts for Advanced Linux Sound Architecture
Summary(pl): reguły i skrypty udev dla Advanced Linux Sound Architecture
Name: alsa-udev
Version: 0.1
Release: 0.1
License: GPL
Group: Applications/Sound
Source0: alsa.rules
Source1: alsa.sh
Source2: alsa_udev.conf
Source3: alsasave.init
URL: http://www.alsa-project.org/
Requires(post,preun): /sbin/chkconfig
Requires: awk
Obsoletes: alsaconf
Obsoletes: alsa-init-tools
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
udev rules and scripts for Advanced Linux Sound Architecture.
%description
reguBy i skrypty udev dla Advanced Linux Sound Architecture.
%prep
%install
rm -rf $RPM_BUILD_ROOT
install -D %{SOURCE0} $RPM_BUILD_ROOT/etc/udev/rules.d/alsa.rules
install -D %{SOURCE1} $RPM_BUILD_ROOT/etc/udev/scripts/alsa.sh
install -D %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/alsa_udev
install -D %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/alsasave
%clean
rm -rf $RPM_BUILD_ROOT
%post
/sbin/chkconfig --add alsasave
%preun
if [ "$1" = "0" ]; then
/sbin/chkconfig --del alsasave
fi
%files
%defattr(644,root,root,755)
%attr(754,root,root) /etc/rc.d/init.d/*
%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/*
/etc/udev/rules.d/alsa.rules
%attr(754,root,root) /etc/udev/scripts/alsa.sh
%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
%changelog
* %{date} PLD Team <feedback w pld-linux.org>
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log:$
Więcej informacji o liście dyskusyjnej pld-devel-pl