ALSA "device or resource busy" error

  • Date:

Over the weekend, I spent hours trying to figure out why an FFmpeg command for recording audio from my computer was failing with "device or resource busy" when it previously worked without issue. Long story short, the culprit was VirtualBox. I am writing this post in the hopes that it will be indexed by Google and hopefully spare someone from having the same frustrating experience that I did.

I searched and searched for various solutions to the error. The solutions mentioned making sure certain toggles were enabled in AlsaMixer and checking the output of lsof(8) to see what programs were using ALSA. I closed my media player, all browser windows, killed anything I saw accessing ALSA libraries (".so" files) in the output of lsof(8), and closed any applications I saw listed in the output of lsof /dev/snd/*. I still got the same "device or resource busy" error when trying to run FFmpeg after that. Eventually it dawned on me that any modules or processes running inside the Linux kernel accessing the files in question would not be shown by lsof(8). The only kernel module I could think of that might be accessing ALSA was the VirtualBox DKMS module; whenever my computer boots up, a virtual machine that acts as a proxy to my printer is also started. I shut down the virtual machine, disabled audio then relaunched the virtual machine. After that, I was finally able to use FFmpeg to record audio from my computer.