Bug 133535 - Sound settings not restored on startup
Sound settings not restored on startup
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: alsa-utils (Show other bugs)
3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
:
: 133598 133939 136071 137311 (view as bug list)
Depends On:
Blocks: FC3Target
  Show dependency treegraph
 
Reported: 2004-09-24 13:39 EDT by Paul F. Johnson
Modified: 2014-03-16 22:48 EDT (History)
12 users (show)

See Also:
Fixed In Version: 1.0.6-3
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-20 16:39:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
/etc/dev.d/sound/alsa.dev file (219 bytes, text/plain)
2004-09-27 03:08 EDT, Féliciano Matias
no flags Details
/etc/dev.d/sound/alsa.dev file (246 bytes, patch)
2004-09-27 04:28 EDT, Féliciano Matias
no flags Details | Diff
strace output 1 (8.23 KB, text/plain)
2004-10-15 18:31 EDT, Christopher Stone
no flags Details
strace output 2 (8.23 KB, text/plain)
2004-10-15 18:32 EDT, Christopher Stone
no flags Details
strace output 3 (8.72 KB, text/plain)
2004-10-15 18:33 EDT, Christopher Stone
no flags Details
/etc/dev.d/sound/alsa.dev file (use controlC*) (244 bytes, text/plain)
2004-10-16 04:19 EDT, Féliciano Matias
no flags Details
/etc/dev.d/sound/alsa.dev file (use controlC*) (229 bytes, text/plain)
2004-10-16 04:28 EDT, Féliciano Matias
no flags Details
new script (238 bytes, text/plain)
2004-10-19 23:25 EDT, Bill Nottingham
no flags Details
strace on boot (10.85 KB, text/plain)
2004-10-20 15:12 EDT, Christopher Stone
no flags Details
strace after boot (8.72 KB, text/plain)
2004-10-20 15:14 EDT, Christopher Stone
no flags Details
/etc/rc.d/init.d/alsactl (1.37 KB, text/plain)
2004-10-20 16:17 EDT, Féliciano Matias
no flags Details

  None (edit)
Description Paul F. Johnson 2004-09-24 13:39:08 EDT
Description of problem:
When I shut down and restart my machine, I have to either re-run
system-config-soundcard or use gnome-volumecontrol to unmute/reenable
my sound card levels

Version-Release number of selected component (if applicable):
1.0.6-1 (both alsa-lib and alsa-utils)

How reproducible:
Always

Steps to Reproduce:
1. Shut down and restart
2.
3.
  
Actual results:
Sound levels reset to muted on all devices

Expected results:
Sound levels should be the same as when the desktop was left

Additional info:
Comment 1 Bill Nottingham 2004-09-24 14:36:08 EDT
What do the sound levels look like *before* the desktop is loaded?
Comment 2 Paul F. Johnson 2004-09-24 17:17:52 EDT
How do I find that out?

I know if I log in a terminal, I cannot hear anything from the CD player.
Comment 3 Bill Nottingham 2004-09-24 18:25:50 EDT
Run alsamixer on a terminal, see what things are set at.
Comment 4 Bill Nottingham 2004-09-24 20:37:55 EDT
*** Bug 133598 has been marked as a duplicate of this bug. ***
Comment 5 David Nielsen 2004-09-24 20:45:31 EDT
I just rebooted and checked - Master is set to Off which it wasn't
before the reboot.
Comment 6 Bill Nottingham 2004-09-25 02:22:32 EDT
What happens if you manually run 'alsactl restore'?
Comment 7 Paul F. Johnson 2004-09-25 05:35:28 EDT
Nothing. I still have to restore the settings manually
Comment 8 raxet 2004-09-25 13:57:07 EDT
After doing an alsactl store and then placing alsactl restore in the
rc.local and I don't have to manually restore from soundcard detect or
volume-control after reboot. Works for me like it used to Fedora Cores
before. :)
Comment 9 Féliciano Matias 2004-09-27 03:04:42 EDT
The issue have been describe here :
http://www.redhat.com/archives/fedora-test-list/2004-September/msg01233.html

Bill Nottingham suggested to use /etc/dev.d .

Note that "install snd-XXXX /sbin/modprobe ..." lines in modprobe are
useless.

Patch coming.
Comment 10 Féliciano Matias 2004-09-27 03:08:41 EDT
Created attachment 104355 [details]
/etc/dev.d/sound/alsa.dev file

Note that we can't use /etc/dev.d/ to store sound setting (modules marked
"Unloading").
The "remove snd-XXXX { /usr/sbin/alsactl store ..." line in modprobe.conf works
fine.
Comment 11 Féliciano Matias 2004-09-27 03:13:41 EDT
The component should be set to udev.
Comment 12 Féliciano Matias 2004-09-27 04:28:21 EDT
Created attachment 104356 [details]
/etc/dev.d/sound/alsa.dev file

Check if /usr/sbin/alsactl is executable.
Comment 13 Bill Nottingham 2004-09-27 11:56:54 EDT
If we're going the dev.d route, we really should move alsa-lib and
alsactl to the root FS.
Comment 14 Féliciano Matias 2004-09-27 13:44:34 EDT
I think audio, tv, nvidea, etc... should be loaded (modprobe) after
all local filesystems (think /usr) are mounted.

I don't see why we had to modprobe "misc" modules very early at boot time.

This should be done in a service like named ou httpd. Launched after
kudzu service.
Comment 15 Bill Nottingham 2004-09-29 00:48:01 EDT
*** Bug 133939 has been marked as a duplicate of this bug. ***
Comment 16 Richard Hughes 2004-10-01 02:37:46 EDT
My systems is updated to rawhide. I've had to manually unmute my
volume every time I start my laptop for the last couple of weeks. The
file proposed by Féliciano Matias in Comment #12 works for me - my
ALSA volumes are no longer muted or set to 0. Is this not a blocker
for FC3?
Comment 17 Bill Nottingham 2004-10-14 17:51:29 EDT
Fixed in alsa-utils-1.0.6-2. Note that the script has to operate on
/dev/snd/pcmXXX; /dev/snd/controlXX is available before the actual
mixer is. :/
Comment 18 Christopher Stone 2004-10-15 14:09:20 EDT
Hello.  I just tested a reboot using alsa-utils-1.0.6-2, and my volume
is still being reset to zero.  I still need to type alsactl restore in
order to get my volume back.  Anything I'm doing wrong, or missing?
Comment 19 Bill Nottingham 2004-10-15 15:06:06 EDT
Presumably this is on a udev-enabled system?

a) do you have a separate /usr?
b) what sort of card?
Comment 20 Christopher Stone 2004-10-15 15:17:26 EDT
Bill, I am running FC3T3 with yum updates installed.  I don't have a
seperate /usr.  lspci says I have:

02:0c.0 Multimedia audio controller: ESS Technology ES1978 Maestro 2E
(rev 10)
Comment 21 Bill Nottingham 2004-10-15 16:10:24 EDT
Does the new alsa-utils and alsa-lib work for other people, or do they
see the same failure?
Comment 22 David Nielsen 2004-10-15 17:03:16 EDT
Doesn't restore volume levels here either, using a SB Live! 5.1 card
(emu10k1).
Comment 23 Christopher Stone 2004-10-15 17:07:41 EDT
How can I debug this?  I tried to put echo lines in
/etc/dev.d/sound/alsa.dev but I did not see any of my echo statements
being printed on boot.   I can't even tell if this file is being
executed.  What should $DEVPATH be equal to? Can I test to see if the
sed statement works for my configuration?  Where does my volume
settings get stored when I shutdown? I had an /etc/asound.state file
from when I ran alsactl store before, should I remove this file?  I am
currently running:

udev-038-1
alsa-utils-1.0.6-2
alsa-lib-1.0.6-3
Comment 24 Bill Nottingham 2004-10-15 17:13:14 EDT
1) it's executed without a tty. Debugging echos (or whatever) would
need to be dumped to a file in /tmp or similar
2) DEVPATH is the name of the path in /sys that is triggering the udev
event... /sys/class/sound/pcmC0D0c, for example.
3) volume settings are stored in /etc/asound.state on shutdown
4) no, you shouldn't remove it (although, you may want to check to see
if it's *storing* zero/muted volume.
Comment 25 Christopher Stone 2004-10-15 17:28:08 EDT
okay, I put in the debug statements and sent them to a file in /tmp,
and here is what I found out:

DEVPATH is equal to /class/sound/mixer and therefore the sed statement
in alsa.dev fails. 
Comment 26 Bill Nottingham 2004-10-15 17:36:02 EDT
That's the only one you get? (There should be about 10 or twelve udev
invocations... if you do '>' instead of '>>' you'll only get the last
one.)
Comment 27 Christopher Stone 2004-10-15 17:53:49 EDT
ok here is my modified script:

#!/bin/sh
echo "$ACTION" >> /tmp/udev.dbg
if [ "$ACTION" = "add" ]; then
        echo "$DEVPATH" >> /tmp/udev.dbg
        card=`echo $DEVPATH | sed -n -e
"s/^\/class\/sound\/pcmC\([[:digit:]]\+\).*/\1/p"`
        echo "$card" >> /tmp/udev.dbg
        if [ -n "$card" -a -x /sbin/alsactl ] ; then
                echo "restoring..." >> /tmp/udev.dbg
                /sbin/alsactl restore $card > /dev/null 2>&1
        fi
fi

and here is the output I get:

add
/class/sound/pcmC0D0c
add
/class/sound/pcmC0D0p
add
/class/sound/midiC0D0
0
restoring...
0
restoring...

add
/class/sound/controlC0
add
/class/sound/timer
add
/class/sound/midi
add

/class/sound/dmmidi

add
/class/sound/dsp

add
/class/sound/audio

add
/class/sound/mixer

So it appears it's trying to restore the volume twice, I guess the
output file is not necessarily in the correct order.  My guess is that
its calling alsactl restore on both the pcmC0D0c and pcmC0D0p.

When I boot into KDE though, the volume is set to zero, and if I issue
the command alsactl restore 0 by hand, the volume gets reset correctly.
Comment 28 Bill Nottingham 2004-10-15 18:07:32 EDT
Hm, just to make sure, it's also set at 0 before you run kde?


Could you change it to strace -o /tmp/alsactl.$$ /sbin/alsactl restore ...

and post the output?
Comment 29 Christopher Stone 2004-10-15 18:21:37 EDT
I changed the script to use:
trace -o /tmp/alsactl.$$ /sbin/alsactl restore $card > /dev/null 2>&1

and while my /tmp/udev.dbg file shows it calling restore twice, there
were no /tmp/alsactl.* files:

# ls /tmp/al*
ls: /tmp/al*: No such file or directory
Comment 30 Christopher Stone 2004-10-15 18:22:42 EDT
oh @(&#$()@#$ i just realized i used trace and not strace, stupid cut
& paste!  trying again...
Comment 31 Christopher Stone 2004-10-15 18:31:45 EDT
Created attachment 105310 [details]
strace output 1

strace of first alsactl call
Comment 32 Christopher Stone 2004-10-15 18:32:39 EDT
Created attachment 105311 [details]
strace output 2

strace output of second alsactl call
Comment 33 Christopher Stone 2004-10-15 18:33:31 EDT
Created attachment 105312 [details]
strace output 3

strance of alsactl call by hand that works.
Comment 34 Bill Nottingham 2004-10-15 23:05:34 EDT
So, on *my* test box, /dev/snd/controlC0 gets created first, then
/dev/snd/pcmC0...

We trigger on /dev/snd/pcmC0... and the restore works.

On your box, /dev/snd/pcmC0 gets created first, and /dev/snd/controlC0
last.

(Instead of an strace, before the call to alsactl, can you just do 'ls
-l /dev/snd > /tmp/foo.$$ (or whatever), to verify this?)

I think I'm going to go shoot myself now. Or the udev maintainer. :/
Comment 35 Christopher Stone 2004-10-15 23:15:42 EDT
Well, they all have the same date, so I did ls -lt to order by time
where the oldest files are listed last:

$ ls -lt /dev/snd
total 0
crw-------  1 chris root 116,  1 Oct 15 15:59 seq
crw-------  1 chris root 116, 33 Oct 15 15:29 timer
crw-------  1 chris root 116,  0 Oct 15 15:29 controlC0
crw-------  1 chris root 116, 16 Oct 15 15:29 pcmC0D0p
crw-------  1 chris root 116, 24 Oct 15 15:29 pcmC0D0c
crw-------  1 chris root 116,  8 Oct 15 15:29 midiC0D0
Comment 36 Féliciano Matias 2004-10-16 04:07:40 EDT
I do not understand the use of /class/sound/pcmC*

I trace alsa.dev :
#!/bin/sh
/usr/bin/logger -t $(basename $0)"[$$]" : $DEVPATH
if [ "$ACTION" = "add" ]; then
        card=`echo $DEVPATH | sed -n -e
"s/^\/class\/sound\/pcmC\([[:digit:]]\+\).*/\1/p"`
        if [ -n "$card" -a -x /sbin/alsactl ] ; then
                /usr/bin/logger -t $(basename $0)"[$$]" : $card :
`/sbin/alsactl restore $card 2>&1`
        fi
fi

Here is what I get :

Card 0 (snd-ens1371) :

/class/sound/midiC0D0
/class/sound/pcmC0D1p
0 : /sbin/alsactl: set_controls:986: snd_ctl_open error: No such file
or directory
/class/sound/pcmC0D0p
0 : /sbin/alsactl: set_controls:986: snd_ctl_open error: No such file
or directory
/class/sound/pcmC0D0c
0 : /sbin/alsactl: set_controls:986: snd_ctl_open error: No such file
or directory
/class/sound/controlC0
/class/sound/timer
/class/sound/dmmidi
/class/sound/midi
/class/sound/adsp
/class/sound/audio
/class/sound/mixer
/class/sound/dsp



Card 1 (snd-via82xx) :

/class/sound/pcmC1D1p
1 : /sbin/alsactl: set_controls:986: snd_ctl_open error: No such file
or directory
/class/sound/pcmC1D0p
/class/sound/pcmC1D1c
1 : /sbin/alsactl: set_controls:986: snd_ctl_open error: No such file
or directory
/class/sound/pcmC1D0c
1 : /sbin/alsactl: set_controls:986: snd_ctl_open error: No such file
or directory
1 : /sbin/alsactl: set_controls:986: snd_ctl_open error: No such file
or directory
/class/sound/controlC1
/class/sound/adsp1
/class/sound/dsp1
/class/sound/audio1
/class/sound/mixer1


alsactl is called 3 times for the first card and 4 times for the
second card.
pcmC* is brought before controlC* but alsactl only use controlC* .
When pcmC* are created, controlC* do not exist ("No such file or
directory" error message)


If alsa.dev use controlC* there is another problem described (as I
understand) here :
http://www.redhat.com/archives/fedora-test-list/2004-October/msg00647.html

This "bug" append with udev >= 034. I got "No such device". It's
different than "No such file or directory".
I proposed a ugly workaround.

Harald Hoyer said the problem is perhaps related to the new
wait_for_sysfs.

Good news ! udev-038-1 and my previous patch (
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=104356&action=view
) work nicely :-)
Comment 37 Féliciano Matias 2004-10-16 04:19:13 EDT
Created attachment 105320 [details]
/etc/dev.d/sound/alsa.dev file (use controlC*)

cleanup and update to use /sbin/alsactl (alsa-utils-1.0.6-2).
Comment 38 Féliciano Matias 2004-10-16 04:28:18 EDT
Created attachment 105321 [details]
/etc/dev.d/sound/alsa.dev file (use controlC*)

Cleanup.
Comment 39 Bill Nottingham 2004-10-16 23:43:41 EDT
Ahh... except with some sound drivers, controlC0 is registered first..
before there is any hardware device available.

So that won't work either.

Basically, ALSA is pretty broken.
Comment 40 Christopher Stone 2004-10-17 00:00:58 EDT
Why don't we use both cases? One of them is eventually bound to work.
Comment 41 Bill Nottingham 2004-10-17 00:11:44 EDT
That's probably what has to be done, but it certainly sets off the
ick-o-meter.
Comment 42 Bill Nottingham 2004-10-17 23:13:54 EDT
*** Bug 136071 has been marked as a duplicate of this bug. ***
Comment 43 Bill Nottingham 2004-10-19 23:25:21 EDT
Created attachment 105491 [details]
new script

This is what's going to be in alsa-utils-1.0.6-3 - does this work for people?
Comment 44 Féliciano Matias 2004-10-20 04:53:16 EDT
> does this work for people?

Works here with snd-ens1371 and snd-via82xx.
Comment 45 Rodd Clarkson 2004-10-20 06:17:21 EDT
Didn't work for me.

I've got a 00:08.0 Multimedia audio controller: ESS Technology ES1978
Maestro 2E (rev 10)

All the volumes are at 0 (no volume) and most of the volumes are muted.

On shutdown, the PCM and CD volumes were at about 80% and both weren't
muted.
Comment 46 Christopher Stone 2004-10-20 15:06:02 EDT
Still doesn't work for me either.  I did an strace on the alsactl call
and it looks okay to me.  Still need to run alsactl by hand after boot
for it to work.

My sound card is a ESS Technology ES1978 Maestro 2E (rev 10)
Comment 47 Christopher Stone 2004-10-20 15:12:47 EDT
Created attachment 105541 [details]
strace on boot
Comment 48 Christopher Stone 2004-10-20 15:14:13 EDT
Created attachment 105542 [details]
strace after boot

Notice the strace after boot uses ioctl(3,...) and the one during boot uses
ioctl(0,...)
Comment 49 Bill Nottingham 2004-10-20 15:23:04 EDT
The boot environment has no stdin/stdout/stderr. But it looks like it
succeeds... odd.
Comment 50 Christopher Stone 2004-10-20 16:05:50 EDT
I did some more testing.  Booting into runlevel 3, the sound is
restored properly.  Logging into GNOME, the sound is restored
properly.  Logging into KDE, the sound is reset to zero.
Comment 51 Féliciano Matias 2004-10-20 16:16:04 EDT
Time for an ugly solution ? OK, I do it :-)

As alsa did some time ago, perhaps we should use /etc/rc.d/init.d/alsactl.
It's just for the record.

alsa-utils.spec :

postinstall scriptlet (using /bin/sh):
/sbin/chkconfig --add alsactl
/sbin/chkconfig alsactl on

preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ]; then
   /sbin/chkconfig --del alsactl
   /sbin/service alsactl condstop >/dev/null 2>&1
fi


postuninstall scriptlet (using /bin/sh):
if [ "$1" -ge 1 ]; then
    /sbin/service alsactl condrestart >/dev/null 2>&1 || :
fi


Not tested.
/etc/rc.d/init.d/alsactl coming.
Comment 52 Féliciano Matias 2004-10-20 16:17:50 EDT
Created attachment 105546 [details]
/etc/rc.d/init.d/alsactl

A proposition to use /etc/rc.d/init.d/alsactl as a workaround.
Comment 53 Christopher Stone 2004-10-20 16:29:04 EDT
I think it's working properly, I think it's KDE's fault that the sound
is resetting now, as it works in runlevel 3 and in GNOME.
Comment 54 Bill Nottingham 2004-10-20 16:39:00 EDT
Yeah, if it's just failing in KDE, KDE is doing something odd. Please
file a new bug against that.

Closing as resolved.
Comment 55 Christopher Stone 2004-10-20 16:47:29 EDT
For those who want to continue following this, the new bug is open at
bug #136543
Comment 56 Bill Nottingham 2004-10-27 12:16:15 EDT
*** Bug 137311 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.