Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 281631 - /etc/init.d/alsasound doesn't always restore mixer volume
Summary: /etc/init.d/alsasound doesn't always restore mixer volume
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo ALSA team
URL:
Whiteboard:
Keywords:
: 298840 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-08-16 03:19 UTC by Adam Nielsen
Modified: 2012-02-20 11:17 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Nielsen 2009-08-16 03:19:40 UTC
If there's an error during ALSA init, the initscript aborts and doesn't even try setting the volume.  You have to manually run 'alsactl restore' after logging in to set up the sound card volumes correctly.

/etc/init.d/alsasound should always try to run alsactl restore regardless of any previous failures.

In my case the errors are:

* Loading ALSA modules...
*   Loading: snd-card-0...  [ ok ]
* Restoring Mixer Levels...
Unknown hardware: "HDA-Intel" "Realtek ALC889A" "HDA:10ec0885,1458a002,00100101" "0x1458" "0xa022"
Hardware is initialized using a guess method
/usr/share/alsa/init/default:51: control element not found
/usr/share/alsa/init/default:52: control element not found
* Errors while restoring defaults, ignoring
No state is present for card Interface
Unknown hardware: "USB-Audio" "USB Mixer" "USB1430:474b" "" ""
Hardware is initialized using a guess method
/usr/share/alsa/init/default:53: control element not found
/usr/share/alsa/init/default:53: control element not found
* Errors while restoring defaults, ignoring
Comment 1 Steve Dibb (RETIRED) gentoo-dev 2009-08-17 16:15:25 UTC
Which card?  Need emerge --info
Comment 2 Adam Nielsen 2009-08-17 22:24:03 UTC
Not sure what you mean by 'which card' - it seems to fail for all sound cards on the system.  (But if it fails for the first card, it does keep going and tries the next card - but whatever problem causes this error, it skips alsactl on both cards which I think it shouldn't.)

$ emerge --info
Portage 2.1.6.13 (default/linux/amd64/2008.0, gcc-4.3.4, glibc-2.10.1-r0, 2.6.30 x86_64)
=================================================================
System uname: Linux-2.6.30-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q6600_@_2.40GHz-with-gentoo-2.0.1
Timestamp of tree: Wed, 12 Aug 2009 16:00:01 +0000
distcc 3.1 x86_64-pc-linux-gnu [disabled]
app-shells/bash:     4.0_p28
dev-java/java-config: 1.3.7-r1, 2.1.8-r1
dev-lang/python:     2.4.4-r6, 2.5.4-r3, 2.6.2-r1, 3.1
dev-python/pycrypto: 2.0.1-r8
dev-util/cmake:      2.6.4-r2
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.4.3-r3
sys-apps/sandbox:    2.0
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2, 1.11
sys-devel/binutils:  2.19.1-r1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.30-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=nocona -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -march=nocona -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://ftp.iinet.net.au/linux/Gentoo"
LANG="en_AU.UTF-8"
LC_ALL="en_AU.UTF-8"
LDFLAGS="-Wl,-O1"
LINGUAS="en_AU en_GB"
MAKEOPTS="-j12"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/desktop-effects /usr/i686-mingw32/usr/portage"
SYNC="rsync://rsync.teln.shikadi.net/gentoo-portage"
USE="X a52 aac aalib acl acpi alsa amd64 berkdb bzip2 cairo cli cracklib crypt cups dbus dri dssi dts dv dvd exif ffmpeg flac gdbm gif gnome gpm gtk hal iconv ieee1394 inotify iproute2 ipv6 isdnlog jack java jpeg jpeg2k kde kipi ladcca ladspa libsamplerate lirc mad matroska mmx mng modplug mp3 mplayer mudflap multilib mysql ncurses nls nonfsv4 nptl nptlonly ogg opengl openmp pam pcre perl php png pppd pulseaudio python qt3support readline reflection sdl session slang smp speex spell spl sse sse2 ssl svg sysfs syslog tcpd theora threads tiff truetype unicode vorbis wmf x264 xinerama xml xorg xscreensaver xv xvid xvmc zlib" ALSA_CARDS="emu10k1" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev microtouch mutouch" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_AU en_GB" LIRC_DEVICES="it87 serial" USERLAND="GNU" VIDEO_CARDS="nvidia vesa vga nv none"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

Comment 3 Steve Dibb (RETIRED) gentoo-dev 2009-08-24 16:01:10 UTC
(In reply to comment #2)
> Not sure what you mean by 'which card' - it seems to fail for all sound cards
> on the system.

And they are?
Comment 4 Adam Nielsen 2009-08-24 22:07:14 UTC
One's an onboard Realtek ALC889A (Intel HD audio) and the other's a USB MIDI interface with no mixer that I'm aware of.

I don't think this is important though, the problem was caused by an ALSA upgrade and there's a typo in /usr/share/alsa/init/default, but the issue here is that typo causes the script to abort completely instead of skipping just that step and restoring volumes anyway.
Comment 5 Steve Dibb (RETIRED) gentoo-dev 2009-08-25 16:57:21 UTC
(In reply to comment #4)
> One's an onboard Realtek ALC889A (Intel HD audio) and the other's a USB MIDI
> interface with no mixer that I'm aware of.
> 
> I don't think this is important though, the problem was caused by an ALSA
> upgrade and there's a typo in /usr/share/alsa/init/default, but the issue here
> is that typo causes the script to abort completely instead of skipping just
> that step and restoring volumes anyway.
> 

So there's a typo?  I remember there being an issue with this recently, and it getting fixed, have you tried syncing and upgrading ALSA?  Also, if you know what the typo is, can you post it here.
Comment 6 Adam Nielsen 2009-08-25 23:26:30 UTC
Here's a diff of the typo, the wrong type of bracket was used after the word "values".  But although that fixes this error, the bug is still there in that issues like these will make the script abort unnecessarily.  It's just that normally you won't notice because everything is working properly :-)

--- default.orig        2009-08-13 08:58:56.698197000 +1000
+++ default     2009-08-16 12:49:20.585378194 +1000
@@ -49,7 +49,7 @@
 CTL{name}="Headphone Playback Volume",PROGRAM=="__ctl_search",GOTO="headphone0_end"
 # if master volume control is present, turn headphone volume to max
 ENV{has_pmaster_vol}=="true",CTL{values}="0dB",RESULT=="0",GOTO="headphone0_end"
-ENV{has_pmaster_vol}=="true",CTL{values)="100%",GOTO="headphone0_end"
+ENV{has_pmaster_vol}=="true",CTL{values}="100%",GOTO="headphone0_end"
 CTL{values}="$env{pvolume}",RESULT!="0",CTL{values}="$env{ppercent}"
 LABEL="headphone0_end"
 CTL{name}="Headphone Playback Switch",PROGRAM=="__ctl_search", \
Comment 7 Samuli Suominen (RETIRED) gentoo-dev 2009-08-25 23:31:17 UTC
So.. this is fixed long ago then & is a duplicate bug?

alsa-utils-1.0.20-r5 (17 Aug 2009)

  17 Aug 2009; Samuli Suominen <ssuominen@gentoo.org>
  +alsa-utils-1.0.20-r5.ebuild, +files/alsa-utils-1.0.20-init_default.patch:
  Fix brackets inside /usr/share/alsa/init/default wrt #281538.
Comment 8 Adam Nielsen 2009-08-26 02:05:04 UTC
It's fixed long ago and the only relation to this bug is that it's a good example of how to trigger it.

This bug is that the initscript aborts at the drop of a hat, it should be more robust and continue on, setting the volume etc. even after encountering a problem such as the bracket typo.

I suppose it's more of an enhancement than a bug, but IMHO anything to increase the reliability of a system is good.
Comment 9 gtlinuxman 2010-03-30 08:21:19 UTC
same problem:
# alsactl -f "/var/lib/alsa/asound.state" restore
Unknown hardware: "VIA8233" "Realtek ALC650F" "AC97a:414c4723" "0x1458" "0xa002"
Hardware is initialized using a guess method

% lspci -v | grep -i audio 
00:0b.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
        Subsystem: Pinnacle Systems Inc. PCTV pro (TV + FM stereo receiver, audio section)
00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 50)
        Subsystem: Giga-byte Technology GA-7VAX Onboard Audio (Realtek ALC650)
        Kernel driver in use: VIA 82xx Audio

% eix -Ic alsa-*                                              
[I] media-libs/alsa-lib (1.0.22-r1@30.03.2010): Advanced Linux Sound Architecture Library
[I] media-plugins/alsa-plugins (1.0.22@30.03.2010): ALSA extra plugins
[I] media-sound/alsa-headers (1.0.22@30.03.2010): Header files for Advanced Linux Sound Architecture kernel modules
[I] media-sound/alsa-utils (1.0.22-r1(0.9)@30.03.2010): Advanced Linux Sound Architecture Utils (alsactl, alsamixer, etc.)
Found 4 matches.

Trouble can fixed with workaround:
in /etc/init.d/alsasound
-               alsactl -f "${alsastatedir}/asound.state" restore ${cardnum} \
+               alsactl -I -f "${alsastatedir}/asound.state" restore ${cardnum} \
Comment 10 Sergey 'L29Ah' Alirzaev 2010-04-10 05:13:30 UTC
Same here:
Unknown hardware: "HDA-Intel" "Realtek ALC883" "HDA:10ec0883,1458e601,00100002" "0x1458" "0xa002"
Hardware is initialized using a guess method
Comment 11 Etaoin Shrdlu 2010-07-20 17:37:34 UTC
(In reply to comment #9)

> Trouble can fixed with workaround:
> in /etc/init.d/alsasound
> -               alsactl -f "${alsastatedir}/asound.state" restore ${cardnum} \
> +               alsactl -I -f "${alsastatedir}/asound.state" restore ${cardnum}
> \

Since /etc/init.d/alsasound can be overwritten by an update, I'd say that (lacking a proper fix) that workaround could go into /etc/conf.d/alsasound in an ALSACTL_OPTS variable or similar (of course the initscript has to support that, which it probably doesn't now). 

Comment 12 Tony Vroon (RETIRED) gentoo-dev 2012-02-20 09:02:16 UTC
+*alsa-utils-1.0.25-r1 (20 Feb 2012)
+
+  20 Feb 2012; Tony Vroon <chainsaw@gentoo.org> +alsa-utils-1.0.25-r1.ebuild,
+  +files/alsasound.confd-r4, +files/alsasound.initd-r5:
+  Use -I option on alsactl restore to avoid aborting unnecessarily, as per Adam
+  Nielsen in bug #281631. libsamplerate is both a build & run time dependency,
+  as per Albert W. Hopkins in bug #403557. Remove unsupported autoload/unload
+  as it breaks with kmod, as per Ulenrich in bug #404535.

Better late than never Adam. I can only apologise.
Comment 13 Tony Vroon (RETIRED) gentoo-dev 2012-02-20 09:56:37 UTC
*** Bug 298840 has been marked as a duplicate of this bug. ***
Comment 14 Adam Nielsen 2012-02-20 11:17:52 UTC
Haha no worries, thanks for following through and fixing it!