Hi Jaroslav, Thank you for the fix. I tried it and I don't have 0-written-frames anymore. To be sure that the fix works fine, I compared the multi scenario (forward+loopback) with the forward-only scenario. It works fine in both cases, but sometimes in the multi scenario I have underruns. Could it depend from the fix? Or the usage of multi itself can bring to underruns?
-----Messaggio originale----- Da: Jaroslav Kysela perex@perex.cz Inviato: martedì 9 aprile 2019 10:37 A: Giuliano Zannetti - ART S.p.A. giuliano.zannetti@artgroup-spa.com; alsa-devel@alsa-project.org Oggetto: Re: [alsa-devel] loopback snd_pcm_writei
Dne 01. 04. 19 v 15:51 Giuliano Zannetti - ART S.p.A. napsal(a):
Hi,
I have the configuration in the asound.conf above.
my_plug - - > my_route - - > my_multi - - > slave0 (forward) - - > slave1 (loopback)
I open the plug my_plug in the block mode:
writtenFrames = snd_pcm_writei(handle, bufferToWrite, bufferToWriteSize);
The issue I see is that there are several "writes" with 0 written frames. It seems like the snd_pcm_writei does not hold until data will be written. In general, 0 written frames sounds weird to me, because snd_pcm_writei should block itself if no space is available in the circular buffer right?
I have tried to fix the following method in pcm_multi.c, as Jaroslav Kysela suggests.
-static int snd_pcm_multi_may_wait_for_avail_min(snd_pcm_t *pcm, snd_pcm_uframes_t avail ATTRIBUTE_UNUSED) +static int snd_pcm_multi_may_wait_for_avail_min(snd_pcm_t *pcm, snd_pcm_uframes_t avail) { snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[multi->master_slave].pcm;
return snd_pcm_may_wait_for_avail_min(slave, snd_pcm_mmap_avail(slave));
unsigned int i;
for (i = 0; i < multi->slaves_count; ++i) {
if (snd_pcm_may_wait_for_avail_min(multi->slaves[i].pcm, avail))
return 1;
}
return 0;
}
But unfortunately the issue has not been resolved.
Hi,
I did some debugging (it's pretty reproducible) and the real fixes are here:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.alsa-p... https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.alsa-p... https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.alsa-p... https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.alsa-p...
Just get the latest alsa-lib and it should work correctly now. Let me know the result.
Thanks. Jaroslav