Mercurial > mplayer.hg
comparison TOOLS/audio-block2.c @ 752:a40ee717336e
some more printfs
author | arpi_esp |
---|---|
date | Thu, 10 May 2001 13:20:56 +0000 |
parents | cd1f0d4de0b8 |
children |
comparison
equal
deleted
inserted
replaced
751:1417d8a4a96c | 752:a40ee717336e |
---|---|
1 // This small util discovers your audio driver's behaviour | 1 // This small util discovers your audio driver's behaviour |
2 | 2 |
3 #define OUTBURST 512 | 3 //#define OUTBURST 512 |
4 //#define OUTBURST 4096 | 4 //#define OUTBURST 4096 |
5 #define MAX_OUTBURST 32768 | |
5 | 6 |
6 | 7 |
7 #include <stdio.h> | 8 #include <stdio.h> |
8 #include <stdlib.h> | 9 #include <stdlib.h> |
9 #include <fcntl.h> | 10 #include <fcntl.h> |
22 gettimeofday(&tv,&tz); | 23 gettimeofday(&tv,&tz); |
23 // s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec; | 24 // s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec; |
24 return (tv.tv_sec*1000000+tv.tv_usec); | 25 return (tv.tv_sec*1000000+tv.tv_usec); |
25 } | 26 } |
26 | 27 |
27 static unsigned char a_buffer[OUTBURST]; | 28 static unsigned char a_buffer[MAX_OUTBURST]; |
28 | 29 |
29 void inline print_info(int audio_fd){ | 30 void inline print_info(int audio_fd){ |
30 #if 1 | 31 #if 1 |
31 audio_buf_info zz; | 32 audio_buf_info zz; |
32 ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz); | 33 ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz); |
40 int r; | 41 int r; |
41 int xxx=1024*2; | 42 int xxx=1024*2; |
42 int audio_fd; | 43 int audio_fd; |
43 char *dsp="/dev/dsp"; | 44 char *dsp="/dev/dsp"; |
44 unsigned int t0,t1,t2; | 45 unsigned int t0,t1,t2; |
46 int outburst; | |
45 | 47 |
46 audio_fd=open(dsp, O_WRONLY); | 48 audio_fd=open(dsp, O_WRONLY); |
47 if(audio_fd<0){ | 49 if(audio_fd<0){ |
48 printf("Can't open audio device %s\n",dsp); | 50 printf("Can't open audio device %s\n",dsp); |
49 return 1; | 51 return 1; |
58 r=44100; if(ioctl (audio_fd, SNDCTL_DSP_SPEED, &r)==-1) | 60 r=44100; if(ioctl (audio_fd, SNDCTL_DSP_SPEED, &r)==-1) |
59 printf("audio_setup: your card doesn't support %d Hz samplerate\n",r); | 61 printf("audio_setup: your card doesn't support %d Hz samplerate\n",r); |
60 | 62 |
61 r=0; ioctl (audio_fd, SNDCTL_DSP_GETBLKSIZE, &r); | 63 r=0; ioctl (audio_fd, SNDCTL_DSP_GETBLKSIZE, &r); |
62 printf("fragment size = %d\n",r); | 64 printf("fragment size = %d\n",r); |
65 outburst=r; if(outburst>4096) outburst=4096; | |
63 | 66 |
64 print_info(audio_fd); | 67 print_info(audio_fd); |
65 | 68 |
66 t0=t1=GetTimer(); | 69 t0=t1=GetTimer(); |
67 | 70 |
69 char c='B'; | 72 char c='B'; |
70 fd_set rfds; | 73 fd_set rfds; |
71 struct timeval tv; | 74 struct timeval tv; |
72 FD_ZERO(&rfds); FD_SET(audio_fd,&rfds); | 75 FD_ZERO(&rfds); FD_SET(audio_fd,&rfds); |
73 tv.tv_sec=0; tv.tv_usec = 0; | 76 tv.tv_sec=0; tv.tv_usec = 0; |
74 if(select(audio_fd+1, NULL, &rfds, NULL, &tv)) c=' '; | 77 // if(select(audio_fd+1, NULL, &rfds, NULL, &tv)) c=' '; |
75 | 78 |
76 // print_info(audio_fd); | 79 print_info(audio_fd); |
77 | 80 |
78 r=write(audio_fd,a_buffer,OUTBURST); | 81 r=0; ioctl (audio_fd, SNDCTL_DSP_GETODELAY, &r); printf("delay = %d\n",r); |
82 | |
83 r=write(audio_fd,a_buffer,outburst); | |
79 t2=GetTimer(); | 84 t2=GetTimer(); |
80 if(r<0) printf("Error writting to device\n"); else | 85 if(r<0) printf("Error writting to device\n"); else |
81 if(r==0) printf("EOF writting to device???\n"); else { | 86 if(r==0) printf("EOF writting to device???\n"); else { |
82 printf("%c %6.3f %6.3f [%6d] writting %3d of %3d bytes in %7d us\n",c, | 87 printf("%c %6.3f %6.3f [%6d] writting %3d of %3d bytes in %7d us\n",c, |
83 (float)audio_buffer_size/(44100.0f*4.0f),(float)(t1-t0)*0.000001f, | 88 (float)audio_buffer_size/(44100.0f*4.0f),(float)(t1-t0)*0.000001f, |
84 audio_buffer_size,r,OUTBURST,t2-t1); | 89 audio_buffer_size,r,outburst,t2-t1); |
85 audio_buffer_size+=r; | 90 audio_buffer_size+=r; |
86 } | 91 } |
87 t1=t2; | 92 t1=t2; |
88 } | 93 } |
89 | 94 |