Mercurial > mplayer.hg
annotate mp3lib/test2.c @ 34834:2292b00862af
Only try to build vo gl with X11/win32 backends if these were detected.
Fixes compilation with --disable-x11 or when X11 headers
are available but not the libraries.
author | reimar |
---|---|
date | Fri, 18 May 2012 18:34:26 +0000 |
parents | 4a3c8f6ab63a |
children |
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" |
31339
4a3c8f6ab63a
Add ad_mp3lib.h #include for the mplayer_audio_read prototype.
diego
parents:
31338
diff
changeset
|
29 #include "libmpcodecs/ad_mp3lib.h" |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
30 #include "mp3lib/mp3.h" |
10343 | 31 #include "cpudetect.h" |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
32 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
33 static FILE* mp3file=NULL; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
34 |
31338
4f1740bd1cb3
Revert marking mplayer_audio_read() as static; it is used from linked .o files.
diego
parents:
31330
diff
changeset
|
35 int mplayer_audio_read(char *buf, int size) |
31330
1c789a1ad0f0
Mark mplayer_audio_read() function as static; it is not used outside the file.
diego
parents:
30452
diff
changeset
|
36 { |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
37 return fread(buf,1,size,mp3file); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
38 } |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
39 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
40 #define BUFFLEN 4608 |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
41 static unsigned char buffer[BUFFLEN]; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
42 |
10343 | 43 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
44 int main(int argc,char* argv[]){ |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
45 int len; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
46 int total=0; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
47 int r; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
48 int audio_fd; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
49 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
50 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
|
51 if(!mp3file){ printf("file not found\n"); exit(1); } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
52 |
10343 | 53 GetCpuCaps(&gCpuCaps); |
789
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 // MPEG Audio: |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26504
diff
changeset
|
56 #ifdef CONFIG_FAKE_MONO |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
57 MP3_Init(0); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
58 #else |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
59 MP3_Init(); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
60 #endif |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
61 MP3_samplerate=MP3_channels=0; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
62 len=MP3_DecodeFrame(buffer,-1); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
63 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
71 while(1){ |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
72 int len2; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
73 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
|
74 if(len<=0) break; // EOF |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
75 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
76 // play it |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
77 len2=write(audio_fd,buffer,len); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
78 if(len2<0) break; // ERROR? |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
79 len-=len2; total+=len2; |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
80 if(len>0){ |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
81 // this shouldn't happen... |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
82 memcpy(buffer,buffer+len2,len); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
83 putchar('!');fflush(stdout); |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
84 } |
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
85 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27341
diff
changeset
|
86 |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
87 fclose(mp3file); |
26500 | 88 return 0; |
789
989b921361d0
test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff
changeset
|
89 } |