Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alsa audio output not working #9

Open
curiousercreative opened this issue Apr 3, 2023 · 1 comment
Open

Alsa audio output not working #9

curiousercreative opened this issue Apr 3, 2023 · 1 comment

Comments

@curiousercreative
Copy link

curiousercreative commented Apr 3, 2023

I've got the following Audio Output configuration in the mpd.conf

audio_output {
      type                    "alsa"
      name                  "Digital Stereo"
      device                 "cards.pcm.iec958" # have also tried "hw:3,0"
}

And that yields the below error on run (docker compose down && docker compose up)

mpd  | ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
mpd  | ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
mpd  | ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
mpd  | ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
mpd  | ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
mpd  | ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
mpd  | ALSA lib conf.c:5703:(snd_config_expand) Evaluate error: No such file or directory
mpd  | ALSA lib control.c:1528:(snd_ctl_open_noupdate) Invalid CTL default
mpd  | mixer: Failed to read mixer for 'Digital Stereo': failed to attach to default: No such file or directory

My docker-compose.yml as follows

services:
  mpd:
    image: tobi312/rpi-mpd:alpine
    #image: tobi312/rpi-mpd:debian
    container_name: mpd
    restart: unless-stopped
    ports:
      - 6600:6600  # MPD Client
      - 8000:8000  # Stream
    volumes:
      - "/some/path:/var/lib/mpd/music:ro"
      - ./playlists:/var/lib/mpd/playlists:rw
      - ./data:/var/lib/mpd/data:rw
      - ./mpd.conf:/etc/mpd.conf:rw
    devices:
      - /dev/snd
    cap_add:
      - SYS_NICE

Host is rock64 SBC running Ubuntu 18.04 server

$ uname -a
Linux blahblah.com 4.4.190-1233-rockchip-ayufan-gd3f1be0ed310 #1 SMP Wed Aug 28 08:59:34 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

On the host, the following speaker-test runs output sound properly:

speaker-test
speaker-test -c2
speaker-test -c2 --device cards.pcm.iec958
speaker-test -c2 --device hw:3,0
@42asdf
Copy link

42asdf commented Aug 4, 2024

This seems to be a permission issue.
You can open a shell in the container with docker exec -it mpd sh and try the following:

apk add alsa-utils sudo
speaker-test    # working for me
sudo -u mpd speaker-test    # not working
ls -l /dev/snd/    # the content should be owned by group audio
chown -R root:audio /dev/snd/*
sudo -u mpd speaker-test    # working now

However, mpd can still not access the sound card, so there is probably another problem with the permissions. It might be required, to use the same gid for the audio group in the container as on the host.
As a workaround, you can change the user in mpd.conf from "mpd" to "root". However, this is probably not a good idea.

This image seems to have more advanced alsa support: https://github.com/giof71/mpd-alsa-docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants