typo fixes
[mplayer/greg.git] / libmpcodecs / ad_mp3lib.c
blob2605bb08f210f3a0757f60c3ebedc18bf06a32e1
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
5 #include "config.h"
6 #ifdef USE_MP3LIB
8 #include "ad_internal.h"
10 static ad_info_t info =
12 "MPEG layer-2, layer-3",
13 "mp3lib",
14 "Nick Kurshev",
15 "mpg123",
16 "Optimized to MMX/SSE/3Dnow!"
19 LIBAD_EXTERN(mp3lib)
21 #include "mp3lib/mp3.h"
23 extern int fakemono;
25 static sh_audio_t* dec_audio_sh=NULL;
27 // MP3 decoder buffer callback:
28 int mplayer_audio_read(char *buf,int size){
29 return demux_read_data(dec_audio_sh->ds,buf,size);
32 static int preinit(sh_audio_t *sh)
34 sh->audio_out_minsize=32*36*2*2; //4608;
35 return 1;
38 static int init(sh_audio_t *sh)
40 // MPEG Audio:
41 dec_audio_sh=sh; // save sh_audio for the callback:
42 // MP3_Init(fakemono,mplayer_accel,&mplayer_audio_read); // TODO!!!
43 #ifdef USE_FAKE_MONO
44 MP3_Init(fakemono);
45 #else
46 MP3_Init();
47 #endif
48 MP3_samplerate=MP3_channels=0;
49 sh->a_buffer_len=MP3_DecodeFrame(sh->a_buffer,-1);
50 if(!sh->a_buffer_len) return 0; // unsupported layer/format
51 sh->channels=2; // hack
52 sh->samplesize=2;
53 sh->samplerate=MP3_samplerate;
54 sh->i_bps=MP3_bitrate*(1000/8);
55 MP3_PrintHeader();
56 return 1;
59 static void uninit(sh_audio_t *sh)
63 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
65 switch(cmd)
67 case ADCTRL_RESYNC_STREAM:
68 MP3_DecodeFrame(NULL,-2); // resync
69 MP3_DecodeFrame(NULL,-2); // resync
70 MP3_DecodeFrame(NULL,-2); // resync
71 return CONTROL_TRUE;
72 case ADCTRL_SKIP_FRAME:
73 MP3_DecodeFrame(NULL,-2); // skip MPEG frame
74 return CONTROL_TRUE;
76 return CONTROL_UNKNOWN;
79 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
81 return MP3_DecodeFrame(buf,-1);
83 #endif