summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-03-16 23:05:01 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-03-16 23:05:01 +0000
commit3d2465ed4d2432383fedf0853a78ad9c54dd6061 (patch)
tree78e8c7def45f692f5f99bb14648a13d58092968c /TOOLS
parentc110d4acf5a48d44b576cbfd8aea47d2c02ca99f (diff)
downloadmpv-3d2465ed4d2432383fedf0853a78ad9c54dd6061.tar.bz2
mpv-3d2465ed4d2432383fedf0853a78ad9c54dd6061.tar.xz
added audio driver debug tools
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@120 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/audio-block.c62
-rw-r--r--TOOLS/audio-select.c73
-rwxr-xr-xTOOLS/c3
3 files changed, 138 insertions, 0 deletions
diff --git a/TOOLS/audio-block.c b/TOOLS/audio-block.c
new file mode 100644
index 0000000000..443af85e30
--- /dev/null
+++ b/TOOLS/audio-block.c
@@ -0,0 +1,62 @@
+// This small util discovers your audio driver's behaviour
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/soundcard.h>
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define OUTBURST 256
+
+// Returns current time in microseconds
+unsigned int GetTimer(){
+ struct timeval tv;
+ struct timezone tz;
+// float s;
+ gettimeofday(&tv,&tz);
+// s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
+ return (tv.tv_sec*1000000+tv.tv_usec);
+}
+
+static unsigned char a_buffer[OUTBURST];
+
+int main(){
+ int audio_buffer_size=0;
+ int r;
+ int xxx=1024*2;
+ int audio_fd;
+ char *dsp="/dev/dsp";
+ unsigned int t1,t2;
+
+ audio_fd=open(dsp, O_WRONLY);
+ if(audio_fd<0){
+ printf("Can't open audio device %s\n",dsp);
+ return 1;
+ }
+
+ r=AFMT_S16_LE;ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r);
+ r=1; ioctl (audio_fd, SNDCTL_DSP_STEREO, &r);
+ r=44100; if(ioctl (audio_fd, SNDCTL_DSP_SPEED, &r)==-1)
+ printf("audio_setup: your card doesn't support %d Hz samplerate\n",r);
+
+ t1=GetTimer();
+
+while(xxx-->0){
+ r=write(audio_fd,a_buffer,OUTBURST);
+ t2=GetTimer();
+ if(r<0) printf("Error writting to device\n"); else
+ if(r==0) printf("EOF writting to device???\n"); else {
+ printf("[%6d] writting %3d of %3d bytes in %7d us\n",audio_buffer_size,r,OUTBURST,t2-t1);
+ audio_buffer_size+=r;
+ }
+ t1=t2;
+}
+
+close(audio_fd);
+
+return 0;
+}
+
diff --git a/TOOLS/audio-select.c b/TOOLS/audio-select.c
new file mode 100644
index 0000000000..872245b5ef
--- /dev/null
+++ b/TOOLS/audio-select.c
@@ -0,0 +1,73 @@
+// This small util discovers your audio driver's behaviour
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/soundcard.h>
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define OUTBURST 128
+
+// Returns current time in microseconds
+unsigned int GetTimer(){
+ struct timeval tv;
+ struct timezone tz;
+// float s;
+ gettimeofday(&tv,&tz);
+// s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
+ return (tv.tv_sec*1000000+tv.tv_usec);
+}
+
+static unsigned char a_buffer[OUTBURST];
+
+int main(){
+ int audio_buffer_size;
+ int r;
+ int xxx=1024;
+ int audio_fd;
+ char *dsp="/dev/dsp";
+ unsigned int t1,t2,t3;
+
+ audio_fd=open(dsp, O_WRONLY);
+ if(audio_fd<0){
+ printf("Can't open audio device %s\n",dsp);
+ return 1;
+ }
+
+ r=AFMT_S16_LE;ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r);
+ r=1; ioctl (audio_fd, SNDCTL_DSP_STEREO, &r);
+ r=44100; if(ioctl (audio_fd, SNDCTL_DSP_SPEED, &r)==-1)
+ printf("audio_setup: your card doesn't support %d Hz samplerate\n",r);
+
+ t3=t1=GetTimer();
+
+while(xxx>0){
+ audio_buffer_size=0;
+ while(audio_buffer_size<0x100000){
+ fd_set rfds;
+ struct timeval tv;
+ FD_ZERO(&rfds); FD_SET(audio_fd,&rfds);
+ tv.tv_sec=0; tv.tv_usec = 0;
+ if(!select(audio_fd+1, NULL, &rfds, NULL, &tv)) break;
+ r=write(audio_fd,a_buffer,OUTBURST);
+ if(r<0) printf("Error writting to device\n"); else
+ if(r==0) printf("EOF writting to device???\n"); else
+ audio_buffer_size+=r;
+ }
+ t2=GetTimer();
+ if(audio_buffer_size>0){
+ printf("%6d bytes written in %5d us (wait %5d us)\n",audio_buffer_size,t2-t1,t1-t3);
+ --xxx;
+ t3=t2;
+ }
+ t1=t2;
+}
+
+close(audio_fd);
+
+return 0;
+}
+
diff --git a/TOOLS/c b/TOOLS/c
index 5ba26feeb6..81a26d1e3b 100755
--- a/TOOLS/c
+++ b/TOOLS/c
@@ -1 +1,4 @@
+
gcc movinfo.c -o movinfo
+gcc audio-select.c -o audio-select
+gcc audio-block.c -o audio-block