christf / snapcastc

C implementation of snapcast focussing on audio quality and ease of maintenance.
GNU General Public License v3.0
43 stars 6 forks source link

Error starting client #31

Closed fabsmusicjunkie closed 4 years ago

fabsmusicjunkie commented 5 years ago

I have a pi with raspbian with the with an PCM5102 DAC. It's using the hifiberry-drivers, but has no audio control available (may be the problem). when launching the client following error occurs: snapcast-client -H localhost -p 1704 -s default -d -m dmix:CARD=sndrpihifiberry intercom hello nonce: 4068148625 intercom hello nonce: 4068148626 could not set priority. Adjusting priority helps on otherwise busy clients. Continuing. initializing alsa PCM name: 'default' PCM state: PREPARED channels: 2 rate: 48000 bps frames: 1440 alsa requested buff_size: 5760 period time: 30000 pollfd_count: 1 start threshold is: 28800 starting loop polling handling event on fd 0. handling event on fd 3. taskqueue ready handling taskqueue event saying hello to server snapcast-client: simple.c:283: snd_mixer_selem_get_playback_volume_range: Assertion elem failed. Abgebrochen

aplay -l **** Liste der Hardware-Geräte (PLAYBACK) **** Karte 0: sndrpihifiberry [snd_rpi_hifiberry_dac], Gerät 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [] Sub-Geräte: 1/1 Sub-Gerät #0: subdevice #0 Do you need more information?

christf commented 5 years ago

Hi,

that is an interesting one. I have a hifiberry as well but never used dmix with snapcast. Indeed snapcast cannot obtain the volume from the mixer device that was specified. Can you send me aplay -L and snapcast-client -l please.

What do you mean by "no audio control available"? Does alsamixer show the sliders for the mixer device you are setting?

snapcast-client -s default -c hw:0 -m Master -H localhost -v should work on your default sound device, Master channel on card 0.

can you try the options: -c hw:0 -m Master -s default

fabsmusicjunkie commented 5 years ago

i don't have a hifiberry, but a dac which is using a similar chip, see: https://de.aliexpress.com/item/PCM5102-DAC-Decoder-I2S-Player-Montiert-Bord-32Bit-384-karat-ber-ES9023-PCM1794-f-r-Raspberry/32833639428.html alsamixer doesn't show the sliders. The volume is always at 100%. aplay -L null Discard all samples (playback) or generate zero samples (capture) default sysdefault:CARD=sndrpihifiberry snd_rpi_hifiberry_dac, Default Audio Device dmix:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Direct sample mixing device dsnoop:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Direct sample snooping device hw:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Direct hardware device without any conversions plughw:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Hardware device with all software conversions

snapcast-client -l PCM DEVICE name: null id: 0 description: Discard all samples (playback) or generate zero samples (capture) PCM DEVICE name: default id: 1 description: PCM DEVICE name: sysdefault:CARD=sndrpihifiberry id: 2 description: snd_rpi_hifiberry_dac, Default Audio Device PCM DEVICE name: dmix:CARD=sndrpihifiberry,DEV=0 id: 3 description: snd_rpi_hifiberry_dac, Direct sample mixing device PCM DEVICE name: dsnoop:CARD=sndrpihifiberry,DEV=0 id: 4 description: snd_rpi_hifiberry_dac, Direct sample snooping device PCM DEVICE name: hw:CARD=sndrpihifiberry,DEV=0 id: 5 description: snd_rpi_hifiberry_dac, Direct hardware device without any conversions PCM DEVICE name: plughw:CARD=sndrpihifiberry,DEV=0 id: 6 description: snd_rpi_hifiberry_dac, Hardware device with all software conversions

christf commented 5 years ago

wow. looks like your alsa setup then is not compatible with what snapcast-client expects. Alsa does not seem to export any mixer controls, snapcast-client expects an alsa-supplied mixer to control the volume. Could you please confirm that -c hw:0 -m Master -s default does not work for you? I am not sure how to proceed in this case. Maybe connect with the alsa-folks to check how to achieve mixing in this case?

Edit: Have you tried the alsa softvol plugin as described in the README?

In the mean time, could you try #32 please?

fabsmusicjunkie commented 5 years ago

"-c hw:0 -m Master -s default" also brings: snapcast-client: pcm_params.c:2290: snd_pcm_hw_refine: Assertion `pcm && params' failed.

I tried to use the softvol, but i see no changes.

with #32 it gives the following error:

-c hw:1 -m Master -s default could not set priority. Adjusting priority helps on otherwise busy clients. Continuing. ALSA lib pcm.c:2364:(snd_pcm_open_conf) type is not defined snapcast-client: pcm_params.c:2290: snd_pcm_hw_refine: Assertion pcm && params' failed.

christf commented 5 years ago

sorry for this, I am not sure where this actually fails because these are alsa-internal functions. Can you please always include -d / strace? Better yet, if you know how to handle gdb, please run with:

gdb --args ./snapcast-client -d -v -c hw:0 -m Master -s default -H wherever and show a backtrace (bt) when it fails.

fabsmusicjunkie commented 5 years ago

Edt: suddenly something is working completly different. ./snapcast-client -H localhost -p 1707 -m Master -c hw:0 intercom hello nonce: 1677516641 intercom hello nonce: 1677516642 could not set priority. Adjusting priority helps on otherwise busy clients. Continuing. could not initialize mixer Master. Continuing with bogus volume values. You will not be able to control the volume .could not initialize mixer Master. Continuing with bogus volume values. You will not be able to control the volume .sendto failed: Connection refused ....

with -d there is an endless return of: "handling event on fd 4. polling handling event on fd 4. polling"

i don't have any experience in gdb, but tried it. I don't know if i do it right: `Starting program: /home/pi/snapcastc-mixer/build/src/snapcast-client ./snapcast-client -d -H localhost -p 1707 -s default [Thread debugging using libthread_db enabled] Using host libthread_db library /lib/arm-linux-gnueabihf/libthread_db.so.1. intercom hello nonce: 1951769360 intercom hello nonce: 1951769361 could not set priority. Adjusting priority helps on otherwise busy clients. Continuing. initializing alsa snapcast-client: pcm_params.c:2290: snd_pcm_hw_refine: Assertion pcm && params failed. Program received signal SIGABRT, Aborted. __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 51 ../sysdeps/unix/sysv/linux/raise.c: Datei oder Verzeichnis nicht gefunden. (gdb) (gdb) backtrace

0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51

1 0x76c1c824 in __GI_abort () at abort.c:89

2 0x76c141a4 in __assert_fail_base (fmt=0x76ff5410 "", assertion=0x76df76d0 "pcm && params",

assertion@entry=0x2 <error: Cannot access memory at address 0x2>, file=0x7efff24c " ", file@entry=0x76d2c078 "", line=2290, line@entry=1996444688, function=function@entry=0x76df92dc "snd_pcm_hw_refine") at assert.c:92

3 0x76c14280 in __GI___assert_fail (assertion=0x2 <error: Cannot access memory at address 0x2>, file=0x76d2c078 "", line=1996444688,

function=0x76df92dc "snd_pcm_hw_refine") at assert.c:101

4 0x76d829cc in snd_pcm_hw_refine () from /usr/lib/arm-linux-gnueabihf/libasound.so.2

Backtrace stopped: previous frame identical to this frame (corrupt stack?)`

christf commented 5 years ago

the error that is visible from gdb hints at both:

In that case playing around with the settings that control which audio device is used is the right thing to find a workaround. The patches from the mixer branch are still required. For now this will not allow to control the volume.f

Could you please try the updated version of the patch including the fixup commit? It will allow to store a software volume to avoid unnecessary volume control packets sent. A ta late stage we might get software volume control implemented to actually change the volume in software even if there is no mixer device.