DF-4846 / ctlchurn.c
/* ctlchurn.c — control: same topology, but ONLY write sizes that are exact * multiples of both aligns (12 and 14): lcm = 84 -> 43008, 21504. */ #include <sys/soundcard.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char **argv) { int fds[2], ch[2] = { 6, 7 }, fmt = AFMT_S16_LE, sp = 48000, r, i, j; static const int sz[] = { 43008, 43008, 21504, 43008 }; unsigned char b[131072]; long it = (argc > 1) ? atol(argv[1]) : 300; memset(b, 1, sizeof(b)); for (i = 0; i < 2; i++) { fds[i] = open("/dev/dsp", O_WRONLY); if (fds[i] < 0) { perror("open"); return (1); } ioctl(fds[i], SNDCTL_DSP_SETFMT, &fmt); ioctl(fds[i], SNDCTL_DSP_SPEED, &sp); ioctl(fds[i], SNDCTL_DSP_CHANNELS, &ch[i]); } for (j = 0; j < it; j++) for (i = 0; i < 2; i++) { r = write(fds[i], b, sz[j % 4]); if (r < 0) { perror("write"); return (1); } usleep(3000); } printf("control done, no error\n"); return (0); } |