Update of /cvsroot/alsa/alsa-driver/test In directory sc8-pr-cvs1:/tmp/cvs-serv18440
Modified Files: .cvsignore Makefile Added Files: osspcm2.c Log Message: Added osspcm2.c, cleanups --- NEW FILE: osspcm2.c --- #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <unistd.h> #include <sys/soundcard.h> #include <time.h> int main(void) { int fd = open("/dev/dsp", O_RDONLY); if (fd == -1) { perror("open"); exit(127); } int res = AFMT_S16_LE; if (ioctl(fd, SNDCTL_DSP_SETFMT, &res) == -1) { perror("ioctl"); exit(127); } res = 0; if (ioctl(fd, SNDCTL_DSP_STEREO, &res) == -1) { perror("ioctl"); exit(127); } res = 22050; if (ioctl(fd, SOUND_PCM_READ_RATE, 0xbfffdcfc) == -1) { perror("ioctl"); exit(127); } res = 0x2000a; if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &res) == -1) { perror("ioctl"); exit(127); } audio_buf_info info; if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) == -1) { perror("read"); exit(127); } printf(" Size of a fragment in bytes: %d\n", info.fragsize); printf(" Allocated fragments for buffering: %d\n", info.fragstotal); char buf[1024]; if (read(fd, buf, sizeof(buf)) < 0) { perror("read"); exit(127); } static struct timespec naptime = { 0, 100000000 }; int count = 0; do { if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) == -1) { perror("read"); exit(127); } nanosleep(&naptime, 0); if (++count == 20) { printf("Failed to cause an xrun.\n"); exit(127); } printf("info.bytes = %u, info.fragsize = %u, info.fragstotal = %u\n", info.bytes, info.fragsize, info.fragstotal); } while(info.bytes < info.fragsize * info.fragstotal); printf(" Successfully caused an xrun.\n"); printf(" non-blocking fragments: %d\n", info.fragments); printf(" non-blocking bytes: %d\n", info.bytes); ssize_t bufsize = info.bytes; ssize_t trlen = 0; int nf = 0; for (;;) { if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) == -1) { perror("ioctl"); exit(127); } if (info.fragments > 0) { ssize_t rlen; if ((rlen = read(fd, buf, sizeof(buf))) < 0) { perror("read"); exit(127); } trlen += rlen; if (trlen > bufsize) { printf(" Read %d bytes: stream successfully restarted.\n", trlen); exit(0); } nf = 0; } else if (++nf > 10) { printf(" Stream is not restarted after xrun.\n"); exit(1); } } close(fd); return 0; } Index: .cvsignore =================================================================== RCS file: /cvsroot/alsa/alsa-driver/test/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- .cvsignore 10 Sep 2000 09:20:17 -0000 1.2 +++ .cvsignore 26 Jul 2003 08:14:09 -0000 1.3 @@ -3,5 +3,8 @@ mixer osspcm osspcm1 +osspcm2 +seq1 +seq2 ossdelay csp_load Index: Makefile =================================================================== RCS file: /cvsroot/alsa/alsa-driver/test/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Makefile 27 Apr 2003 14:50:43 -0000 1.9 +++ Makefile 26 Jul 2003 08:14:09 -0000 1.10 @@ -10,6 +10,9 @@ osspcm1: osspcm1.c $(CC) $(CFLAGS) -o osspcm1 osspcm1.c +osspcm2: osspcm2.c + $(CC) $(CFLAGS) -o osspcm2 osspcm2.c + ossdelay: ossdelay.c $(CC) $(CFLAGS) -o ossdelay ossdelay.c ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog