Finding which application is blocking access to an audio device on Linux

Many Linux applications will lock access to a device (e.g. Alsa audio source) when using it; the ones that don’t are the ones using daemons implementing resource sharing (e.g. PulseAudio server), and these are sometimes the ones that don’t work, so you might need this tip with either legacy software or when having trouble with middle layer daemons.

Classical case would be when a Flash player does not render audio, and you don’t undestand why; let’s just find the process using the audio device (thus, blocking access to the Flash player), and kill it.

To find which application is blocking the device, let’s just use the fuser UNIXutility:

user@machine:~$ fuser -v /dev/snd/*

USER PID ACCESS COMMAND

/dev/snd/controlC0: user 17365 F…. gst-launch-0.10

/dev/snd/pcmC0D0c: user 17365 F…m gst-launch-0.10

/dev/snd/pcmC0D0p: user 17365 F…m gst-launch-0.10

Now, let’s just kill the application using kill:

kill 17365

Note: you can also use lsof for this, but it will list ALL open files on the system, and is very resource-consuming.