Mercurial > mplayer.hg
annotate libmpcodecs/dec_audio.c @ 17279:600d0b740940
"Currently mplayer looks for only one MP3 frame sync. The attached
patch makes it to look for two consecutive valid MP3 frame headers,
reducing the probability of false positives, which causes Bug 380.
Funny that the fix is so simple. Seems that someone has forgotten to
initialize MP3_resync correctly.
Also this is the recommended way to sync MP3 frames. See
http://www.dv.co.yu/mpgscript/mpeghdr.htm. "
Original thread:
Date: Dec 31, 2005 10:15 AM
Subject: [MPlayer-dev-eng] [PATCH] Try twice when searching for MP3 frame header, fixes Bug 380
author | gpoirier |
---|---|
date | Sat, 31 Dec 2005 18:56:35 +0000 |
parents | 6ff3379a0862 |
children | ac53dc3093a7 |
rev | line source |
---|---|
5342 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <unistd.h> | |
4 | |
5 #include "config.h" | |
6 #include "mp_msg.h" | |
7 #include "help_mp.h" | |
8 | |
9 #include "stream.h" | |
10 #include "demuxer.h" | |
11 | |
12 #include "codec-cfg.h" | |
13 #include "stheader.h" | |
14 | |
15 #include "dec_audio.h" | |
16 #include "ad.h" | |
17012 | 17 #include "libaf/af_format.h" |
5342 | 18 |
17012 | 19 #include "libaf/af.h" |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
20 |
8152 | 21 #ifdef DYNAMIC_PLUGINS |
22 #include <dlfcn.h> | |
23 #endif | |
24 | |
5342 | 25 #ifdef USE_FAKE_MONO |
26 int fakemono=0; | |
27 #endif | |
28 /* used for ac3surround decoder - set using -channels option */ | |
29 int audio_output_channels = 2; | |
15950
4432bb25b13e
-af-adv force=1 is now default (and thus also lavcresample)
reimar
parents:
15811
diff
changeset
|
30 af_cfg_t af_cfg = {1, NULL}; // Configuration for audio filters |
5342 | 31 |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
32 void afm_help(){ |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
33 int i; |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
34 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_AvailableAudioFm); |
15789
32d9c8a0a02b
adds some more -identify output, patch by kiriuja < mplayer DASH patches PAM en DASH directo POUM net>
gpoirier
parents:
14819
diff
changeset
|
35 if (identify) |
32d9c8a0a02b
adds some more -identify output, patch by kiriuja < mplayer DASH patches PAM en DASH directo POUM net>
gpoirier
parents:
14819
diff
changeset
|
36 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_DRIVERS\n"); |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
37 mp_msg(MSGT_DECAUDIO,MSGL_INFO," afm: info: (comment)\n"); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
38 for (i=0; mpcodecs_ad_drivers[i] != NULL; i++) |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
39 if(mpcodecs_ad_drivers[i]->info->comment && mpcodecs_ad_drivers[i]->info->comment[0]) |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
40 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"%9s %s (%s)\n", |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
41 mpcodecs_ad_drivers[i]->info->short_name, |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
42 mpcodecs_ad_drivers[i]->info->name, |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
43 mpcodecs_ad_drivers[i]->info->comment); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
44 else |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
45 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"%9s %s\n", |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
46 mpcodecs_ad_drivers[i]->info->short_name, |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
47 mpcodecs_ad_drivers[i]->info->name); |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
48 } |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
49 |
7522 | 50 int init_audio_codec(sh_audio_t *sh_audio) |
5342 | 51 { |
14815
56fb33e23ad4
If -af-adv force=4 is in effect, use ADCTRL_QUERY_FORMAT to query the
hzoli
parents:
14814
diff
changeset
|
52 if ((af_cfg.force & AF_INIT_FORMAT_MASK) == AF_INIT_FLOAT) { |
56fb33e23ad4
If -af-adv force=4 is in effect, use ADCTRL_QUERY_FORMAT to query the
hzoli
parents:
14814
diff
changeset
|
53 int fmt = AF_FORMAT_FLOAT_NE; |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
54 if (sh_audio->ad_driver->control(sh_audio, ADCTRL_QUERY_FORMAT, |
14815
56fb33e23ad4
If -af-adv force=4 is in effect, use ADCTRL_QUERY_FORMAT to query the
hzoli
parents:
14814
diff
changeset
|
55 &fmt) == CONTROL_TRUE) { |
56fb33e23ad4
If -af-adv force=4 is in effect, use ADCTRL_QUERY_FORMAT to query the
hzoli
parents:
14814
diff
changeset
|
56 sh_audio->sample_format = fmt; |
56fb33e23ad4
If -af-adv force=4 is in effect, use ADCTRL_QUERY_FORMAT to query the
hzoli
parents:
14814
diff
changeset
|
57 sh_audio->samplesize = 4; |
56fb33e23ad4
If -af-adv force=4 is in effect, use ADCTRL_QUERY_FORMAT to query the
hzoli
parents:
14814
diff
changeset
|
58 } |
56fb33e23ad4
If -af-adv force=4 is in effect, use ADCTRL_QUERY_FORMAT to query the
hzoli
parents:
14814
diff
changeset
|
59 } |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
60 if(!sh_audio->ad_driver->preinit(sh_audio)) |
5342 | 61 { |
6989 | 62 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ADecoderPreinitFailed); |
5342 | 63 return 0; |
64 } | |
65 | |
5458 | 66 /* allocate audio in buffer: */ |
67 if(sh_audio->audio_in_minsize>0){ | |
68 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; | |
6989 | 69 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_AllocatingBytesForInputBuffer, |
5458 | 70 sh_audio->a_in_buffer_size); |
71 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
72 memset(sh_audio->a_in_buffer,0,sh_audio->a_in_buffer_size); | |
73 sh_audio->a_in_buffer_len=0; | |
74 } | |
75 | |
5342 | 76 /* allocate audio out buffer: */ |
77 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; /* worst case calc.*/ | |
78 | |
6989 | 79 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_AllocatingBytesForOutputBuffer, |
5342 | 80 sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size); |
81 | |
82 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size); | |
83 if(!sh_audio->a_buffer){ | |
84 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantAllocAudioBuf); | |
85 return 0; | |
86 } | |
87 memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size); | |
88 sh_audio->a_buffer_len=0; | |
89 | |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
90 if(!sh_audio->ad_driver->init(sh_audio)){ |
6989 | 91 mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_ADecoderInitFailed); |
5458 | 92 uninit_audio(sh_audio); // free buffers |
5342 | 93 return 0; |
94 } | |
5458 | 95 |
5342 | 96 sh_audio->inited=1; |
97 | |
98 if(!sh_audio->channels || !sh_audio->samplerate){ | |
99 mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_UnknownAudio); | |
5458 | 100 uninit_audio(sh_audio); // free buffers |
5342 | 101 return 0; |
102 } | |
103 | |
104 if(!sh_audio->o_bps) | |
105 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; | |
7522 | 106 |
14814 | 107 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"AUDIO: %d Hz, %d ch, %s, %3.1f kbit/%3.2f%% (ratio: %d->%d)\n", |
7522 | 108 sh_audio->samplerate,sh_audio->channels, |
14814 | 109 af_fmt2str_short(sh_audio->sample_format), |
110 sh_audio->i_bps*8*0.001,((float)sh_audio->i_bps/sh_audio->o_bps)*100.0, | |
111 sh_audio->i_bps,sh_audio->o_bps); | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
112 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
113 sh_audio->a_out_buffer_size=sh_audio->a_buffer_size; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
114 sh_audio->a_out_buffer=sh_audio->a_buffer; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
115 sh_audio->a_out_buffer_len=sh_audio->a_buffer_len; |
5458 | 116 |
117 return 1; | |
5342 | 118 } |
119 | |
7522 | 120 int init_audio(sh_audio_t *sh_audio,char* codecname,char* afm,int status){ |
121 unsigned int orig_fourcc=sh_audio->wf?sh_audio->wf->wFormatTag:0; | |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
122 int force = 0; |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
123 if (codecname && codecname[0] == '+') { |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
124 codecname = &codecname[1]; |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
125 force = 1; |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
126 } |
7522 | 127 sh_audio->codec=NULL; |
128 while(1){ | |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
129 ad_functions_t* mpadec; |
7522 | 130 int i; |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
131 sh_audio->ad_driver = 0; |
7522 | 132 // restore original fourcc: |
133 if(sh_audio->wf) sh_audio->wf->wFormatTag=i=orig_fourcc; | |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
134 if(!(sh_audio->codec=find_audio_codec(sh_audio->format, |
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
135 sh_audio->wf?(&i):NULL, sh_audio->codec, force) )) break; |
7522 | 136 if(sh_audio->wf) sh_audio->wf->wFormatTag=i; |
137 // ok we found one codec | |
138 if(sh_audio->codec->flags&CODECS_FLAG_SELECTED) continue; // already tried & failed | |
139 if(codecname && strcmp(sh_audio->codec->name,codecname)) continue; // -ac | |
140 if(afm && strcmp(sh_audio->codec->drv,afm)) continue; // afm doesn't match | |
16321
efbfac98cab1
Allow forcing of demuxers and codecs by prepending '+'
reimar
parents:
16306
diff
changeset
|
141 if(!force && sh_audio->codec->status<status) continue; // too unstable |
7522 | 142 sh_audio->codec->flags|=CODECS_FLAG_SELECTED; // tagging it |
143 // ok, it matches all rules, let's find the driver! | |
144 for (i=0; mpcodecs_ad_drivers[i] != NULL; i++) | |
145 if(!strcmp(mpcodecs_ad_drivers[i]->info->short_name,sh_audio->codec->drv)) break; | |
146 mpadec=mpcodecs_ad_drivers[i]; | |
8152 | 147 #ifdef DYNAMIC_PLUGINS |
148 if (!mpadec) | |
149 { | |
150 /* try to open shared decoder plugin */ | |
151 int buf_len; | |
152 char *buf; | |
153 ad_functions_t *funcs_sym; | |
154 ad_info_t *info_sym; | |
155 | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9132
diff
changeset
|
156 buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_audio->codec->drv)+16; |
8152 | 157 buf = malloc(buf_len); |
158 if (!buf) | |
159 break; | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9132
diff
changeset
|
160 snprintf(buf, buf_len, "%s/mplayer/ad_%s.so", MPLAYER_LIBDIR, sh_audio->codec->drv); |
8152 | 161 mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf); |
162 sh_audio->dec_handle = dlopen(buf, RTLD_LAZY); | |
163 if (!sh_audio->dec_handle) | |
164 break; | |
165 snprintf(buf, buf_len, "mpcodecs_ad_%s", sh_audio->codec->drv); | |
166 funcs_sym = dlsym(sh_audio->dec_handle, buf); | |
167 if (!funcs_sym || !funcs_sym->info || !funcs_sym->preinit || | |
168 !funcs_sym->init || !funcs_sym->uninit || !funcs_sym->control || | |
169 !funcs_sym->decode_audio) | |
170 break; | |
171 info_sym = funcs_sym->info; | |
172 if (strcmp(info_sym->short_name, sh_audio->codec->drv)) | |
173 break; | |
174 free(buf); | |
175 mpadec = funcs_sym; | |
176 mp_msg(MSGT_DECAUDIO, MSGL_V, "Using external decoder plugin (%s/mplayer/ad_%s.so)!\n", | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9132
diff
changeset
|
177 MPLAYER_LIBDIR, sh_audio->codec->drv); |
8152 | 178 } |
179 #endif | |
7522 | 180 if(!mpadec){ // driver not available (==compiled in) |
181 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_AudioCodecFamilyNotAvailableStr, | |
182 sh_audio->codec->name, sh_audio->codec->drv); | |
183 continue; | |
184 } | |
185 // it's available, let's try to init! | |
186 // init() | |
187 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_OpeningAudioDecoder,mpadec->info->short_name,mpadec->info->name); | |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
188 sh_audio->ad_driver = mpadec; |
7522 | 189 if(!init_audio_codec(sh_audio)){ |
190 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_ADecoderInitFailed); | |
191 continue; // try next... | |
192 } | |
193 // Yeah! We got it! | |
194 return 1; | |
195 } | |
196 return 0; | |
197 } | |
198 | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
199 extern char *get_path(char *filename); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
200 |
7522 | 201 int init_best_audio_codec(sh_audio_t *sh_audio,char** audio_codec_list,char** audio_fm_list){ |
202 char* ac_l_default[2]={"",(char*)NULL}; | |
203 // hack: | |
204 if(!audio_codec_list) audio_codec_list=ac_l_default; | |
205 // Go through the codec.conf and find the best codec... | |
206 sh_audio->inited=0; | |
207 codecs_reset_selection(1); | |
208 while(!sh_audio->inited && *audio_codec_list){ | |
209 char* audio_codec=*(audio_codec_list++); | |
210 if(audio_codec[0]){ | |
211 if(audio_codec[0]=='-'){ | |
212 // disable this codec: | |
213 select_codec(audio_codec+1,1); | |
214 } else { | |
215 // forced codec by name: | |
216 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_ForcedAudioCodec,audio_codec); | |
217 init_audio(sh_audio,audio_codec,NULL,-1); | |
218 } | |
219 } else { | |
220 int status; | |
221 // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING. | |
222 if(audio_fm_list){ | |
223 char** fmlist=audio_fm_list; | |
224 // try first the preferred codec families: | |
225 while(!sh_audio->inited && *fmlist){ | |
226 char* audio_fm=*(fmlist++); | |
227 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_TryForceAudioFmtStr,audio_fm); | |
228 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) | |
229 if(init_audio(sh_audio,NULL,audio_fm,status)) break; | |
230 } | |
231 } | |
232 if(!sh_audio->inited) | |
233 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) | |
234 if(init_audio(sh_audio,NULL,NULL,status)) break; | |
235 } | |
236 } | |
237 | |
238 if(!sh_audio->inited){ | |
239 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantFindAudioCodec,sh_audio->format); | |
10683 | 240 mp_msg(MSGT_DECAUDIO,MSGL_HINT, MSGTR_RTFMCodecs); |
7522 | 241 return 0; // failed |
242 } | |
243 | |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16321
diff
changeset
|
244 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_SelectedAudioCodec, |
7522 | 245 sh_audio->codec->name,sh_audio->codec->drv,sh_audio->codec->info); |
246 return 1; // success | |
247 } | |
248 | |
5342 | 249 void uninit_audio(sh_audio_t *sh_audio) |
250 { | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
251 if(sh_audio->afilter){ |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
252 mp_msg(MSGT_DECAUDIO,MSGL_V,"Uninit audio filters...\n"); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
253 af_uninit(sh_audio->afilter); |
10803 | 254 free(sh_audio->afilter); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
255 sh_audio->afilter=NULL; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
256 } |
7240 | 257 if(sh_audio->inited){ |
258 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_UninitAudioStr,sh_audio->codec->drv); | |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
259 sh_audio->ad_driver->uninit(sh_audio); |
8152 | 260 #ifdef DYNAMIC_PLUGINS |
261 if (sh_audio->dec_handle) | |
262 dlclose(sh_audio->dec_handle); | |
263 #endif | |
7240 | 264 sh_audio->inited=0; |
265 } | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
266 if(sh_audio->a_out_buffer!=sh_audio->a_buffer) free(sh_audio->a_out_buffer); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
267 sh_audio->a_out_buffer=NULL; |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
268 sh_audio->a_out_buffer_size=0; |
5458 | 269 if(sh_audio->a_buffer) free(sh_audio->a_buffer); |
270 sh_audio->a_buffer=NULL; | |
271 if(sh_audio->a_in_buffer) free(sh_audio->a_in_buffer); | |
272 sh_audio->a_in_buffer=NULL; | |
5342 | 273 } |
274 | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
275 /* Init audio filters */ |
8995
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
276 int preinit_audio_filters(sh_audio_t *sh_audio, |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
277 int in_samplerate, int in_channels, int in_format, |
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
278 int* out_samplerate, int* out_channels, int* out_format){ |
16306 | 279 return init_audio_filters(sh_audio, in_samplerate, in_channels, in_format, |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
280 out_samplerate, out_channels, out_format, 0, 0); |
8995
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
281 } |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
282 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
283 /* Init audio filters */ |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
284 int init_audio_filters(sh_audio_t *sh_audio, |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
285 int in_samplerate, int in_channels, int in_format, |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
286 int *out_samplerate, int *out_channels, int *out_format, |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
287 int out_minsize, int out_maxsize){ |
8995
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
288 af_stream_t* afs=sh_audio->afilter; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
289 if(!afs){ |
9018 | 290 afs = (af_stream_t*)malloc(sizeof(af_stream_t)); |
8995
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
291 memset(afs,0,sizeof(af_stream_t)); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
292 } |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
293 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
294 // input format: same as codec's output format: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
295 afs->input.rate = in_samplerate; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
296 afs->input.nch = in_channels; |
14245 | 297 afs->input.format = in_format; |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
298 af_fix_parameters(&(afs->input)); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
299 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
300 // output format: same as ao driver's input format (if missing, fallback to input) |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
301 afs->output.rate = *out_samplerate; |
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
302 afs->output.nch = *out_channels; |
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
303 afs->output.format = *out_format; |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
304 af_fix_parameters(&(afs->output)); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
305 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
306 // filter config: |
7614 | 307 memcpy(&afs->cfg,&af_cfg,sizeof(af_cfg_t)); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
308 |
16793
8d4fb5469efb
Make a few more messages translatable by moving them into help_mp-en.h.
diego
parents:
16321
diff
changeset
|
309 mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_BuildingAudioFilterChain, |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
310 afs->input.rate,afs->input.nch,af_fmt2str_short(afs->input.format), |
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
311 afs->output.rate,afs->output.nch,af_fmt2str_short(afs->output.format)); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
312 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
313 // let's autoprobe it! |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
314 if(0 != af_init(afs)){ |
9132 | 315 sh_audio->afilter=NULL; |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
316 free(afs); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
317 return 0; // failed :( |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
318 } |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
319 |
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
320 *out_samplerate=afs->output.rate; |
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
321 *out_channels=afs->output.nch; |
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
322 *out_format=afs->output.format; |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
323 |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
324 if (out_maxsize || out_minsize) { |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
325 // allocate the a_out_* buffers: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
326 if(out_maxsize<out_minsize) out_maxsize=out_minsize; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
327 if(out_maxsize<8192) out_maxsize=MAX_OUTBURST; // not sure this is ok |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
328 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
329 sh_audio->a_out_buffer_size=out_maxsize; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
330 sh_audio->a_out_buffer=malloc(sh_audio->a_out_buffer_size); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
331 memset(sh_audio->a_out_buffer,0,sh_audio->a_out_buffer_size); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
332 sh_audio->a_out_buffer_len=0; |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
15789
diff
changeset
|
333 } |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
334 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
335 // ok! |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
336 sh_audio->afilter=(void*)afs; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
337 return 1; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
338 } |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
339 |
5342 | 340 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) |
341 { | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
342 int declen; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
343 af_data_t afd; // filter input |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
344 af_data_t* pafd; // filter output |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
345 ad_functions_t* mpadec = sh_audio->ad_driver; |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
346 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
347 if(!sh_audio->inited) return -1; // no codec |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
348 if(!sh_audio->afilter){ |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
349 // no filter, just decode: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
350 // FIXME: don't drop initial decoded data in a_buffer! |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
351 return mpadec->decode_audio(sh_audio,buf,minlen,maxlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
352 } |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
353 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
354 // declen=af_inputlen(sh_audio->afilter,minlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
355 declen=af_calc_insize_constrained(sh_audio->afilter,minlen,maxlen, |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
356 sh_audio->a_buffer_size-sh_audio->audio_out_minsize); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
357 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
358 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\ndecaudio: minlen=%d maxlen=%d declen=%d (max=%d)\n", |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
359 minlen, maxlen, declen, sh_audio->a_buffer_size); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
360 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
361 if(declen<=0) return -1; // error! |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
362 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
363 // limit declen to buffer size: - DONE by af_calc_insize_constrained |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
364 // if(declen>sh_audio->a_buffer_size) declen=sh_audio->a_buffer_size; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
365 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
366 // decode if needed: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
367 while(declen>sh_audio->a_buffer_len){ |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
368 int len=declen-sh_audio->a_buffer_len; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
369 int maxlen=sh_audio->a_buffer_size-sh_audio->a_buffer_len; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
370 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
371 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"decaudio: decoding %d bytes, max: %d (%d)\n", |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
372 len, maxlen, sh_audio->audio_out_minsize); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
373 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
374 if(maxlen<sh_audio->audio_out_minsize) break; // don't overflow buffer! |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
375 // not enough decoded data waiting, decode 'len' bytes more: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
376 len=mpadec->decode_audio(sh_audio, |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
377 sh_audio->a_buffer+sh_audio->a_buffer_len, len, maxlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
378 if(len<=0) break; // EOF? |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
379 sh_audio->a_buffer_len+=len; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
380 } |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
381 if(declen>sh_audio->a_buffer_len) |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
382 declen=sh_audio->a_buffer_len; // still no enough data (EOF) :( |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
383 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
384 // round to whole samples: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
385 // declen/=sh_audio->samplesize*sh_audio->channels; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
386 // declen*=sh_audio->samplesize*sh_audio->channels; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
387 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
388 // run the filters: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
389 afd.audio=sh_audio->a_buffer; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
390 afd.len=declen; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
391 afd.rate=sh_audio->samplerate; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
392 afd.nch=sh_audio->channels; |
14245 | 393 afd.format=sh_audio->sample_format; |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
394 af_fix_parameters(&afd); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
395 //pafd=&afd; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
396 // printf("\nAF: %d --> ",declen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
397 pafd=af_play(sh_audio->afilter,&afd); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
398 // printf("%d \n",pafd->len); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
399 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
400 if(!pafd) return -1; // error |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
401 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
402 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"decaudio: declen=%d out=%d (max %d)\n", |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
403 declen, pafd->len, maxlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
404 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
405 // copy filter==>out: |
11857
6107e58dcc28
not pretty, but at least it prevents the channels from getting out of order...
rfelker
parents:
11855
diff
changeset
|
406 if(maxlen < pafd->len) { |
6107e58dcc28
not pretty, but at least it prevents the channels from getting out of order...
rfelker
parents:
11855
diff
changeset
|
407 maxlen -= maxlen % (sh_audio->channels * sh_audio->samplesize); |
11855 | 408 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"%i bytes of audio data lost due to buffer overflow, len = %i\n", pafd->len - maxlen,pafd->len); |
11857
6107e58dcc28
not pretty, but at least it prevents the channels from getting out of order...
rfelker
parents:
11855
diff
changeset
|
409 } |
5342 | 410 else |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
411 maxlen=pafd->len; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
412 memmove(buf, pafd->audio, maxlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
413 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
414 // remove processed data from decoder buffer: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
415 sh_audio->a_buffer_len-=declen; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
416 if(sh_audio->a_buffer_len>0) |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
417 memmove(sh_audio->a_buffer, sh_audio->a_buffer+declen, sh_audio->a_buffer_len); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
418 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
419 return maxlen; |
5342 | 420 } |
421 | |
422 void resync_audio_stream(sh_audio_t *sh_audio) | |
423 { | |
6049 | 424 sh_audio->a_in_buffer_len=0; // clear audio input buffer |
5342 | 425 if(!sh_audio->inited) return; |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
426 sh_audio->ad_driver->control(sh_audio,ADCTRL_RESYNC_STREAM,NULL); |
5342 | 427 } |
428 | |
429 void skip_audio_frame(sh_audio_t *sh_audio) | |
430 { | |
431 if(!sh_audio->inited) return; | |
14819
601e2c8a2922
Remove file-global mpadec, add ad_driver member to sh_audio_t instead.
hzoli
parents:
14818
diff
changeset
|
432 if(sh_audio->ad_driver->control(sh_audio,ADCTRL_SKIP_FRAME,NULL)==CONTROL_TRUE) return; |
5342 | 433 // default skip code: |
434 ds_fill_buffer(sh_audio->ds); // skip block | |
435 } | |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
436 |
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
437 void adjust_volume() |
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
438 { |
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14815
diff
changeset
|
439 } |