Sometimes no sound in browser / video player on Arch Linux

Sometimes after booting the machine up I would just get no sound in my browser / video player and sometimes it would be there working just perfectly. The only way to get the sound if it wasn’t there was to reboot the computer. A strange issue I ignored at first thinking it would go away after a few full system updates, but after a while the problem was still there and I got annoyed by it and thankfully found a cure.

The problem was the usb webcam. Turns out ALSA isn’t very smart when it comes to device assignment so sometimes it would make the snd_usb_audio (webcam) the first sound device instead of the soundcard. A workaround is just putting your soundcard module name before the snd_usb_audio in your /etc/rc.conf. In my case it was like this:

MODULES=( ... snd_hda_intel snd_usb_audio ... )

edit: I think there is one more situation when sound does not work – it’s when your skype autostarts on startup. It starts webcam of course and sometimes skype starts before you can hear the welcoming sound of entering into your WM.