quiniouben / vban

VBAN protocol open-source implementation
GNU General Public License v3.0
450 stars 63 forks source link

no audio playing using vban_receptor (raspian, alsa) #34

Closed Pomax closed 5 years ago

Pomax commented 5 years ago

I followed the instructions to install this by installing the libs and headers necessary, running the autogen script, ./configure with --disable-pulseaudio --disable-jack arguments, make and make install, and I have a working vban_receptor command available now.

However, when I run the receptor command, things go wrong:

pi@raspberrypi:~/Documents/git/vban $ vban_receptor -i 192.168.1.24 -p 6980 -s DAW
vban_receptor veersion 2.1.0

Error: alsa_write: short write (expected 256, wrote 72)
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8306(snd_pcm_recover) underrun occurred
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8306(snd_pcm_recover) underrun occurred
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8306(snd_pcm_recover) underrun occurred
[...]

(the longer I leave it running, the more this error repeats, with different values for wrote).

I verified that the IP, port, and stream name involved are correct, and if I try to just play a random youtube video in Chromium, I do hear audio, so something seems to be pretty wrong?

Pomax commented 5 years ago

@quiniouben any idea? =/

quiniouben commented 5 years ago

Hi @Pomax , sorry for the delay, times are busy this year... I am not sure to understand if you have or haven't correct audio going through. Have you ?

About this error, if it repeats very quickly, then probably something is wrong with the alsa interface used. If it occurs from time to time (let's say once or twice per half minute), well, I have seen this in the past and this is the drawback of the simplistic approach token for vban_receptor regarding synchronization with audio interfaces.

Pomax commented 5 years ago

I don't get any audio at all from vban_receptor (but other audio sources work fine, like youtube in a browser, or VLC). I only get those console messages.

quiniouben commented 5 years ago

Hi, ok. Let's try to learn more about your system:

One more thing could be to raise the debug level with option -l, you could try -l3 for instance

Pomax commented 5 years ago

aplay -L gives the following output:

pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: vc4hdmi [vc4-hdmi], device 0: MAI PCM vc4-hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Raspian only has ALSA available by default, so there is no pulseaudio available.

The audio from other sources gets sent through HDMI. but I don't know if that means it's card 0's HDMI subdevice, or that card 1 vc4hdmi device... (I'm a bit out of my element here, I have no idea how audio devices on linux work or how to configure them)

Pomax commented 5 years ago

Is there a way to change the device to explicitly use the HDMI part of that "device 1", to see if it's just a matter of ALSA sending the audio to the wrong connector?

(I don't quite know what part of the strings shown should be used for that)

Pomax commented 5 years ago

alsamixer information:

photo_2019-04-11 10 52 39

Pomax commented 5 years ago

In a bit of desperation I hooked up a USB sound card, disabled the native broadcom audio chip, and followed some pretty solid advice on making sure the USB device is set as default, and with all that done, this command will happily play audio through my speakers now:

$ aplay /usr/share/sounds/alsa/Front_Center.wav -D plughw:0,0

but vban receptor still does not play any audio:

$ vban_receptor -i 192.168.1.17 -pp 6980 -s DAW -d plughw=0,0

it's still just showing that same "broken pipe"/"underrun" error..

VBAN on the sending computer says that is the correct IP, port, and stream name, with the stream sending to 192.168.1.11, which is the raspberry pi IP according to ifconfig. Pinging from one machine to the other also works fine. Also, just to be sure, I made sure to check that the stream outputs weren't muted: they are not.

quiniouben commented 5 years ago

Hi @Pomax , I am sorry for the long delays, free time is lacking a lot this year... That is weird. The broken pipe clearly says the problem is on alsa side, and if you reach it, it means you correctly receive vban packets from the emitting side. About selecting the audio device you play on, you should pass vban_receptor the -d option you correctly identified, with labels that aplay -L shows (please note the capital "-L", not the small "-l"). Using aplay -L you will have knowledge what is the default device. One reason could be that the emitter sends data at some sample frequency or sample format that the receptor doesn't like too much, eventhough it pretends to do it. Could you please copy paste the output of the vban_receptor invocation with -l3 option ?

Pomax commented 5 years ago

I removed the alsa config overrides for using a USB audio device again, and miraculously, vban_receptor now just works (even without a device flag)...

So I have no idea why it suddenly works, but audio gets sent over the network just fine now (although at 48KHz it's pretty choppy, so I adjusted that down to 22.5KHz at the sender and things sound perfectly fine now)

quiniouben commented 5 years ago

Hi, I am glad it works now, even though it is a bit frustrating not to know why. Anyway, I will close this issue.