Audio Line-In Piped to Snapcast Crashes Sound Card (any Linux gurus on here?)

I’m trying to get Snapcast up and running and configured in HA. Strictly speaking I haven’t got to the HA bit yet but I need some help and figured someone here may be able to help me.

My ultimate goal is to take the audio line in from the USB sound card plugged into my Pi Zero and pipe it to a number of other devices using Snapcast. This way I can plug my Echo Dot into a Pi Zero and stream radio, bluetooth, Spotify etc all via voice control.

I have Snapcast up and running and using mpd I can successfully cast a radio stream to 2 different Snapcast clients.

For piping the line in to the Snapcast FIFO (the named pipe that is picked up by the Snapcast server and then broadcast out) Snapcast recommend CPIPED. If I do this the line is is at first successfully streamed to the 2 different Snapcast clients…but…after about 10 seconds it stops and the USB Audio card stops working.

This is the command I am running:

/home/pi/cpiped/cpiped -d plughw:CARD=Device /tmp/lineinfifo

This is the dmesg:

[  548.218519] usb 1-1.3: 1:1: cannot set freq 48000 to ep 0x1
[  548.218679] usb 1-1.3: 2:1: cannot set freq 48000 to ep 0x82
[  548.218789] usb 1-1.3: 13:0: cannot get min/max values for control 2 (id 13)
[  548.218858] usb 1-1.3: 9:0: cannot get min/max values for control 2 (id 9)
[  548.218909] usb 1-1.3: 10:0: cannot get min/max values for control 2 (id 10)
[  548.331420] usb 1-1.3: new full-speed USB device number 5 using dwc_otg
[  548.431444] usb 1-1.3: device descriptor read/64, error -71
[  548.651399] usb 1-1.3: device descriptor read/64, error -71
[  548.871482] usb 1-1.3: new full-speed USB device number 6 using dwc_otg
[  548.971456] usb 1-1.3: device descriptor read/64, error -71
[  549.191395] usb 1-1.3: device descriptor read/64, error -71
[  549.411437] usb 1-1.3: new full-speed USB device number 7 using dwc_otg
[  549.851415] usb 1-1.3: device not accepting address 7, error -71
[  549.951391] usb 1-1.3: new full-speed USB device number 8 using dwc_otg
[  550.391433] usb 1-1.3: device not accepting address 8, error -71
[  550.391868] usb 1-1-port3: unable to enumerate USB device

This also occurs if I use arecord:

arecord --device=plughw:CARD=Device --format=S16_LE --rate=44100 --channels=2 /tmp/lineinfifo

Not sure why a frequency of 48000 is mentioned in dmesg, especially when using arecord as I am explicitly specifying a frequency of 44100 which is what Snapserver is set to on that FIFO.

Weirdly (and probably importantly) I do not get the crashing issue if I use arecord to record to file instead of a FIFO:

arecord --device=plughw:CARD=Device --format=S16_LE --rate=44100 --channels=2 test.wav

I can run this record for as long as I want and get no problem.

Please send help!

Another test I have run is to create a brand new FIFO with mkfifo. I then used CPIPED to record to this FIFO and then simultaneously used aplay to play the contents.

This worked without issue so the problem appears to be something related Snapserver reading the FIFO?

Ok, so replacing the sound card has resolved the issue. Not sure if it was a problem with the soundcard, the model of soundcard or the config in place for it.

Working now :slight_smile:.