quiniouben / vban

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

Raspberry and KODI problem #62

Closed Blobbel closed 3 years ago

Blobbel commented 3 years ago

I noticed there were some other kinda unresolved issues that got resolved but nobody understood why it started working.

I have a more or less standard KODI installation on a Raspberry Pi 3B and I am having a bit of a problem getting vban_receptor to work. What's a bit unusual here is that I am trying to play back a 5.1 stream from a PC into the KODI system (which is connected to speakers via HDMI). I have to admit I don't know so much about Linux audio but I would be happy to try to get this sorted out, not only for myself, I do believe some other people might want to run vban on raspberries that are used as media players..

After getting the toolchain in order, I configured and compiled vban with --disable-pulseaudio --disable-jack

Here is the output of aplay -L :

osmc@osmc:~/vban/vban-master$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dmix:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=2
    bcm2835 ALSA, bcm2835 IEC958/HDMI1
    Hardware device with all software conversions

I set up Voicemeeter on the PC and enabled VBAN. Stream1 is set for 6 channels, PCM 16bit, 48k. I am playing back audio from foobar2000 using "Voicemeeter input" as the audiodevice.. so far so good.

But if I try to connect the receptor, i get this kind of errors:

osmc@osmc:~$ vban_receptor -i 192.168.8.168 -p 6980 -s Stream1    -d default          
vban_receptor version 2.1.0

Error: alsa_write: short write (expected 119, wrote 4)
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred
Error: alsa_write: short write (expected 119, wrote 4)
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred
Error: alsa_write: short write (expected 119, wrote 4)
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred
Error: alsa_write: short write (expected 119, wrote 4)
Error: alsa_write: snd_pcm_writei failed: Broken pipe

Yes, my network really is '192.168.8.".

aplay works with some stereo test file (even if some other audio is playing on the raspberry under KODI -- the sound gets mixed).

I'm also able to get test noise into all 6 speakers with speaker-test -c6 -D hw:0,1 (wrongly mapped but still)

But hw:0,1 as the device for vban_receptor gets the short write/ broken pipe message.

I tried it after sudo systemctl stop mediacenter, same thing.

if I put -d null as the device then it gives no error message. (But no audio ouput either for obvious reasons)

I tried different device descriptors, and for some of them there is a channel mismatch instead of the broken pipe/ underrun:

osmc@osmc:~/vban/vban-master$ vban_receptor -i 192.168.8.168 -p 6980 -s Stream1    -d dmix:CARD=ALSA,DEV=0
vban_receptor version 2.1.0

ALSA lib pcm.c:8507:(snd_pcm_set_params) Channels count (6) not available for PLAYBACK: Invalid argument
Error: alsa_open: set_params error: Invalid argument
Error: audio_set_stream_config: could not open backend with new config

The channel mismatch thing happens on the following devices:

dmix:CARD=ALSA,DEV=0 dmix:CARD=ALSA,DEV=1 dmix:CARD=ALSA,DEV=2 hw:CARD=ALSA,DEV=0

Strangely, hw:CARD=ALSA,DEV=1 hw:CARD=ALSA,DEV=2 instead have the broken pipe issue.

dsnoop:CARD=ALSA,DEV=0 instead gives The dsnoop plugin supports only capture stream

Does anyone know what could be the matter or have any idea where I should poke next? This could of course also be a Raspberry or KODI thing, but it's are a common enough setup that this might be googlable for someone else trying to achieve the same thing.

Logging with -l 4 gives this:

osmc@osmc:~/vban$ vban_receptor -i 192.168.8.168 -p 6980 -s Stream1 -l4  -d hw:0,1       
vban_receptor version 2.1.0

Info: socket_open: opening socket with port 6980
Info: socket_open with port: 6980
Info: audio_init: config is direction out, backend , device hw:0,1, buffer size 3072
Info: audio_backend_get_by_name: taking default backend alsa
Info: audio_set_map_config: new map config is nb channels 0
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005888
Info: audio_set_stream_config: new stream config is nb channels 6, sample rate 48000, bit_fmt 16I
Debug: alsa_open: snd_pcm_open
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005889
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005890
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005891
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005892
Debug: audio_write invoked with size 1428
Error: alsa_write: short write (expected 119, wrote 4)
Warning: main: wrote 48 bytes, expected 1428 bytes
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005893
Debug: audio_write invoked with size 1428
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred
Warning: main: wrote 0 bytes, expected 1428 bytes
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005894
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005895
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005896
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005897
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005898
Debug: audio_write invoked with size 1428
Error: alsa_write: short write (expected 119, wrote 4)
Warning: main: wrote 48 bytes, expected 1428 bytes
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1005899
Debug: audio_write invoked with size 1428
Error: alsa_write: snd_pcm_writei failed: Broken pipe
ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred
Warning: main: wrote 0 bytes, expected 1428 bytes
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168

etc

If I specify -c1,2 it's possible to get a message such as new map config is nb channels 2 instead of the a bit suspicious 0 but the error remains:

osmc@osmc:~/vban$ vban_receptor -i 192.168.8.168 -p 6980 -s Stream1  -c1,2 -l4 -d hw:0,1 
vban_receptor version 2.1.0

Info: socket_open: opening socket with port 6980
Info: socket_open with port: 6980
Info: audio_init: config is direction out, backend , device hw:0,1, buffer size 3072
Info: audio_backend_get_by_name: taking default backend alsa
Info: audio_set_map_config: new map config is nb channels 2
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1191003
Info: audio_set_stream_config: new stream config is nb channels 6, sample rate 48000, bit_fmt 16I
Debug: alsa_open: snd_pcm_open
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1191004
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1191005
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1191006
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1191007
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1191008
Debug: audio_write invoked with size 1428
Debug: socket_read invoked
Debug: socket_read ip 192.168.8.168
Debug: packet_pcm_check: packet is vban: 1312899670, sr: 3, nbs: 118, nbc: 5, bit: 1, name: Stream1, nu: 1191009
Debug: audio_write invoked with size 1428
Error: alsa_write: short write (expected 119, wrote 54)
Warning: main: wrote 648 bytes, expected 1428 bytes

Cheers and thanks for the good work!

Blobbel commented 3 years ago

I figured it out, part 1 of the fix was by setting -q 4 for a larger buffer, which makes 99.9% of those error messages disappear.

Part 2 was realizing the fader of the "Virtual input" into Voicemeeter needed to be up. D'oh!!!!!

Closing the issue but leaving this up for googlability in case someone else has the same issue.