2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "ad_internal.h"
26 #include "ad_mp3lib.h"
28 static const ad_info_t info
=
30 "MPEG layer-2, layer-3",
34 "Optimized to MMX/SSE/3Dnow!"
39 #include "mp3lib/mp3.h"
43 static sh_audio_t
* dec_audio_sh
=NULL
;
45 // MP3 decoder buffer callback:
46 int mplayer_audio_read(char *buf
,int size
){
47 return demux_read_data(dec_audio_sh
->ds
,buf
,size
);
50 static int preinit(sh_audio_t
*sh
)
52 sh
->audio_out_minsize
=32*36*2*2; //4608;
56 static int init(sh_audio_t
*sh
)
59 dec_audio_sh
=sh
; // save sh_audio for the callback:
60 // MP3_Init(fakemono,mplayer_accel,&mplayer_audio_read); // TODO!!!
61 #ifdef CONFIG_FAKE_MONO
66 MP3_samplerate
=MP3_channels
=0;
67 sh
->a_buffer_len
=MP3_DecodeFrame(sh
->a_buffer
,-1);
68 if(!sh
->a_buffer_len
) return 0; // unsupported layer/format
69 sh
->channels
=2; // hack
71 sh
->samplerate
=MP3_samplerate
;
72 sh
->i_bps
=MP3_bitrate
*(1000/8);
77 static void uninit(sh_audio_t
*sh
)
81 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
85 case ADCTRL_RESYNC_STREAM
:
86 MP3_DecodeFrame(NULL
,-2); // resync
87 MP3_DecodeFrame(NULL
,-2); // resync
88 MP3_DecodeFrame(NULL
,-2); // resync
90 case ADCTRL_SKIP_FRAME
:
91 MP3_DecodeFrame(NULL
,-2); // skip MPEG frame
94 return CONTROL_UNKNOWN
;
97 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
99 return MP3_DecodeFrame(buf
,-1);