8 #include "ad_internal.h"
10 static ad_info_t info
=
12 "MPEG layer-2, layer-3",
16 "Optimized to MMX/SSE/3Dnow!"
21 #include "mp3lib/mp3.h"
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;
38 static int init(sh_audio_t
*sh
)
41 dec_audio_sh
=sh
; // save sh_audio for the callback:
42 // MP3_Init(fakemono,mplayer_accel,&mplayer_audio_read); // TODO!!!
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
53 sh
->samplerate
=MP3_samplerate
;
54 sh
->i_bps
=MP3_bitrate
*(1000/8);
59 static void uninit(sh_audio_t
*sh
)
63 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
67 case ADCTRL_RESYNC_STREAM
:
68 MP3_DecodeFrame(NULL
,-2); // resync
69 MP3_DecodeFrame(NULL
,-2); // resync
70 MP3_DecodeFrame(NULL
,-2); // resync
72 case ADCTRL_SKIP_FRAME
:
73 MP3_DecodeFrame(NULL
,-2); // skip MPEG frame
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);