1 |
beandog 09/07/31 21:49:39 |
2 |
|
3 |
Added: alsasound.confd-r3 alsasound.initd-r3 |
4 |
Log: |
5 |
Remove UNLOAD_ON_STOP and KILLPROC_ON_STOP options |
6 |
(Portage version: 2.2_rc33/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 media-sound/alsa-utils/files/alsasound.confd-r3 |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-utils/files/alsasound.confd-r3?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-utils/files/alsasound.confd-r3?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: alsasound.confd-r3 |
15 |
=================================================================== |
16 |
# ENABLE_OSS_EMUL: |
17 |
# Do you want to enable in-kernel oss emulation? |
18 |
# no - Do not load oss emul drivers |
19 |
# yes - Load oss emul drivers if they're found |
20 |
|
21 |
ENABLE_OSS_EMUL="yes" |
22 |
|
23 |
# RESTORE_ON_START: |
24 |
# Do you want to restore your mixer settings? If not, your cards will be |
25 |
# muted. |
26 |
# no - Do not restore state |
27 |
# yes - Restore state |
28 |
|
29 |
RESTORE_ON_START="yes" |
30 |
|
31 |
# SAVE_ON_STOP: |
32 |
# Do you want to save changes made to your mixer volumes when alsasound |
33 |
# stops? |
34 |
# no - Do not save state |
35 |
# yes - Save state |
36 |
|
37 |
SAVE_ON_STOP="yes" |
38 |
|
39 |
# LOAD_ON_START: |
40 |
# Do you want to load sound modules when alsasound starts? |
41 |
# Note: The Gentoo ALSA developers encourage you to build your sound |
42 |
# drivers into the kernel unless the device is hotpluggable or |
43 |
# you need to supply specific options (such as model= to HD-Audio). |
44 |
# no - Do not load modules |
45 |
# yes - Load modules |
46 |
LOAD_ON_START="yes" |
47 |
|
48 |
|
49 |
|
50 |
1.1 media-sound/alsa-utils/files/alsasound.initd-r3 |
51 |
|
52 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r3?rev=1.1&view=markup |
53 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r3?rev=1.1&content-type=text/plain |
54 |
|
55 |
Index: alsasound.initd-r3 |
56 |
=================================================================== |
57 |
#!/sbin/runscript |
58 |
# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r3,v 1.1 2009/07/31 21:49:39 beandog Exp $ |
59 |
# Copyright 2007 Gentoo Foundation |
60 |
# Distributed under the terms of the GNU General Public License v2 |
61 |
|
62 |
alsastatedir=/var/lib/alsa |
63 |
alsascrdir=/etc/alsa.d |
64 |
|
65 |
opts="save restore" |
66 |
|
67 |
depend() { |
68 |
need localmount |
69 |
after bootmisc modules isapnp coldplug hotplug |
70 |
} |
71 |
|
72 |
load_modules() { |
73 |
# List of drivers for each card. |
74 |
local DRIVERS="$(modprobe -c | sed -n -e 's/^alias \(snd-card-[[:digit:]]\+\) .*/\1/p')" |
75 |
|
76 |
# Fall back on the automated aliases if we don't have ALSA configured properly... |
77 |
if [ -z "${DRIVERS}" ] && \ |
78 |
( [ ! -r /proc/asound/cards ] || grep -q ' no soundcards ' /proc/asound/cards 2>/dev/null ) ; then |
79 |
ewarn "Could not detect custom ALSA settings. Loading all detected alsa drivers." |
80 |
DRIVERS="$(modprobe -c | sed -n -e '/^alias pci:.* snd.*/ s/^alias pci:[^ ]* \(.*\)/\1/p' | sort | uniq)" |
81 |
if [ -z "${DRIVERS}" ] ; then |
82 |
eerror "Unable to find any ALSA drivers. Have you compiled alsa-drivers correctly?" |
83 |
fi |
84 |
fi |
85 |
|
86 |
if [ "${ENABLE_OSS_EMUL}" = "yes" ] ; then |
87 |
DRIVERS="${DRIVERS} $(modprobe -l | sed -n -e '/snd.*oss/ s:\/.*\/\(.*\).ko:\1:p')" |
88 |
fi |
89 |
|
90 |
# We want to ensure snd-seq is loaded as it is needed for things like |
91 |
# timidity even if we don't use a real sequencer. |
92 |
DRIVERS="${DRIVERS} $(modprobe -l | sed -n -e '/snd.seq\./ s:\/.*\/\(.*\).ko:\1:p')" |
93 |
|
94 |
# We want to ensure snd-ioctl32 is loaded as it is needed for 32bit |
95 |
# compatibility |
96 |
DRIVERS="${DRIVERS} $(modprobe -l | sed -n -e '/snd.ioctl32\./ s:\/.*\/\(.*\).ko:\1:p')" |
97 |
|
98 |
local DRIVER= DMOD= |
99 |
for DRIVER in ${DRIVERS} ; do |
100 |
[ "${DRIVER}" = "off" ] && continue |
101 |
DMOD="$(echo "${DRIVER}" | sed -e 's/-/_/g')" |
102 |
if ! grep -q "^${DMOD} " /proc/modules ; then |
103 |
ebegin "Loading: ${DRIVER}" |
104 |
modprobe ${DRIVER} |
105 |
eend $? |
106 |
fi |
107 |
done |
108 |
|
109 |
if [ -f /proc/asound/seq/drivers ] ; then |
110 |
local SEQUENCERS="$(sed -n -e 's/\([^,]*\),empty,.*/\1/p' /proc/asound/seq/drivers)" |
111 |
local SEQUENCER |
112 |
for SEQUENCER in ${SEQUENCERS} ; do |
113 |
DMOD="$(echo "${SEQUENCER}" | sed -e 's/-/_/g')" |
114 |
if ! grep -q "^${DMOD} " /proc/modules ; then |
115 |
ebegin "Loading: ${SEQUENCER}" |
116 |
modprobe ${SEQUENCER} |
117 |
eend $? |
118 |
fi |
119 |
done |
120 |
fi |
121 |
|
122 |
for DRIVER in ${DRIVERS} |
123 |
do |
124 |
local TMP=${DRIVER##snd-} |
125 |
TMP=${TMP##snd_} |
126 |
if [ -x "${alsascrdir}/${TMP}" ] ; then |
127 |
ebegin "Running: ${alsascrdir}/${TMP}" |
128 |
"${alsascrdir}/${TMP}" |
129 |
eend $? |
130 |
fi |
131 |
done |
132 |
|
133 |
if [ ! -d /proc/asound ] || grep -q ' no soundcards ' /proc/asound/cards ; then |
134 |
eerror "ERROR: Failed to load necessary drivers" |
135 |
return 1 |
136 |
fi |
137 |
} |
138 |
|
139 |
unload_modules_24() { |
140 |
local LOADED_MODULES="$(lsmod | sed -n -e 's/^\(snd[^ ]*\) .*/\1/p')" |
141 |
local MODULE |
142 |
for MODULE in ${LOADED_MODULES} ; do |
143 |
rmmod "${MODULE}" |
144 |
done |
145 |
rmmod soundcore 2>/dev/null |
146 |
rmmod gameport 2>/dev/null |
147 |
|
148 |
lsmod | grep -vq '^snd' |
149 |
} |
150 |
|
151 |
unload_modules_recursive() { |
152 |
local revdeps="$(lsmod | sed -n -e "s/,/ /g" -e "s/^$1 *[0-9]* *[0-9]* \(.*\)/\1/p")" |
153 |
|
154 |
for module in ${revdeps} ; do |
155 |
unload_modules_recursive "${module}" |
156 |
done |
157 |
|
158 |
vebegin "Unloading: $1" |
159 |
rmmod --wait "$1" |
160 |
veend $? |
161 |
} |
162 |
|
163 |
unload_modules_26() { |
164 |
# First of all, remove the snd module and all the modules depending |
165 |
# on it, this should remove already most of ALSA modules. |
166 |
lsmod | grep -q "^snd[[:space:]]" && unload_modules_recursive snd |
167 |
|
168 |
# Then find the remaining ones, and handle them too. |
169 |
for module in $(lsmod | sed -n -e 's/^\(snd[^ ]*\) .*/\1/p'); do |
170 |
unload_modules_recursive "${module}" |
171 |
done |
172 |
|
173 |
lsmod | grep -vq "^snd" |
174 |
} |
175 |
|
176 |
terminate() { |
177 |
# |
178 |
# Kill processes holding open sound devices |
179 |
# |
180 |
# DEVS=`find /dev/ -follow -type c -maxdepth 1 -print 2>/dev/null | xargs ls -dils | grep "1*1[46]," | cut -d: -f2 | cut -d" " -f2; echo /proc/asound/dev/*` |
181 |
local ossdevs="/dev/admmidi* /dev/adsp* /dev/amidi* /dev/audio* /dev/dmfm* \ |
182 |
/dev/dmmidi* /dev/dsp* /dev/dspW* /dev/midi0* /dev/mixer* /dev/music \ |
183 |
/dev/patmgr* /dev/sequencer* /dev/sndstat" |
184 |
local alsadevs="/proc/asound/dev/* /dev/sound/* /dev/snd/*" |
185 |
fuser -k ${ossdevs} ${alsadevs} >/dev/null 2>/dev/null |
186 |
|
187 |
# remove all sequencer connections if any |
188 |
[ -f /proc/asound/seq/clients ] && type aconnect >/dev/null 2>/dev/null && aconnect --removeall |
189 |
} |
190 |
|
191 |
restore() { |
192 |
ebegin "Restoring Mixer Levels" |
193 |
|
194 |
if [ ! -r "${alsastatedir}/asound.state" ] ; then |
195 |
ewarn "No mixer config in ${alsastatedir}/asound.state, you have to unmute your card!" |
196 |
eend 0 |
197 |
return 0 |
198 |
fi |
199 |
|
200 |
local cards="$(sed -n -e 's/ *\([[:digit:]]*\) .*/\1/p' /proc/asound/cards)" |
201 |
local CARDNUM |
202 |
for cardnum in ${cards}; do |
203 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
204 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
205 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
206 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
207 |
alsactl -f "${alsastatedir}/asound.state" restore ${cardnum} \ |
208 |
|| ewarn "Errors while restoring defaults, ignoring" |
209 |
done |
210 |
|
211 |
for ossfile in "${alsastatedir}"/oss/card*_pcm* ; do |
212 |
[ -e "${ossfile}" ] || continue |
213 |
# We use cat because I'm not sure if cp works properly on /proc |
214 |
local procfile=${ossfile##${alsastatedir}/oss} |
215 |
procfile="$(echo "${procfile}" | sed -e 's,_,/,g')" |
216 |
if [ -e /proc/asound/"${procfile}"/oss ] ; then |
217 |
cat "${ossfile}" > /proc/asound/"${procfile}"/oss |
218 |
fi |
219 |
done |
220 |
|
221 |
eend 0 |
222 |
} |
223 |
|
224 |
save() { |
225 |
ebegin "Storing ALSA Mixer Levels" |
226 |
|
227 |
mkdir -p "${alsastatedir}" |
228 |
if ! alsactl -f "${alsastatedir}/asound.state" store; then |
229 |
eerror "Error saving levels." |
230 |
eend 1 |
231 |
return 1 |
232 |
fi |
233 |
|
234 |
for ossfile in /proc/asound/card*/pcm*/oss; do |
235 |
[ -e "${ossfile}" ] || continue |
236 |
local device=${ossfile##/proc/asound/} ; device=${device%%/oss} |
237 |
device="$(echo "${device}" | sed -e 's,/,_,g')" |
238 |
mkdir -p "${alsastatedir}/oss/" |
239 |
cp "${ossfile}" "${alsastatedir}/oss/${device}" |
240 |
done |
241 |
|
242 |
eend 0 |
243 |
} |
244 |
|
245 |
start() { |
246 |
if [ -f /proc/modules ] && [ "${LOAD_ON_START}" = "yes" ]; then |
247 |
ebegin "Loading ALSA modules" |
248 |
eindent |
249 |
load_modules |
250 |
eoutdent |
251 |
eend $? || return 1 |
252 |
fi |
253 |
|
254 |
if [ ! -d /proc/asound ]; then |
255 |
eerror "ALSA failed to load." |
256 |
eend 1 |
257 |
return 1 |
258 |
elif [ "${RESTORE_ON_START}" = "yes" ]; then |
259 |
restore |
260 |
fi |
261 |
|
262 |
return 0 |
263 |
} |
264 |
|
265 |
stop() { |
266 |
if [ ! -d /proc/asound ] ; then |
267 |
eerror "ALSA is not loaded" |
268 |
return 0 |
269 |
fi |
270 |
|
271 |
[ "${SAVE_ON_STOP}" = "yes" ] && save |
272 |
|
273 |
return 0 |
274 |
} |