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