Reputation: 1469
I'm trying to configure the default audio device on a NixOS host.
My alsa devices are thus:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 0: ALC1220 Analog [ALC1220 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 1: ALC1220 Digital [ALC1220 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
I don't have HDMI or digitaul audio devices; I just want to use the regular ALC1220 Analog device.
I currently have AUDIODEV=hw:1,0
set in my environment (for sox), and alsa-audio-device=sysdefault:CARD=Generic
in my vlcrc. That works, but it is obviously user- and app- specific, and is a pain for declaritiveness (declarity?).
It seems that it should be something I can set at the host level, e.g., by setting
sound.extraConfig =
''
pcm.!default {
type hw
card Generic
}
'';
in my configuration.nix, or possibly configuring pulseaudio.
I have sought help in the NixOS Wiki (ALSA, Pulse), on other sites such as ArchLinux, Pulse documentation, and other sites like StackOverflow (e.g., stackexchange), but I can find nothing that actually works.
I have tried the above, and variants thereof; and also tried with & without Pulse; but I have found nothing that works.
Simply being able to sound audio to all the devices on that card would be jolly good, too.
As always, any pointers gratefully recieved.
Update: here is my /etc/asound.conf
pcm_type.pulse {
libs.native = /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_pcm_pulse.so ;
}
pcm.!default {
type pulse
hint.description "Default Audio Device (via PulseAudio)"
}
ctl_type.pulse {
libs.native = /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so ;
}
ctl.!default {
type pulse
}
(and that module is real):
$ ls -l /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so
-r-xr-xr-x 1 root root 33512 Jan 1 1970 /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so
Upvotes: 1
Views: 2713
Reputation: 607
This problem is most likely due to pulseaudio comandeering the default device, despite listing it in ~/.asoundrc.
The best solution to override pulse's comandeering of the default device with an alsa hook. To do this, edit your ~/.asoundrc with the following contents at the top :
@hooks [
{
func load
files [
"~/.asoundrc"
]
errors false
}
]
You can then add you default device as required, probably something like the following in your case :
pcm.!default {
type hw
card "Generic"
}
ctl.!default {
type hw
card "Generic"
}
Upvotes: 0