Hi.
I just happened to stumble about a (what I call) pretty subtle
bug in typical ALSA PCM code:
root@fzidpc73:/tmp# cat test.c
#include <stdio.h>
int main() {
int period = 1024;
int nperiods = 3;
int rate = 96000;
unsigned buffer_time = 1000000*period*nperiods/rate;
printf("%d\n", buffer_time);
}
root@fzidpc73:/tmp# ./test
-12739
root@fzidpc73:/tmp# sed -i -e 's/int rate/unsigned int rate/' test.c
root@fzidpc73:/tmp# gcc -o test test.c
root@fzidpc73:/tmp# ./test
32000
I.e., don't trust this boilerplate formula blindly.
--
CYa,
⡍⠁⠗⠊⠕