1 |
ssuominen 14/06/23 21:34:42 |
2 |
|
3 |
Added: alsasound.initd-r6 |
4 |
Log: |
5 |
Version bump wrt #513670 by "PG". Don't save pulseaudio state files to filesystem root directory / wrt #438844 by Alexander Tsoy. |
6 |
|
7 |
(Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key 4868F14D) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 media-sound/alsa-utils/files/alsasound.initd-r6 |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r6?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r6?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: alsasound.initd-r6 |
16 |
=================================================================== |
17 |
#!/sbin/runscript |
18 |
# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r6,v 1.1 2014/06/23 21:34:42 ssuominen Exp $ |
19 |
# Copyright 1999-2014 Gentoo Foundation |
20 |
# Distributed under the terms of the GNU General Public License v2 |
21 |
|
22 |
alsastatedir=/var/lib/alsa |
23 |
alsascrdir=/etc/alsa.d |
24 |
alsahomedir=/var/run/alsasound |
25 |
|
26 |
extra_commands="save restore" |
27 |
|
28 |
depend() { |
29 |
need localmount |
30 |
after bootmisc modules isapnp coldplug hotplug |
31 |
} |
32 |
|
33 |
restore() { |
34 |
ebegin "Restoring Mixer Levels" |
35 |
|
36 |
checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1 |
37 |
|
38 |
if [ ! -r "${alsastatedir}/asound.state" ] ; then |
39 |
ewarn "No mixer config in ${alsastatedir}/asound.state, you have to unmute your card!" |
40 |
eend 0 |
41 |
return 0 |
42 |
fi |
43 |
|
44 |
local cards="$(sed -n -e 's/ *\([[:digit:]]*\) .*/\1/p' /proc/asound/cards)" |
45 |
local CARDNUM |
46 |
for cardnum in ${cards}; do |
47 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
48 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
49 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
50 |
[ -e /dev/snd/controlC${cardnum} ] || sleep 2 |
51 |
alsactl -E HOME="${alsahomedir}" -I -f "${alsastatedir}/asound.state" restore ${cardnum} \ |
52 |
|| ewarn "Errors while restoring defaults, ignoring" |
53 |
done |
54 |
|
55 |
for ossfile in "${alsastatedir}"/oss/card*_pcm* ; do |
56 |
[ -e "${ossfile}" ] || continue |
57 |
# We use cat because I'm not sure if cp works properly on /proc |
58 |
local procfile=${ossfile##${alsastatedir}/oss} |
59 |
procfile="$(echo "${procfile}" | sed -e 's,_,/,g')" |
60 |
if [ -e /proc/asound/"${procfile}"/oss ] ; then |
61 |
cat "${ossfile}" > /proc/asound/"${procfile}"/oss |
62 |
fi |
63 |
done |
64 |
|
65 |
eend 0 |
66 |
} |
67 |
|
68 |
save() { |
69 |
ebegin "Storing ALSA Mixer Levels" |
70 |
|
71 |
checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1 |
72 |
|
73 |
mkdir -p "${alsastatedir}" |
74 |
if ! alsactl -E HOME="${alsahomedir}" -f "${alsastatedir}/asound.state" store; then |
75 |
eerror "Error saving levels." |
76 |
eend 1 |
77 |
return 1 |
78 |
fi |
79 |
|
80 |
for ossfile in /proc/asound/card*/pcm*/oss; do |
81 |
[ -e "${ossfile}" ] || continue |
82 |
local device=${ossfile##/proc/asound/} ; device=${device%%/oss} |
83 |
device="$(echo "${device}" | sed -e 's,/,_,g')" |
84 |
mkdir -p "${alsastatedir}/oss/" |
85 |
cp "${ossfile}" "${alsastatedir}/oss/${device}" |
86 |
done |
87 |
|
88 |
eend 0 |
89 |
} |
90 |
|
91 |
start() { |
92 |
if [ "${RESTORE_ON_START}" = "yes" ]; then |
93 |
restore |
94 |
fi |
95 |
|
96 |
return 0 |
97 |
} |
98 |
|
99 |
stop() { |
100 |
if [ "${SAVE_ON_STOP}" = "yes" ]; then |
101 |
save |
102 |
fi |
103 |
return 0 |
104 |
} |