annotate mp3lib/test2.c @ 29998:0dacb57a3d3e

Filter list of missing source files so that it only contains nonexisting files. Thus those files can be symlinked directly without testing if they exist.
author diego
date Mon, 14 Dec 2009 12:03:02 +0000
parents 0f1b5b68af32
children fee09b258e8a
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;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27341
diff changeset
29
789
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); }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27341
diff changeset
32
10343
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:
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26504
diff changeset
36 #ifdef CONFIG_FAKE_MONO
789
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);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27341
diff changeset
43
789
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);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27341
diff changeset
50
789
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
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27341
diff changeset
55
789
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 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27341
diff changeset
66
789
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 }