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

[Problem]: ALSA error " (snd1_pcm_direct_initialize_slave) unable to start PCM stream " when streaming to more than 2 slaves #1922

Open
2 tasks done
glasscake opened this issue Oct 13, 2024 · 2 comments

Comments

@glasscake
Copy link

glasscake commented Oct 13, 2024

What happened?

I have 3 usb DACs set up with their own output in my alsa config:

pcm_slave.outs1 {
        pcm "hw:usbAudio1"
        rate 44100
        channels 2
}
pcm_slave.outs2 {
        pcm "hw:usbAudio2"
        rate 44100
        channels 2
}
pcm_slave.outs3 {
        pcm "hw:usbAudio3"
        rate 44100
        channels 2
}
pcm.out1 {
        type plug
        slave.pcm {
                type dshare
                ipc_perm 0666
                ipc_key 4242
                slave outs1
                bindings.0 0
                bindings.1 1
        }
}
pcm.out2 {
        type plug
        slave.pcm {
                type dshare
                ipc_perm 0666
                ipc_key 4243
                slave outs2
                bindings.0 0
                bindings.1 1
        }
}
pcm.out3 {
        type plug
        slave.pcm {
                type dshare
                ipc_perm 0666
                ipc_key 4244
                slave outs3
                bindings.0 0
                bindings.1 1
        }
}

I can play to any of the 3 individually fine. I can play to any combination of 2 of them fine, but when trying to play to all 3 at the same time the last selected device outputs the (snd1_pcm_direct_initialize_slave) unable to start PCM stream error.

I am running them in docker and deploying with a portainer stack:

services:
  shairport1:
    image: mikebrady/shairport-sync:4.3.4
    restart: unless-stopped
    devices:
      - "/dev/snd" # ALSA device, omit if using PulseAudio
    volumes:
      - /etc/shairport-sync/shairport1.conf:/etc/shairport-sync.conf # Customised Shairport Sync configuration file.
      - /etc/asound.conf:/etc/asound.conf
    logging:
      options:
        max-size: "200k"
        max-file: "10"
    ipc: host
    mac_address: XX:XX:XX:XX:XX:XX
    networks:
      servers-macvlan:
        ipv4_address: xxx.xxx.xxx.xxx

  shairport2:
    image: mikebrady/shairport-sync:4.3.4

    restart: unless-stopped
    devices:
      - "/dev/snd" # ALSA device, omit if using PulseAudio
    volumes:
      - /etc/shairport-sync/shairport2.conf:/etc/shairport-sync.conf # Customised Shairport Sync configuration file.
      - /etc/asound.conf:/etc/asound.conf
    logging:
      options:
        max-size: "200k"
        max-file: "10"
    mac_address: XX:XX:XX:XX:XX:XX
    networks:
      servers-macvlan:
        ipv4_address: xxx.xxx.xxx.xxx

  shairport3:
    image: mikebrady/shairport-sync:4.3.4

    restart: unless-stopped
    devices:
      - "/dev/snd" # ALSA device, omit if using PulseAudio
    volumes:
      - /etc/shairport-sync/shairport3.conf:/etc/shairport-sync.conf # Customised Shairport Sync configuration file.
      - /etc/asound.conf:/etc/asound.conf
    logging:
      options:
        max-size: "200k"
        max-file: "10"
    mac_address: XX:XX:XX:XX:XX:XX
    networks:
      servers-macvlan:
        ipv4_address: xxx.xxx.xxx.xxx


networks:
  servers-macvlan:
    driver: macvlan
    driver_opts:
      parent: ens18
    ipam:
      config:
        - subnet: "xxx.xxx.xxx.xxx/24"
          ip_range: "xxx.xxx.xxx.xxx/24"
          gateway: "xxx.xxx.xxx.xxx"

my config file looks like this for each file just renaming the display name and output name

general =
{
        name = "BY Speaker";
        output_backend = "alsa"; // Run "shairport-sync -h" to get a list of all output_backends, e.g. "alsa", "pipe", "stdout". The default is>
        airplay_device_id_offset = 0; // (AirPlay 2 only) add this to the default airplay_device_id calculated from one of the device's MAC add>
        regtype = "_airplay._tcp"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Def>
        playback_mode = "mono";
};



alsa =
{
        output_device = "out1"; // the name of the alsa output device. Use "shairport-sync -h" to discover the names of ALSA hardware devices. >
};

I also get this error on the console of the VM in proxmox:
USB 2-1.4.4: cannot submit urb 0, error -028: not enough bandwidth. I bought a USB 3.0 PCIE card and am going to try with that but any other pointers would be greatly appreciated.

Relevant log output

Server startup complete. Host name is 57f9b0072820.local. Local service cookie is 3974265796.

s6-rc: info: service 03-avahi successfully started

s6-rc: info: service legacy-services: starting

s6-rc: info: service legacy-services successfully started

Starting shairport-sync

Service "57f9b0072820" (/etc/avahi/services/ssh.service) successfully established.

Service "57f9b0072820" (/etc/avahi/services/sftp-ssh.service) successfully established.

ALSA lib pcm_direct.c:1427:(snd1_pcm_direct_initialize_slave) unable to start PCM stream

ALSA lib pcm_dshare.c:711:(snd_pcm_dshare_open) unable to initialize slave

ALSA lib pcm_direct.c:1427:(snd1_pcm_direct_initialize_slave) unable to start PCM stream

ALSA lib pcm_dshare.c:711:(snd_pcm_dshare_open) unable to initialize slave

System Information.

Running on an ubuntu server VM through proxmox. A whole USB bus controller is passed through to the VM and the USB to audio DACs are plugged into a USB expander

Configuration Information.

/ # shairport-sync --displayConfig
>> Display Config Start.

From "uname -a":
 Linux 860906cef8b2 6.1.0-23-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.99-1 (2024-07-15) x86_64 Linux

From /etc/os-release:
 Alpine Linux v3.17

Shairport Sync Version String:
 4.3.4-dirty-AirPlay2-smi10-alac-OpenSSL-Avahi-ALSA-pa-dummy-stdout-pipe-soxr-convolution-metadata-mqtt-dbus-mpris-sysconfdir:/etc

Command Line:
 shairport-sync --displayConfig

Configuration File:
 /etc/shairport-sync.conf

Configuration File Settings:
 general : 
 {
   name = "BY Speaker";
   output_backend = "alsa";
   airplay_device_id_offset = 0;
   regtype = "_airplay._tcp";
   playback_mode = "mono";
 };
 alsa : 
 {
   output_device = "out1";
 };

>> Display Config End.
>> Goodbye!

PulseAudio or PipeWire installed?

  • Check if your system uses a Sound Server.

How did you install Shairport Sync?

Docker

Check previous issues

  • Confirm
@glasscake
Copy link
Author

Using a PCI to USB 3.0 7 port device worked and now I can play on 3 devices at the same time.

@mikebrady
Copy link
Owner

Thanks for the post. Perhaps some other users have experience that might help here.

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

No branches or pull requests

2 participants