annotate mp3lib/test2.c @ 4198:7e2bf04c9a7c

added vidix_start() and vidix_stop() for better runtime-resize support ;)
author alex
date Wed, 16 Jan 2002 15:22:45 +0000
parents 03b7e2955a20
children b277842a74a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
1
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 826
diff changeset
2 //gcc test2.c -O2 -I.. -L. ../libvo/aclib.c -lMP3 -lm -o test2
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
3
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
4 #include <stdio.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
5 #include <stdlib.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
6
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
7 #include <fcntl.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
8 #include <sys/ioctl.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
9 #include <unistd.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
10 #include <sys/soundcard.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
11
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
12 #include "mp3lib/mp3.h"
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
13 #include "config.h"
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
14
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
15 static FILE* mp3file=NULL;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
16
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
17 int mplayer_audio_read(char *buf,int size){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
18 return fread(buf,1,size,mp3file);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
19 }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
20
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
21 #define BUFFLEN 4608
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
22 static unsigned char buffer[BUFFLEN];
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
23
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
24 int main(int argc,char* argv[]){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
25 int len;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
26 int total=0;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
27 float length;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
28 int r;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
29 int audio_fd;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
30
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
31 mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
32 if(!mp3file){ printf("file not found\n"); exit(1); }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
33
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
34 // MPEG Audio:
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
35 #ifdef USE_FAKE_MONO
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
36 MP3_Init(0);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
37 #else
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
38 MP3_Init();
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
39 #endif
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
40 MP3_samplerate=MP3_channels=0;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
41 len=MP3_DecodeFrame(buffer,-1);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
42
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
43 audio_fd=open("/dev/dsp", O_WRONLY);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
44 if(audio_fd<0){ printf("Can't open audio device\n");exit(1); }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
45 r=AFMT_S16_LE;ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
46 r=MP3_channels-1;ioctl (audio_fd, SNDCTL_DSP_STEREO, &r);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
47 r=MP3_samplerate;ioctl (audio_fd, SNDCTL_DSP_SPEED, &r);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
48 printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,MP3_samplerate);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
49
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
50 while(1){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
51 int len2;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
52 if(len==0) len=MP3_DecodeFrame(buffer,-1);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
53 if(len<=0) break; // EOF
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
54
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
55 // play it
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
56 len2=write(audio_fd,buffer,len);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
57 if(len2<0) break; // ERROR?
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
58 len-=len2; total+=len2;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
59 if(len>0){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
60 // this shouldn't happen...
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
61 memcpy(buffer,buffer+len2,len);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
62 putchar('!');fflush(stdout);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
63 }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
64 }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
65
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
66 fclose(mp3file);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
67
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
68 }