* ALSA support: save/restore the volume settings, create device nodes

in /dev/snd.

svn path=/nixos/trunk/; revision=8124
This commit is contained in:
Eelco Dolstra 2007-03-01 00:36:00 +00:00
parent a177575779
commit ba56551986
5 changed files with 64 additions and 1 deletions

View file

@ -749,4 +749,13 @@
}
{
name = ["sound" "enable"];
default = true;
description = "
Whether to enable ALSA sound.
";
}
]

View file

@ -197,7 +197,8 @@ rec {
nixosRebuild
nixosCheckout
setuidWrapper
];
]
++ (if config.get ["sound" "enable"] then [pkgs.alsaUtils] else []);
# We don't want to put all of `startPath' and `path' in $PATH, since

View file

@ -131,6 +131,12 @@ import ../upstart-jobs/gather.nix {
inherit (pkgs) glibc pwdutils;
})
# ALSA sound support.
++ optional ["sound" "enable"]
(import ../upstart-jobs/alsa.nix {
inherit (pkgs) kernel module_init_tools alsaUtils;
})
# Handles the reboot/halt events.
++ (map
(event: makeJob (import ../upstart-jobs/halt.nix {

38
upstart-jobs/alsa.nix Normal file
View file

@ -0,0 +1,38 @@
{kernel, module_init_tools, alsaUtils}:
let
soundState = "/var/state/asound.state";
in
{
name = "alsa";
job = "
start on hardware-scan
stop on shutdown
script
# Load some additional modules.
export MODULE_DIR=${kernel}/lib/modules/
for mod in snd_pcm_oss; do
${module_init_tools}/sbin/modprobe $mod || true
done
# Restore the sound state.
${alsaUtils}/sbin/alsactl -f ${soundState} restore
end script
stop script
# Save the sound state.
${alsaUtils}/sbin/alsactl -f ${soundState} store
end script
";
}

View file

@ -28,3 +28,12 @@ KERNEL=="uinput", NAME="input/%k", MODE="0600"
# Create a symlink for the CD-ROM device.
KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1", SYSFS{device/media}=="cdrom", SYMLINK+="cdrom cdrom-%k"
# ALSA sound devices.
KERNEL=="controlC[0-9]*", NAME="snd/%k"
KERNEL=="hwC[D0-9]*", NAME="snd/%k"
KERNEL=="pcmC[D0-9cp]*", NAME="snd/%k"
KERNEL=="midiC[D0-9]*", NAME="snd/%k"
KERNEL=="timer", NAME="snd/%k"
KERNEL=="seq", NAME="snd/%k"