Re: Issues with more than four channels

From: Alexandre Ratchov <>
Date: Mon, 8 Jun 2020 17:33:54 +0200
On Mon, Jun 08, 2020 at 02:56:05AM +0200, Daniel Gibson wrote:
> Hi,
> I experimented a bit with sndio on Linux.
> I was generally impressed how well it works (once I got it to work) and was
> happy to see that even on my XUbuntu 18.04 several programs and libs (incl.
> Audacious, VLC, openal-soft and SDL2) support it out of the box, but I ran
> into a a two issues that seem to be related to using a 5.1 surround speaker
> set (instead of just stereo speakers/headphones or 4 channels).
> I also found the code quite readable and clean (I read around a bit while
> debugging).

Glad you think it's clean, thanks ;-)

> snd_pcm_dump() is called in sio_alsa_setpar(), and when dev_sio_open() is
> called, that function is called twice:
> First: dev_sio_open() -> sio_open() -> _sio_alsa_open() -> sio_setpar() ->
> sio_alsa_setpar() - with default values (2 channels etc)
> Second: dev_sio_open() -> sio_setpar() -> sio_alsa_setpar() - with the
> actually configured number of channels and buffer sizes etc
> The different values are from  the *second* call.

It's OK to have two calls, the first one is to setup the library
initial settings, then sndiod (as any other program) requests its
prefered parameters.

> 2. Problem: using "-m play" and -z (or -b) *at the same time* results in
> distorted/stuttering output
> This line works:
>   sndiod -d -z 480 -f rsnd/1 -c 0:5
> So does this one:
>   sndiod -d -f rsnd/1 -c 0:5 -m play
> This also works (explicitly enabling both play and recording):
>   sndiod -d -z 480 -f rsnd/1 -c 0:5 -m play,rec
> This one causes distortion:
>   sndiod -d -z 480 -f rsnd/1 -c 0:5 -m play
> This one too:
>   sndiod -d -z 480 -b 960 -f rsnd/1 -c 0:5 -m play
> This one weirdly seems to work:
>   sndiod -d -z 480 -b 1440 -f rsnd/1 -c 0:5 -m play
> So using both workarounds for my first problem at the same time causes new
> issues..
> This time the ALSA debug dump was the same in broken/nonbroken cases (except
> it also listed a capture device if recording wasn't disabled).
> However, for some reason it seems to work if I manually set both buffersize
> and periodsize, *if* the periodsize is (at least) 3x as big as the
> buffersize - while usually (without "-m play") 2x buffersize is enough.
> Like in the first problem, this only happens when enabling channels 4 and 5
> (starting sndiod with "-c 0:4" or 0:5 or just 4:5 or 4:4); sndiod with "-c
> 0:3" etc doesn't have this distortion.

Most likely the "start threshold" logic is wrong. The "watchdog
time-out" happens when play and rec directions are out of sync, most
probably because one of them didn't start at all. Still, I fail to
understand why this is sensitive to the channel count.

My Linux box does stereo only, so I'll have to setup a new one to try
to reproduce it. Meanwhile could you send me the debug output of the
full-duplex 6-channel setup, as follows. In one terminal run:

SNDIO_DEBUG=5 sndiod -dd -a on -f rsnd/1 -c 0:5 2>log-6ch.txt

then in another run "aucat -i /dev/zero" for around 10 seconds and
send me the resulting file. Then the same but for the working

SNDIO_DEBUG=5 sndiod -dd -a on -f rsnd/1 2>log-2ch.txt

Thanks for the openal change, BTW

-- Alexandre
Received on Mon Jun 08 2020 - 17:33:54 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 09 2022 - 16:23:48 CEST