7 #include "ad_internal.h"
9 static ad_info_t info
=
11 "MPEG layer-2, layer-3",
15 "Optimized to MMX/SSE/3Dnow!"
20 #include "mp3lib/mp3.h"
24 static sh_audio_t
* dec_audio_sh
=NULL
;
26 // MP3 decoder buffer callback:
27 int mplayer_audio_read(char *buf
,int size
){
28 return demux_read_data(dec_audio_sh
->ds
,buf
,size
);
31 static int preinit(sh_audio_t
*sh
)
33 sh
->audio_out_minsize
=32*36*2*2; //4608;
37 static int init(sh_audio_t
*sh
)
40 dec_audio_sh
=sh
; // save sh_audio for the callback:
41 // MP3_Init(fakemono,mplayer_accel,&mplayer_audio_read); // TODO!!!
42 #ifdef CONFIG_FAKE_MONO
47 MP3_samplerate
=MP3_channels
=0;
48 sh
->a_buffer_len
=MP3_DecodeFrame(sh
->a_buffer
,-1);
49 if(!sh
->a_buffer_len
) return 0; // unsupported layer/format
50 sh
->channels
=2; // hack
52 sh
->samplerate
=MP3_samplerate
;
53 sh
->i_bps
=MP3_bitrate
*(1000/8);
58 static void uninit(sh_audio_t
*sh
)
62 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
66 case ADCTRL_RESYNC_STREAM
:
67 MP3_DecodeFrame(NULL
,-2); // resync
68 MP3_DecodeFrame(NULL
,-2); // resync
69 MP3_DecodeFrame(NULL
,-2); // resync
71 case ADCTRL_SKIP_FRAME
:
72 MP3_DecodeFrame(NULL
,-2); // skip MPEG frame
75 return CONTROL_UNKNOWN
;
78 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
80 return MP3_DecodeFrame(buf
,-1);