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"
27 static const ad_info_t info
=
29 "MPEG layer-2, layer-3",
33 "Optimized to MMX/SSE/3Dnow!"
38 #include "mp3lib/mp3.h"
42 static sh_audio_t
* dec_audio_sh
=NULL
;
44 // MP3 decoder buffer callback:
45 int mplayer_audio_read(char *buf
,int size
){
46 return demux_read_data(dec_audio_sh
->ds
,buf
,size
);
49 static int preinit(sh_audio_t
*sh
)
51 sh
->audio_out_minsize
=32*36*2*2; //4608;
55 static int init(sh_audio_t
*sh
)
58 dec_audio_sh
=sh
; // save sh_audio for the callback:
59 // MP3_Init(fakemono,mplayer_accel,&mplayer_audio_read); // TODO!!!
60 #ifdef CONFIG_FAKE_MONO
65 MP3_samplerate
=MP3_channels
=0;
66 sh
->a_buffer_len
=MP3_DecodeFrame(sh
->a_buffer
,-1);
67 if(!sh
->a_buffer_len
) return 0; // unsupported layer/format
68 sh
->channels
=2; // hack
70 sh
->samplerate
=MP3_samplerate
;
71 sh
->i_bps
=MP3_bitrate
*(1000/8);
76 static void uninit(sh_audio_t
*sh
)
80 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
84 case ADCTRL_RESYNC_STREAM
:
85 MP3_DecodeFrame(NULL
,-2); // resync
86 MP3_DecodeFrame(NULL
,-2); // resync
87 MP3_DecodeFrame(NULL
,-2); // resync
89 case ADCTRL_SKIP_FRAME
:
90 MP3_DecodeFrame(NULL
,-2); // skip MPEG frame
93 return CONTROL_UNKNOWN
;
96 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
98 return MP3_DecodeFrame(buf
,-1);