void thread_test(Sound* s) { while(1) { usleep(200000); /* 0.2sec */ s->loop_count = s->asound_read(); } }
So the function asound_read() is called 5 times per second. Since the function returns the number of blocks read, each containing 4k samples, the average value of loop_count should be 2.34 (= 0.2*(48000/4k)).
% ag --no-numbers loop_count log.txt | sort | uniq -c 3 loop_count = 0 2282 loop_count = 2 992 loop_count = 3
After a short run of the program, the average value obtained is 2.30 (= (3*0+2282*2+992*3)/(3+2282+992)), and no -EPIPE error (overrun for capture) was observed during the run.