annotate mp3lib/test2.c @ 27148:858c01b81117

r26502: Document rgbtest arguments r26057: Fix copy&paste typo in rgbtest documentation r26198: Grayscale encoding/decoding with FFmpeg is no longer enabled, remove references r26221: Try to fix the description of what mbcmp influences, please fix if I misunderstood the code. r26231: better syntax for A key r26232: added missing escapes r26260: Experimental support for -framedrop with -correct-pts. r26271: Mention that '-frames 0' is useful with -identify, closes bug #1046. r26273: add "ipod" to the list of formats handled by lavf r26297: compacted new libavformat's 'ipod' description r26402: Enable runtime control for colorful and/or module name output r26427: Restore grayscale decoding support with FFmpeg. r26449: 10L, forgot to commit the documentation for the -noconfig options. r26460: restore options alphabetical order r26650: Update documentation for the gl2 driver to make clear gl is usually preferred. r26674: add h264 to list of supported codecs r26732: Mark new options Michael committed as undocumented. r26739: Oops, remove stray .TP. r26749: -psprobe can be used in mpeg-pes streams, too r26762: Add a new suboption to -vo xv and -vo xvmc that allows selection r26763: Remove '(pass 1/2)' from some lavcopts. These options really worked on r26795: Add support for AppleIR Remote as an input under Linux systems. r26798: Document the -noar command-line option in en/fr manpages. r26806: Document x264's AQ options r26853: Update gl vo section with the new force-pbo suboption. r26909: Add a slave command to stop stream playback. r26979: small spelling/wording fixes r26986: Document VIDIXIVTVALPHA environment variable. r26997: Fix codec-specific options syntax declaration to be less confusing and wrong. r27057: Ability for specifying TV standard individually for each TV channel. r27132: Fix/restore the description of the rectangle video filter. previously applied: r27169: add missing escapes and full stops for scaletempo filter r27179: remove two trailing whitespaces
author kraymer
date Mon, 30 Jun 2008 19:35:45 +0000
parents 01829c7ce94d
children e7c989f7a7c9
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 #include <stdio.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
2 #include <stdlib.h>
26498
b00fef572591 Add missing #include, fixes the warning:
diego
parents: 26203
diff changeset
3 #include <string.h>
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
4
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
5 #include <fcntl.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
6 #include <sys/ioctl.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
7 #include <unistd.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
8 #include <sys/soundcard.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
9
26203
0d255d03016f #include config.h before all other headers.
diego
parents: 10343
diff changeset
10 #include "config.h"
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
11 #include "mp3lib/mp3.h"
10343
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
12 #include "cpudetect.h"
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
13
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
14 static FILE* mp3file=NULL;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
15
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
16 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
17 return fread(buf,1,size,mp3file);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
18 }
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 #define BUFFLEN 4608
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
21 static unsigned char buffer[BUFFLEN];
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
22
10343
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
23
789
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 int r;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
28 int audio_fd;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
29
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
30 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
31 if(!mp3file){ printf("file not found\n"); exit(1); }
10343
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
32
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
33 GetCpuCaps(&gCpuCaps);
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
34
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
35 // MPEG Audio:
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
36 #ifdef USE_FAKE_MONO
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
37 MP3_Init(0);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
38 #else
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
39 MP3_Init();
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
40 #endif
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
41 MP3_samplerate=MP3_channels=0;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
42 len=MP3_DecodeFrame(buffer,-1);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
43
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
44 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
45 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
46 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
47 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
48 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
49 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
50
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
51 while(1){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
52 int len2;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
53 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
54 if(len<=0) break; // EOF
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
55
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
56 // play it
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
57 len2=write(audio_fd,buffer,len);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
58 if(len2<0) break; // ERROR?
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
59 len-=len2; total+=len2;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
60 if(len>0){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
61 // this shouldn't happen...
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
62 memcpy(buffer,buffer+len2,len);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
63 putchar('!');fflush(stdout);
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
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
67 fclose(mp3file);
26500
014bd7dffbf9 Add return statement, fixes the warning:
diego
parents: 26499
diff changeset
68 return 0;
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
69 }