Skip to contentSkip to conversation

ALSA-LIB: xrun recovery in iec958 plugin for 8ch HDMI?

DISCUSSION Pavel Hofman 1 participant 2 messages Jan 31, 2024

lore
Share & tools
lore
#0 lore raw

Hi,

Users of RPi's hdmi:vc4-hdmi report random channel swapping after an xrun. Tested (among other clients) on speaker-test, details https://forums.raspberrypi.com/viewtopic.php?p=2187582#p2187540

Experienced RPi developer has diagnosed the driver - HDMI device and DMA are correctly reset at xrun recovery (i.e. snd_pcm_stop(XRUN) in the driver -> snd_pcm_prepare in the client).

Therefore an option is that alsa supplies misaligned 8ch samples after the xrun recovery.

Users checked the older HDMI driver bcm2835_audio (bcm2835-pcm.c) which accepts standard S16/24_LE formats and does not require the iec958 plugin and xruns did not cause any channel swaps.

Hence aiming at the iec958 plugin. It seems to keep state (e.g. iec->counter) which perhaps may not be reset at snd_pcm_prepare.

Thanks a lot,

Pavel.

#1 lore raw

Dne 31. 01. 24 v 9:48 Pavel Hofman napsal(a):

Quoted 4 lines

Hi,

Users of RPi's  hdmi:vc4-hdmi report random channel swapping after an xrun. Tested (among other clients) on speaker-test, details https://forums.raspberrypi.com/viewtopic.php?p=2187582#p2187540

Quoted 8 lines

Experienced RPi developer has diagnosed the driver - HDMI device and DMA are correctly reset at xrun recovery (i.e. snd_pcm_stop(XRUN) in the driver -> snd_pcm_prepare in the client).

Therefore an option is that alsa supplies misaligned 8ch samples after the xrun recovery.

Users checked the older HDMI driver bcm2835_audio (bcm2835-pcm.c) which accepts standard S16/24_LE formats and does not require the iec958 plugin and xruns did not cause any channel swaps.

Hence aiming at the iec958 plugin. It seems to keep state (e.g. iec->counter) which perhaps may not be reset at snd_pcm_prepare.

Hm, iec->counter seems to be reset correctly at prepare through plugin->prepare -> snd_pcm_plugin_call_init_cb -> snd_pcm_iec958_init . It should mark the audio block with 'Z' on the first byte of the recovered stream OK. Could perhaps be any cached samples within the chain, not cleared by prepare? But that would cause issues in other cases too... So I have no idea now :-)