comparison mp3lib/test2.c @ 29263:0f1b5b68af32

whitespace cosmetics: Remove all trailing whitespace.
author diego
date Wed, 13 May 2009 02:58:57 +0000
parents e7c989f7a7c9
children fee09b258e8a
comparison
equal deleted inserted replaced
29262:7d545a6b8aff 29263:0f1b5b68af32
24 int main(int argc,char* argv[]){ 24 int main(int argc,char* argv[]){
25 int len; 25 int len;
26 int total=0; 26 int total=0;
27 int r; 27 int r;
28 int audio_fd; 28 int audio_fd;
29 29
30 mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb"); 30 mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
31 if(!mp3file){ printf("file not found\n"); exit(1); } 31 if(!mp3file){ printf("file not found\n"); exit(1); }
32 32
33 GetCpuCaps(&gCpuCaps); 33 GetCpuCaps(&gCpuCaps);
34 34
35 // MPEG Audio: 35 // MPEG Audio:
36 #ifdef CONFIG_FAKE_MONO 36 #ifdef CONFIG_FAKE_MONO
37 MP3_Init(0); 37 MP3_Init(0);
38 #else 38 #else
39 MP3_Init(); 39 MP3_Init();
40 #endif 40 #endif
41 MP3_samplerate=MP3_channels=0; 41 MP3_samplerate=MP3_channels=0;
42 len=MP3_DecodeFrame(buffer,-1); 42 len=MP3_DecodeFrame(buffer,-1);
43 43
44 audio_fd=open("/dev/dsp", O_WRONLY); 44 audio_fd=open("/dev/dsp", O_WRONLY);
45 if(audio_fd<0){ printf("Can't open audio device\n");exit(1); } 45 if(audio_fd<0){ printf("Can't open audio device\n");exit(1); }
46 r=AFMT_S16_LE;ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r); 46 r=AFMT_S16_LE;ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r);
47 r=MP3_channels-1;ioctl (audio_fd, SNDCTL_DSP_STEREO, &r); 47 r=MP3_channels-1;ioctl (audio_fd, SNDCTL_DSP_STEREO, &r);
48 r=MP3_samplerate;ioctl (audio_fd, SNDCTL_DSP_SPEED, &r); 48 r=MP3_samplerate;ioctl (audio_fd, SNDCTL_DSP_SPEED, &r);
49 printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,MP3_samplerate); 49 printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,MP3_samplerate);
50 50
51 while(1){ 51 while(1){
52 int len2; 52 int len2;
53 if(len==0) len=MP3_DecodeFrame(buffer,-1); 53 if(len==0) len=MP3_DecodeFrame(buffer,-1);
54 if(len<=0) break; // EOF 54 if(len<=0) break; // EOF
55 55
56 // play it 56 // play it
57 len2=write(audio_fd,buffer,len); 57 len2=write(audio_fd,buffer,len);
58 if(len2<0) break; // ERROR? 58 if(len2<0) break; // ERROR?
59 len-=len2; total+=len2; 59 len-=len2; total+=len2;
60 if(len>0){ 60 if(len>0){
61 // this shouldn't happen... 61 // this shouldn't happen...
62 memcpy(buffer,buffer+len2,len); 62 memcpy(buffer,buffer+len2,len);
63 putchar('!');fflush(stdout); 63 putchar('!');fflush(stdout);
64 } 64 }
65 } 65 }
66 66
67 fclose(mp3file); 67 fclose(mp3file);
68 return 0; 68 return 0;
69 } 69 }