[Solved] USB DAC getting wrong group and permissions

Hi,

I’ve installed Volumio on my Raspberry Pi and connected my DAC to it.
I can play music on the Volumio via AirPlay, but it has frequent noises.
I am trying to get it to play some music with mpd, having no success so far.

The DAC is NAD D 3020, and it is detected automatically by ALSA and registered as card #0.

I couldn’t get the web UI to play so I am running mpc directly from the terminal.

volumio@volumio:/tmp$ mpc play Katy Perry - Dark Horse (feat. Juicy J) [paused] #3/4 0:00/3:36 (0%) volume: n/a repeat: off random: off single: off consume: off ERROR: problems opening audio device

/var/log/mpd/mpd.log:

Mar 02 10:01 : client: [120] opened from 127.0.0.1:33339 Mar 02 10:01 : client: [120] process command "play" ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card Mar 02 10:01 : output: Failed to open "Output" [alsa]: Failed to open ALSA device "hw:0,0": No such file or directory Mar 02 10:01 : client: [120] command returned 0 Mar 02 10:01 : client: [120] process command list Mar 02 10:01 : client: command_process_list: process command "status" Mar 02 10:01 : client: command_process_list: command returned 0 Mar 02 10:01 : client: command_process_list: process command "currentsong" Mar 02 10:01 : client: command_process_list: command returned 0 Mar 02 10:01 : client: [120] process command list returned 0 Mar 02 10:01 : client: [120] closed

I am able to play music using aplay when running using “sudo aplay” as the root user.
I am unable, however, to play using aplay from the “pi” user, even though it is in the “audio” group.

Running “aplay -l” shows that while root can see the DAC card, the pi user cannot.

volumio@volumio:/tmp$ sudo -u pi aplay -l **** List of PLAYBACK Hardware Devices **** card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7

and:

volumio@volumio:/tmp$ sudo aplay -l **** List of PLAYBACK Hardware Devices **** card 0: Audio [NAD USB Audio], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7

Any idea why the DAC card is only available for the root user?

Thanks!

I finally solved it.

If someone else runs into this problem, my solution was adding udev rules to set the correct group and permissions to the USB device.

I created a file named /etc/udev/rules.d/50-usb_sound.rules that contains the following code:

# ALSA devices SUBSYSTEM=="snd", GROUP="audio" KERNEL=="controlC[0-9]*", NAME="snd/%k", MODE="1660" KERNEL=="pcm[CD0-9]*p", NAME="snd/%k", MODE="1660"

And restarted udev:

$ sudo /etc/init.d/udev restart

The device now gets the correct group and permissions.

I have the same problem with my usb dac but I’m afraid your solution does not solve it completely : the new rule you added seems to be only executed after you restart udev. After that if you reboot volumio and unplug / plug the dac the rule is somhow not run and the permission stay on root:root :frowning:

There also another rule, in /lib/udev/rules.d/91-permissions.rules, that also set the correct permission.

When I test the rules with udevadm, I clearly see both should be applied :

udevadm test $(udevadm info -q path -n /dev/snd/controlC0) 2>&1

I definitely do not understand why these rules are not applied after a reboot, I’m looking at udev documentation right now but I haven’t found any lead yet …

some progress here (but no solution yet ) : after boot, udev is simply not running :frowning:

pi@volumio:~$ ps aux | grep udevd
pi        2810  0.0  0.1   3628   736 pts/0    S+   23:22   0:00 grep udevd

The trick in previous post works because when actually start udev. No extra rule is necessary, I just now need to understand why udevd is not running after a clean boot. It is started in rcS.d but seems to quit shortly afterwards.

Hi,

some services, among which udev, are killed at startup by script:
/var/www/command/orion_optimize.sh

Just remove the line where udev is killed and it should work

Naqua

Excellent guys, I’m integrating this as a fix. Please could you report for which USB DAC this happens?

@naqua : many many thanks for that, I’ve already spend two full evenings trying to understand why udev was not running after a clean boot . I never thought it was actually killed explicitely somewhere !!

It would be nice to remove the kill in the standard volumio distribution ihmo, do you know why it was done ? is there any good reason not to keep it running ?

@michelangelo : I’m using a Cambridge dacmagc (first generation) but I’m pretty sure it happens with any other usb dac.
Actually as udev is not running after boot, I would even expect other weird behavior with any device that you can hot plug and are usually managed by udev like for example usb drive (persistent naming is udev based).

@naqua great find!

@michaelangelo I’m using the NAD D 3020.

Thanks again everyone!