linuxserver / docker-daapd

GNU General Public License v3.0
103 stars 37 forks source link

Local audio output permissions missing #40

Closed jptrsn closed 2 years ago

jptrsn commented 3 years ago

Expected Behavior

Selecting a local audio output should allow user to hear audio from local audio hardware.

Current Behavior

Following messages appear in logs after boot, no local audio will work.

[ WARN] laudio: Failed to probe ALSA card=0 - No such file or directory [ INFO] laudio: Adding ALSA device 'hw:0,0' with name 'Server'

Details of issue are also explored in this issue

Steps to Reproduce

  1. Configure container with local output enabled. Add /dev/snd to devices accessible to container.
  2. Toggle local audio off then on and observe error state.
  3. Enter container with a shell and execute chmod 666 /dev/snd/*
  4. Toggle local audio off then on and observe that it works as expected.

Environment

OS: Ubuntu Server 20.04.1 CPU architecture: x86_64 How docker service was installed: Docker installed from official repo, running container using docker-compose.

Command used to create docker container (run/create/compose/screenshot)

  daapd:
    image: linuxserver/daapd:latest
    container_name: daapd
    network_mode: host
    volumes:
      - ./daapd/config:/config
      - ./Storage/Audio:/music
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=${TZ}
    expose:
      - 3689
    devices:
      - "/dev/snd:/dev/snd"
    restart: unless-stopped

Docker logs

-------------------------------------
          _         ()
         | |  ___   _    __
         | | / __| | |  /  \
         | | \__ \ | | | () |
         |_| |___/ |_|  \__/

Brought to you by linuxserver.io
-------------------------------------

To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    1000
User gid:    1000
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-dbus: executing...
[cont-init.d] 30-dbus: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] 99-custom-files: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
Found user 'avahi' (UID 86) and group 'avahi' (GID 86).
Successfully dropped root privileges.
avahi-daemon 0.8 starting up.
WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
dbus_bus_get_private(): Failed to connect to socket /var/run/dbus/system_bus_socket: Connection refused
WARNING: Failed to contact D-Bus daemon.
avahi-daemon 0.8 exiting.
[services.d] done.
Failed to set ownership on logfile: Operation not permitted
[  LOG]     main: Forked Media Server Version 27.2 taking off
[  LOG]     main: Built with:
[  LOG]     main: - ffmpeg
[  LOG]     main: - iTunes XML
[  LOG]     main: - Spotify
[  LOG]     main: - LastFM
[  LOG]     main: - Chromecast
[  LOG]     main: - MPD
[  LOG]     main: - Device verification
[  LOG]     main: - Websockets
[  LOG]     main: - ALSA
[  LOG]     main: - Webinterface
[ INFO]     main: Initialized with ffmpeg 4.3.1
[  LOG]     main: mDNS init
[  LOG]     mdns: Avahi state change: Client connecting
[ INFO]     main: Initializing database
[  LOG]       db: Configured to use database file '/config/dbase_and_logs/songs3.db'
Found user 'avahi' (UID 86) and group 'avahi' (GID 86).
Successfully dropped root privileges.
avahi-daemon 0.8 starting up.
WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
Loading service file /etc/avahi/services/sftp-ssh.service.
Loading service file /etc/avahi/services/ssh.service.
*** WARNING: Detected another IPv4 mDNS stack running on this host. This makes mDNS unreliable and is thus not recommended. ***
*** WARNING: Detected another IPv6 mDNS stack running on this host. This makes mDNS unreliable and is thus not recommended. ***
Joining mDNS multicast group on interface veth0bdd677.IPv6 with address fe80::c032:f0ff:fe93:b6a1.
New relevant interface veth0bdd677.IPv6 for mDNS.
Joining mDNS multicast group on interface veth4c7dd26.IPv6 with address fe80::74f3:f1ff:fe0a:f8e1.
New relevant interface veth4c7dd26.IPv6 for mDNS.
Joining mDNS multicast group on interface vethf0418cc.IPv6 with address fe80::8c88:c6ff:fe48:d580.
New relevant interface vethf0418cc.IPv6 for mDNS.
Joining mDNS multicast group on interface veth324e800.IPv6 with address fe80::40e9:80ff:fe5f:cd5.
New relevant interface veth324e800.IPv6 for mDNS.
Joining mDNS multicast group on interface veth3e96f20.IPv6 with address fe80::304c:d7ff:fe32:f889.
New relevant interface veth3e96f20.IPv6 for mDNS.
Joining mDNS multicast group on interface veth68b2cd7.IPv6 with address fe80::18c4:66ff:fe69:678e.
New relevant interface veth68b2cd7.IPv6 for mDNS.
Joining mDNS multicast group on interface veth27ba36e.IPv6 with address fe80::4c8d:36ff:fee2:d242.
New relevant interface veth27ba36e.IPv6 for mDNS.
Joining mDNS multicast group on interface vetha2f9fcf.IPv6 with address fe80::c0b3:d6ff:fe9e:adcc.
New relevant interface vetha2f9fcf.IPv6 for mDNS.
Joining mDNS multicast group on interface veth8e98867.IPv6 with address fe80::b039:23ff:feb3:ded9.
New relevant interface veth8e98867.IPv6 for mDNS.
Joining mDNS multicast group on interface vethc44df48.IPv6 with address fe80::60a4:a1ff:fed6:6b6c.
New relevant interface vethc44df48.IPv6 for mDNS.
Joining mDNS multicast group on interface veth4e5ccee.IPv6 with address fe80::3085:80ff:fe01:97a9.
New relevant interface veth4e5ccee.IPv6 for mDNS.
Joining mDNS multicast group on interface veth71e4f0a.IPv6 with address fe80::68f7:4cff:fe68:558a.
New relevant interface veth71e4f0a.IPv6 for mDNS.
Joining mDNS multicast group on interface veth4fffecd.IPv6 with address fe80::584e:c9ff:fe1e:9565.
New relevant interface veth4fffecd.IPv6 for mDNS.
Joining mDNS multicast group on interface vethbd5e255.IPv6 with address fe80::3cbd:8aff:fed4:50d3.
New relevant interface vethbd5e255.IPv6 for mDNS.
Joining mDNS multicast group on interface vethc4fdeb1.IPv6 with address fe80::5049:44ff:fe8d:e7a3.
New relevant interface vethc4fdeb1.IPv6 for mDNS.
Joining mDNS multicast group on interface vethb59824c.IPv6 with address fe80::8413:dbff:fe9c:f648.
New relevant interface vethb59824c.IPv6 for mDNS.
Joining mDNS multicast group on interface veth80b83b2.IPv6 with address fe80::4c20:7eff:fef5:9abe.
New relevant interface veth80b83b2.IPv6 for mDNS.
Joining mDNS multicast group on interface br-b54abc0bd105.IPv6 with address fe80::42:bfff:fe31:8a37.
New relevant interface br-b54abc0bd105.IPv6 for mDNS.
Joining mDNS multicast group on interface br-b54abc0bd105.IPv4 with address 172.18.0.1.
New relevant interface br-b54abc0bd105.IPv4 for mDNS.
Joining mDNS multicast group on interface br-874565727ad7.IPv6 with address fe80::42:e9ff:fee1:d00f.
New relevant interface br-874565727ad7.IPv6 for mDNS.
Joining mDNS multicast group on interface br-874565727ad7.IPv4 with address 172.19.0.1.
New relevant interface br-874565727ad7.IPv4 for mDNS.
Joining mDNS multicast group on interface hassio.IPv6 with address fe80::42:52ff:fe27:1b6a.
New relevant interface hassio.IPv6 for mDNS.
Joining mDNS multicast group on interface hassio.IPv4 with address 172.30.32.1.
New relevant interface hassio.IPv4 for mDNS.
Joining mDNS multicast group on interface docker0.IPv6 with address fe80::42:5dff:feed:d4cd.
New relevant interface docker0.IPv6 for mDNS.
Joining mDNS multicast group on interface docker0.IPv4 with address 172.17.0.1.
New relevant interface docker0.IPv4 for mDNS.
Joining mDNS multicast group on interface enp7s0.IPv6 with address fe80::922b:34ff:fe2d:9cea.
New relevant interface enp7s0.IPv6 for mDNS.
Joining mDNS multicast group on interface enp7s0.IPv4 with address 192.168.1.13.
New relevant interface enp7s0.IPv4 for mDNS.
Joining mDNS multicast group on interface lo.IPv6 with address ::1.
New relevant interface lo.IPv6 for mDNS.
Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1.
New relevant interface lo.IPv4 for mDNS.
Network interface enumeration completed.
Registering new address record for fe80::c032:f0ff:fe93:b6a1 on veth0bdd677.*.
Registering new address record for fe80::74f3:f1ff:fe0a:f8e1 on veth4c7dd26.*.
Registering new address record for fe80::8c88:c6ff:fe48:d580 on vethf0418cc.*.
Registering new address record for fe80::40e9:80ff:fe5f:cd5 on veth324e800.*.
Registering new address record for fe80::304c:d7ff:fe32:f889 on veth3e96f20.*.
Registering new address record for fe80::18c4:66ff:fe69:678e on veth68b2cd7.*.
Registering new address record for fe80::4c8d:36ff:fee2:d242 on veth27ba36e.*.
Registering new address record for fe80::c0b3:d6ff:fe9e:adcc on vetha2f9fcf.*.
Registering new address record for fe80::b039:23ff:feb3:ded9 on veth8e98867.*.
Registering new address record for fe80::60a4:a1ff:fed6:6b6c on vethc44df48.*.
Registering new address record for fe80::3085:80ff:fe01:97a9 on veth4e5ccee.*.
Registering new address record for fe80::68f7:4cff:fe68:558a on veth71e4f0a.*.
Registering new address record for fe80::584e:c9ff:fe1e:9565 on veth4fffecd.*.
Registering new address record for fe80::3cbd:8aff:fed4:50d3 on vethbd5e255.*.
Registering new address record for fe80::5049:44ff:fe8d:e7a3 on vethc4fdeb1.*.
Registering new address record for fe80::8413:dbff:fe9c:f648 on vethb59824c.*.
Registering new address record for fe80::4c20:7eff:fef5:9abe on veth80b83b2.*.
Registering new address record for fe80::42:bfff:fe31:8a37 on br-b54abc0bd105.*.
Registering new address record for 172.18.0.1 on br-b54abc0bd105.IPv4.
Registering new address record for fe80::42:e9ff:fee1:d00f on br-874565727ad7.*.
Registering new address record for 172.19.0.1 on br-874565727ad7.IPv4.
Registering new address record for fe80::42:52ff:fe27:1b6a on hassio.*.
Registering new address record for 172.30.32.1 on hassio.IPv4.
Registering new address record for fe80::42:5dff:feed:d4cd on docker0.*.
Registering new address record for 172.17.0.1 on docker0.IPv4.
Registering new address record for fe80::922b:34ff:fe2d:9cea on enp7s0.*.
Registering new address record for 192.168.1.13 on enp7s0.IPv4.
Registering new address record for ::1 on lo.*.
Registering new address record for 127.0.0.1 on lo.IPv4.
Server startup complete. Host name is hp-server.local. Local service cookie is 3434428279.
[  LOG]       db: Now vacuuming database, this may take some time...
[  LOG]       db: Database OK with 2857 active files and 17 active playlists
[ INFO]    cache: cache thread init
[ INFO]  spotify: Spotify session init
[  LOG]     mdns: Failed to create service browser: Bad state
[  LOG]     raop: Could not add mDNS browser for AirPlay devices
[ WARN]   laudio: Failed to probe ALSA card=0 - No such file or directory
[ INFO]   laudio: Adding ALSA device 'default' with name 'Server'
[ WARN]   ffmpeg: No bit rate set. Defaulting to 96000 bps.
[  LOG]     mdns: Failed to create service browser: Bad state
[  LOG]     cast: Could not add mDNS browser for Chromecast devices
Service "hp-server" (/etc/avahi/services/ssh.service) successfully established.
Service "hp-server" (/etc/avahi/services/sftp-ssh.service) successfully established.
github-actions[bot] commented 3 years ago

Thanks for opening your first issue here! Be sure to follow the issue template!

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

VergilGao commented 2 years ago

Have you solved this problem? I ran into the same problem.

it works well with following docker-compose.yml file:

version: "2.1"
services:
  daapd:
    image: linuxserver/daapd
    container_name: owntone
    environment:
      - PUID=1000
      - PGID=29
      - TZ=Asia/Shanghai
    volumes:
      - /disk/data1/codebase/docker/owntone/config:/config
      - /disk/data1/media/music:/music
    devices:
      - /dev/snd
    network_mode: host
    restart: unless-stopped
jptrsn commented 2 years ago

I've switched to using a fifo output instead. As mentioned in the original post, if you use docker to launch a bash terminal inside the container and modify permissions on the sound devices, it will allow you to use local output.

In your case, once the container is running, you would want to run the following comands: docker exec -it owntone /bin/bash (bash terminal inside your owntone container) chmod +666 /dev/snd/* (add permissions to all sound devices) exit (quit the bash terminal)

It would be great if the authors of the docker container could add the command to the docker file and then build a new version of the container, but so far I've not heard anything from anyone.

VergilGao commented 2 years ago

i mean my case sovled this problem. because the gourp of id:29 has the access permission of audio devices.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Joshfindit commented 2 years ago

I have this issue as well, but I use - PGID=50.

I suspect that very few people will have this issue because very few people change the group ID, however I still feel that this is an important bug to address.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.