FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Get help for Volumio here!

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.

FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby dakku » Tue Feb 18 2014 13:25

No Sound / No Playback through MPD?
Sometimes MPD has a little heart attack and cannot playback if you are using multiple players.

Check the MPD log to see if you have this error:
Code: Select all
tail -f  /var/log/mpd/mpd.log
alsa_output: Failed to open "Output" [alsa]: Failed to open ALSA device "hw:0,0": Device or resource busy


If you have the above error, its best to comment out the device parameter in mpd.conf

Edit mpd.conf
Code: Select all
nano /etc/mpd.conf


edit as follows, comment out the device "hw:0,0"
Code: Select all
audio_output {
                 type           "alsa"
                 name           "Output"
#                device         "hw:0,0"
                 dsd_usb        "yes"
                 auto_resample  "no"
}


Restart MPD
Code: Select all
/etc/init.d/mpd restart
Random avatar
dakku
Serious Listener
Serious Listener
 
Posts: 62
Joined: Sat Feb 15 2014 15:11

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.


Re: FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby michelangelo » Tue Feb 18 2014 13:30

Could you explain when exactly does it happen?
User avatar
michelangelo
Founder
 
Posts: 4766
Joined: Sun Dec 15 2013 23:18


Re: FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby dakku » Tue Feb 18 2014 13:44

I tend to notice it if I leave my Volumio running overnight, it dead in the morning and I have to SSH in.

I have not been able to reproduce the error in a consistent manner. My first thought was that it may be related to the updated version of MPD, so I switched back and tried the old one. Same issue.. Phew, so its not the "new thing" that broke it :P

Then, I traced through the logs and found that MPD explicitly tries to bind to the device 0,0. Which, as far as I understand, is not really required if you have configured ALSA to set the USB DAC as the default playback device. Binding to a device at application level, to my knowledge, will not allow anything else to playback to it.

This is not so much an issue if you are only using MPD, but I am also using Shairport and Squeeze, so I kinda need to make the amends I outlined.

Equally, you have to make sure the device bindings are commented out in Shairport and Squeeze :)

ALSA Config in Volumio:
Code: Select all
root@volumio:~# cat /etc/modprobe.d/alsa-base.conf
# autoloader aliases
install sound-slot-0 /sbin/modprobe snd-card-0
install sound-slot-1 /sbin/modprobe snd-card-1
install sound-slot-2 /sbin/modprobe snd-card-2
install sound-slot-3 /sbin/modprobe snd-card-3
install sound-slot-4 /sbin/modprobe snd-card-4
install sound-slot-5 /sbin/modprobe snd-card-5
install sound-slot-6 /sbin/modprobe snd-card-6
install sound-slot-7 /sbin/modprobe snd-card-7
# Cause optional modules to be loaded above generic modules
install snd /sbin/modprobe --ignore-install snd && { /sbin/modprobe --quiet snd-ioctl32 ; /sbin/modprobe --quiet snd-seq ; : ; }
install snd-rawmidi /sbin/modprobe --ignore-install snd-rawmidi && { /sbin/modprobe --quiet snd-seq-midi ; : ; }
install snd-emu10k1 /sbin/modprobe --ignore-install snd-emu10k1 && { /sbin/modprobe --quiet snd-emu10k1-synth ; : ; }
# Keep snd-pcsp from beeing loaded as first soundcard
options snd-pcsp index=-2
# Keep snd-usb-audio from beeing loaded as first soundcard
#options snd-usb-audio index=-2
# Prevent abnormal drivers from grabbing index 0
options bt87x index=-2
options cx88_alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
options snd-usb-audio nrpacks=1


We already have the USB as the default playback device (see below) :) Do we have to explicitly configure the device in each player? By commenting it out I have not noticed any sound quality degradation and all players can now use USB Dac.
Code: Select all
# Keep snd-usb-audio from beeing loaded as first soundcard
#options snd-usb-audio index=-2


Will do some more debugging and let you know if the GUI crashes are fixed :)
Random avatar
dakku
Serious Listener
Serious Listener
 
Posts: 62
Joined: Sat Feb 15 2014 15:11


Re: FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby jcdidier » Sun Apr 13 2014 09:02

hello,
i thought I found the hooly grail by applying this method ...
but it didn't work :
I got a mutual exclusion between mpd and squeezlite : first come first served

apparently, the sound application grabs the output device at the physical layer, ot at the alsa subdevice layer.
This prevents simultaneous activation and playback of all apps (I also use shairport)
I am using a hifiberry dac

my sound driver configuration shows the following :
root@volumio:/var/log# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=sndrpihifiberry
snd_rpi_hifiberry_dac,
Default Audio Device
sysdefault:CARD=sndrpihifiberry
snd_rpi_hifiberry_dac,
Default Audio Device
root@volumio:/var/log# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

I applied the recommendations of this post but no success.
mpd fails if squeezelite started and vice-versa

any idea on how to tweak alsa ?
Random avatar
jcdidier
Fresh off the boat
Fresh off the boat
 
Posts: 9
Joined: Sat Apr 12 2014 08:04


Re: FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby michelangelo » Sun Apr 13 2014 09:29

This is meant to happen! Just one app has control over the alsa device.
The thing I can tell is just stop the squeeze if you're using mpd, and viceversa.
I was looking at a way to make it automatically, using inotify. If mpd plays then stops squeeze...
User avatar
michelangelo
Founder
 
Posts: 4766
Joined: Sun Dec 15 2013 23:18


Re: FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby jcdidier » Sun Apr 13 2014 09:58

I am not sure of what you mean by "meant to happen" ...

Is this a deliberate choice to have only one app work exclusively with the device ?

or something we can't fix ?

In the latter case, at the conceptual level, if we can configure alsa to accept multiple subdevices mixed into the default physical dac within the bcm2835, I am pretty sure we can find a similar configuration for the hifiberry dac.

I simply don't know how.
Does anyone have a clue ?

if the choice has been made with regards to audiophilia principles, I can understand but I am not sure of how much perturbation alsa would add.
At least, I would like to hear the difference.

what do you think ?
Random avatar
jcdidier
Fresh off the boat
Fresh off the boat
 
Posts: 9
Joined: Sat Apr 12 2014 08:04


FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby trigg015 » Sun Jul 13 2014 02:28

Did anyone already found a solution for this?
I'm also having this problem using both Squeeze and Shairport (with Wolfson soundcard on RPI)

Some kind of automatic release of the ALSA-driver when switching apps would be great.
User avatar
trigg015
Fresh off the boat
Fresh off the boat
 
Posts: 6
Joined: Tue Apr 29 2014 12:09


FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby riker1 » Sun Dec 25 2016 12:50

Hi
having the same problem.

Any solution in sight?

Thanks thomas
Random avatar
riker1
Fresh off the boat
Fresh off the boat
 
Posts: 1
Joined: Sun Dec 25 2016 12:49


FIX: MPD Failed to open ALSA device "hw:0,0" Device busy

Postby rockarolla » Wed Mar 07 2018 09:22

Commenting out the line in mpd.conf worked for me. I had tried the deselect i2s DAC/reboot/reselect i2s DAC/reboot method, but the "failed to open ALSA device HW:0,1" error continued. Thanks for this suggestion!

Raspi 3 with Hifiberry DAC+ Pro
Random avatar
rockarolla
Fresh off the boat
Fresh off the boat
 
Posts: 1
Joined: Mon Feb 12 2018 19:30


Return to Help

Who is online

Users browsing this forum: No registered users and 9 guests