Solved - No audio as service but sudo -u mopidy works (DietPi)


I’m running Mopidy as a service on Diet Pi with pHAT DAC.

I can access the web interface but I cannot get sound. The error I’m seeing in /var/log/mopidy/mopidy.log is

WARNING [1211:MainThread] GStreamer warning: gst-resource-error-quark: Could not open audio device for playback. (6)

The service is running as user mopidy, I’ve checked this like so

$ ps -aux | grep mopidy
mopidy    1211 19.5 10.9 282556 53904 ?        Ssl  17:19   0:22 /usr/bin/python /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

The mopidy user belongs to the following groups

$ groups mopidy
mopidy : audio spi i2c gpio dietpi

The audio section of /etc/mopidy/mopidy.conf is as follows

output = autoaudiosink

I have tested that autoaudiosink works using the following command (as root), I heard the beep.

gst-launch-1.0 audiotestsrc ! audioresample ! autoaudiosink

Now the weird part… if I start mopidy with the following command instead of as the service, it works fine, I can hear sound. Also works fine without the debugging.

sudo -u mopidy GST_DEBUG=3 mopidy -v

I’m running out of ideas now, except maybe sudo -u mopidy is actually running with root credentials and that’s why it’s OK?

I wondered if the audio device is not in the audio group, is that even possible?

$ find /dev -group audio

CD Extension Development

Not sure if it’s relevant in your case but from the docs
" If you used the Raspbian Desktop image you may also need to add the mopidy user to the video group. Run sudo adduser mopidy video to do this."


Adding video alone didn’t help. I have managed to get it working by adding the following groups.

dietpi adm tty dialout cdrom sudo audio www-data video plugdev games users input netdev gpio i2c spi

So to re-cap, in case anyone else find themselves scratching their head running Mopidy on DietPi with pHATDAC the following groups were not enough

audio spi i2c gpio dietpi

I added all the groups that the dietpi user has

$ usermod -a -G dietpi,tty,dialout,cdrom,sudo,audio,www-data,video,plugdev,games,users,input,netdev,spi,i2c,gpio mopidy