No Audio from Mopidy (was previously working)

Only change was to update the packages on the Raspberry Pi 4.

Did a bit of searching around before opening this topic.

If I run:
gst-launch-1.0 audiotestsrc ! audioresample ! alsasink

I get a tone.

If I try to use the web client (Iris), it shows that it’s playing, but no sound comes out.

Connected via the headphone jack.

Config looks like:

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
max_tracklist_length = 10000
restore_state = false

[logging]
verbosity = 0
format = %(levelname)-8s [%(threadName)s] %(name)s %(message)s
color = false
config_file =

[audio]
mixer = software
mixer_volume = 100
output = alsasink
buffer_time =

[proxy]
scheme =
hostname =
port =
username =
password =

[local]
enabled = true
media_dir = /home/pi/Music
scan_timeout = 60000
scan_flush_threshold = 100
scan_follow_symlinks = false
included_file_extensions =
excluded_file_extensions =
.cue
.directory
.html
.jpeg
.jpg
.log
.nfo
.pdf
.png
.txt
.zip
directories =
Albums local:directory?type=album
Artists local:directory?type=artist
Composers local:directory?type=artist&role=composer
Genres local:directory?type=genre
Performers local:directory?type=artist&role=performer
Release Years local:directory?type=date&format=%25Y
Tracks local:directory?type=track
Last Week’s Updates local:directory?max-age=604800
Last Month’s Updates local:directory?max-age=2592000
timeout = 10
use_artist_sortname = false
album_art_files =
*.jpg
*.jpeg
*.png
[iris]
enabled = true
country = NZ
locale = en_NZ

data_dir = $XDG_DATA_DIR/iris

[file]
enabled = true
media_dirs =
$XDG_MUSIC_DIR|Music
~/|Home
excluded_file_extensions =
.directory
.html
.jpeg
.jpg
.log
.nfo
.pdf
.png
.txt
show_dotfiles = false
follow_symlinks = false
metadata_timeout = 1000

[http]
enabled = true
hostname = 0.0.0.0
port = 6680
zeroconf = Mopidy HTTP server on $hostname
allowed_origins =
csrf_protection = true
default_app = mopidy
[m3u]
enabled = true
base_dir =
default_encoding = latin-1
default_extension = .m3u8
playlists_dir =

[softwaremixer]
enabled = true

[stream]
enabled = true
protocols =
http
https
mms
rtmp
rtmps
rtsp
metadata_blacklist =
timeout = 5000

I added volume = 100 as part of debugging, but that didn’t help.

When I look in alsamixer, it’s set to full volume for the headphone jack.

When I look in the GUI via VNC, it’s set to headphone at full volume.

I know raspberry pi changed how the audio devices are organised in the latest version of raspbian so my guess is that it’s related to this. The audio jack and the hdmi audio used to share the same card but now they have been separated. Is that the case when you run ‘aplay -l’? I would guess they’ve configured the audio jack output as default for their pi user but not for other users on the system (e.g. not for the mopidy user running the Mopidy service). Can you use raspi-config to make it the system-wide default? Or have a look for a file at ~/.asoundrc that may be making it the default for the pi user only. You can then create a file in /etc/asound.conf with the same contents to make the configuration apply to all users.

Alternatively, you can try and specify the exact audio device to use in your Mopidy config:

[audio] 
output = alsasink device=hw:1,0

Where hw:1,0 would be Card 1, device 0 (taken from the output of aplay -l on your system).

1 Like

You are correct that they are listed as two cards now.

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3

I had already used raspi-config. At least I believe I have. I then created an asound.conf with the same info from .asoundrc. At that point, simply restarting mopidy fixed things. No need to restart the entire Raspbery Pi.

Thank you SO MUCH for your help, this has been driving me nuts for 3 days now. It’s how my kid listens to music at night, so it’s a great weight off my shoulder to have it fixed.

Great news. I’ll update our install documentation with this new extra setup.

1 Like

Hi,

I just faced the same issue, when running mopidy manually in terminal everything was working fine, but when running it as a service there was no sound. But I couldn’t find the mentioned ~/.asoundrc file.
For me the solution was to change the following lines in /usr/share/alsa/alsa.conf

defaults.ctl.card 0
defaults.pcm.card 0
defaults.pcm.device 0

to the values I got from running

aplay -l

Rebooted the system and finally I have sound using the mopidy services.

The system-wide version of ~/.asoundrc is usually /etc/asound.conf. Out of interest, what system are you on here? Raspbian or something else?

I can’t neither find a /etc/asound.conf file. But I tried to configure the audio output via raspi-config before, as said it also worked when mopidy was running in the terminal, but not when it was running as a service. Even though I copied the configuration file.

Yes, I’m running the most recent raspbian (v10 “buster”)

If you can’t find it, you just create the file. Either way, glad it’s now working. I did add a step to the raspbian instructions but I guess it’s outdated already. Their (RPi Foundation’s) frequent changes (hacks) in this area are really frustrating to keep up with.