alsaloop: confusing line of code and easier example of the use of snd_pcm_poll_descriptors API
GitHub issues - edited
github at alsa-project.org
Fri Dec 23 11:10:31 CET 2022
alsa-project/alsa-utils issue #185 was edited from anthonio9:
Hi! Recently I've been studying the `alsaloop` software, I'm trying to understand how should the `snd_pcm_poll_descriptors` api be used reliably. Reading through the `pcmjob.c` file I've noticed that in the `pcmjob_pollfds_handle` function in line 1964 there's a condition that does not exactly make sense to me. What's the purpose of variable `loopcount`? If the code is more or less
```cpp
int loopcount = 0;
do
{
// instructions
loopcount++;
} while ((ccount > 0 || pcount > 0) && loopcount > 10); // line 1964
```
isn't it equal to running the loop just once without any loops? After all, the `loopcount` will never reach 10 and the conditional statement will always turn false finishing the loop after one iteration. Correct me if I'm wrong.
I suppose that condition would make more sense if it was as below:
```cpp
} while ((ccount > 0 || pcount > 0) && loopcount < 10); // line 1964
```
then the loop would be stop for iterating too many times, assuming that 10 is "too many". With the part `loopcount < 10` deleted, the loop usually runs twice.
I'd also appreciate a simpler example than `alsaloop` focusing just on the audio parts, on transferring audio from input to output reliably with the use of `snd_pcm_poll_descriptors`.
Thanks
Issue URL : https://github.com/alsa-project/alsa-utils/issues/185
Repository URL: https://github.com/alsa-project/alsa-utils
More information about the Alsa-devel
mailing list