Mercurial > mplayer.hg
annotate mp3lib/test2.c @ 30918:be200e917ae1
Remove unused OPTFLAGS variable from config.mak.
author | diego |
---|---|
date | Thu, 25 Mar 2010 19:53:05 +0000 |
parents | fee09b258e8a |
children | 1c789a1ad0f0 |
rev | line source |
---|---|
30452
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
1 /* |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
3 * |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
7 * (at your option) any later version. |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
8 * |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
13 * |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
17 */ |
fee09b258e8a
Add missing license headers to test programs for external libraries.
diego
parents:
29263
diff
changeset
|
18 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
19 #include <stdio.h> |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
20 #include <stdlib.h> |
26498 | 21 #include <string.h> |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
22 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
23 #include <fcntl.h> |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
24 #include <sys/ioctl.h> |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
25 #include <unistd.h> |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
26 #include <sys/soundcard.h> |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
27 |
26203 | 28 #include "config.h" |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
29 #include "mp3lib/mp3.h" |
10343 | 30 #include "cpudetect.h" |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
31 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
32 static FILE* mp3file=NULL; |
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 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
|
35 return fread(buf,1,size,mp3file); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
36 } |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
37 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
38 #define BUFFLEN 4608 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
39 static unsigned char buffer[BUFFLEN]; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
40 |
10343 | 41 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
42 int main(int argc,char* argv[]){ |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
43 int len; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
44 int total=0; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
45 int r; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
46 int audio_fd; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
47 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
48 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
|
49 if(!mp3file){ printf("file not found\n"); exit(1); } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
50 |
10343 | 51 GetCpuCaps(&gCpuCaps); |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
52 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
53 // MPEG Audio: |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26504
diff
changeset
|
54 #ifdef CONFIG_FAKE_MONO |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
55 MP3_Init(0); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
56 #else |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
57 MP3_Init(); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
58 #endif |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
59 MP3_samplerate=MP3_channels=0; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
60 len=MP3_DecodeFrame(buffer,-1); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
61 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
69 while(1){ |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
70 int len2; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
71 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
|
72 if(len<=0) break; // EOF |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
73 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
74 // play it |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
75 len2=write(audio_fd,buffer,len); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
76 if(len2<0) break; // ERROR? |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
77 len-=len2; total+=len2; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
78 if(len>0){ |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
79 // this shouldn't happen... |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
80 memcpy(buffer,buffer+len2,len); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
81 putchar('!');fflush(stdout); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
82 } |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
83 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
84 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
85 fclose(mp3file); |
26500 | 86 return 0; |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
87 } |