hvalev / spotifyd-docker

Spotifyd within a docker container for ARM (armv7/arm64) and x32/x64 architectures in configuration variants alsa/pulseaudio for audio-backend and with/without D-Bus API for controlling spotifyd through generic media players.
11 stars 4 forks source link

Alsa device not working #48

Open pgcudahy opened 1 year ago

pgcudahy commented 1 year ago

Hello, I've got an ubuntu setup with working audio but trying to get a spotifyd.conf that works with this container. Currently I have a USB soundcard that is labeled as "default" by aplay -L and aplay -D default /usr/share/sounds/alsa/Front_Center.wav works. My spotifyd.conf is

username= XXX
password = XXX
backend = "alsa"
device = "default"
control = "default"
mixer = "PCM"
volume_controller = "alsa"
device_name = "YYY"
bitrate = 160
no_audio_cache = true
initial_volume = "90"
volume_normalisation = true
normalisation_pregain = -10
zeroconf_port = 1234
device_type = "computer"

And my docker-compose.yml is

  spotifyd:
    container_name: spotifyd
    image: hvalev/spotifyd-alsa
    network_mode: host
    devices:
      - /dev/snd:/dev/snd
    volumes:
      - /usr/share/alsa:/usr/share/alsa
      - /home/pgcudahy/spotifyd/spotifyd.conf:/etc/spotifyd.conf
      - /etc/asound.conf:/etc/asound.conf
    group_add:
      - audio
    restart: unless-stopped

But it doesn't work and the logs are

Loading config from "/etc/spotifyd.conf"
No proxy specified
Using alsa volume controller.
Connecting to AP "ap.spotify.com:443"
Authenticated as "XXX" !
Country: "US"
Using Alsa sink with format: S16
Couldn't set volume: Error("snd_mixer_attach", Sys(EINVAL))
ALSA lib dlmisc.c:170:(snd_dlsym_verify) unable to verify version for symbol snd_func_private_integer
ALSA lib conf.c:4556:(_snd_config_evaluate) symbol snd_func_private_integer is not defined inside (null)
ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such device or address
ALSA lib conf.c:3694:(snd_config_hook_load) Unable to expand filenames in the pre-load section
ALSA lib conf.c:3572:(snd_config_hooks_call) function snd_config_hook_load_for_all_cards returned error: No such device or address
ALSA lib control.c:1264:(snd_ctl_open_conf) Invalid type for CTL default definition

What am I getting wrong?

hvalev commented 1 year ago

Hi, I think to expose a USB device to a docker container you need to add as volume the actual usb drive handle. One way to easily check whether it would work is with the privileged: true option in your docker compose. privileged gives root access to the container of all of your host's devices. The proper way to do it is to mount the specific usb devices to the container. You can do that by mounting it as a volume similar to something like this: - /dev/ttyUSB0:/dev/ttyUSB0. However, you need to find out the exact handle for your soundcard. You can do that with lsusb.

pgcudahy commented 1 year ago

lsusb gives me

Bus 002 Device 003: ID 0d8c:0014 C-Media Electronics, Inc. Audio Adapter (Unitek Y-247A)

But there are not ttyUSB devices I tried adding

    devices:
      - /dev/snd:/dev/snd
      - /dev/bus/usb:/dev/bus/usb
    privileged: true

to the dockercompose.yml but get the same error

hvalev commented 1 year ago

you can mount the complete /dev to your container, e.g. - /dev:/dev or check which is the /dev handle for your usb soundcard using dmesg

pgcudahy commented 1 year ago

Thanks very much for helping me with this. But even with

    devices:
      - /dev:/dev
    privileged: true

I still get the same error

hvalev commented 1 year ago

I'm not sure then. You could try to start the container with a bash shell and see if you can see the soundcard and try to get it to work. Alternatively, try to get spotifyd without a container, since it should be a bit easier.

pgcudahy commented 1 year ago

Yeah, odd. I tried with the container dubodubonduponey/librespot and got it to work straight off. Thanks again for trying to debug with me.