Mercurial > mplayer.hg
annotate libmpcodecs/dec_audio.c @ 13935:20d243a3c398
keep screensaver off when playing multiple files.
patch by rgselknospam (at) yahoo [dot] com.
author | reimar |
---|---|
date | Sun, 14 Nov 2004 11:36:40 +0000 |
parents | c605df89ca9f |
children | d9bdae1d1c04 |
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" | |
17 #include "../libao2/afmt.h" | |
18 | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
19 #include "../libaf/af.h" |
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; | |
7614 | 30 af_cfg_t af_cfg; // Configuration for audio filters |
5342 | 31 |
32 static ad_functions_t* mpadec; | |
33 | |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
34 void afm_help(){ |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
35 int i; |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
36 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_AvailableAudioFm); |
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 { |
52 if(!mpadec->preinit(sh_audio)) | |
53 { | |
6989 | 54 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ADecoderPreinitFailed); |
5342 | 55 return 0; |
56 } | |
57 | |
5458 | 58 /* allocate audio in buffer: */ |
59 if(sh_audio->audio_in_minsize>0){ | |
60 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; | |
6989 | 61 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_AllocatingBytesForInputBuffer, |
5458 | 62 sh_audio->a_in_buffer_size); |
63 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
64 memset(sh_audio->a_in_buffer,0,sh_audio->a_in_buffer_size); | |
65 sh_audio->a_in_buffer_len=0; | |
66 } | |
67 | |
5342 | 68 /* allocate audio out buffer: */ |
69 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; /* worst case calc.*/ | |
70 | |
6989 | 71 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_AllocatingBytesForOutputBuffer, |
5342 | 72 sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size); |
73 | |
74 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size); | |
75 if(!sh_audio->a_buffer){ | |
76 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantAllocAudioBuf); | |
77 return 0; | |
78 } | |
79 memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size); | |
80 sh_audio->a_buffer_len=0; | |
81 | |
82 if(!mpadec->init(sh_audio)){ | |
6989 | 83 mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_ADecoderInitFailed); |
5458 | 84 uninit_audio(sh_audio); // free buffers |
5342 | 85 return 0; |
86 } | |
5458 | 87 |
5342 | 88 sh_audio->inited=1; |
89 | |
90 if(!sh_audio->channels || !sh_audio->samplerate){ | |
91 mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_UnknownAudio); | |
5458 | 92 uninit_audio(sh_audio); // free buffers |
5342 | 93 return 0; |
94 } | |
95 | |
96 if(!sh_audio->o_bps) | |
97 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; | |
7522 | 98 |
7561 | 99 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"AUDIO: %d Hz, %d ch, %d bit (0x%X), ratio: %d->%d (%3.1f kbit)\n", |
7522 | 100 sh_audio->samplerate,sh_audio->channels, |
7561 | 101 sh_audio->samplesize*8,sh_audio->sample_format, |
7522 | 102 sh_audio->i_bps,sh_audio->o_bps,sh_audio->i_bps*8*0.001); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
103 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
104 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
|
105 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
|
106 sh_audio->a_out_buffer_len=sh_audio->a_buffer_len; |
5458 | 107 |
108 return 1; | |
5342 | 109 } |
110 | |
7522 | 111 int init_audio(sh_audio_t *sh_audio,char* codecname,char* afm,int status){ |
112 unsigned int orig_fourcc=sh_audio->wf?sh_audio->wf->wFormatTag:0; | |
113 sh_audio->codec=NULL; | |
114 while(1){ | |
115 int i; | |
116 // restore original fourcc: | |
117 if(sh_audio->wf) sh_audio->wf->wFormatTag=i=orig_fourcc; | |
118 if(!(sh_audio->codec=find_codec(sh_audio->format, | |
119 sh_audio->wf?(&i):NULL, sh_audio->codec,1) )) break; | |
120 if(sh_audio->wf) sh_audio->wf->wFormatTag=i; | |
121 // ok we found one codec | |
122 if(sh_audio->codec->flags&CODECS_FLAG_SELECTED) continue; // already tried & failed | |
123 if(codecname && strcmp(sh_audio->codec->name,codecname)) continue; // -ac | |
124 if(afm && strcmp(sh_audio->codec->drv,afm)) continue; // afm doesn't match | |
125 if(sh_audio->codec->status<status) continue; // too unstable | |
126 sh_audio->codec->flags|=CODECS_FLAG_SELECTED; // tagging it | |
127 // ok, it matches all rules, let's find the driver! | |
128 for (i=0; mpcodecs_ad_drivers[i] != NULL; i++) | |
129 if(!strcmp(mpcodecs_ad_drivers[i]->info->short_name,sh_audio->codec->drv)) break; | |
130 mpadec=mpcodecs_ad_drivers[i]; | |
8152 | 131 #ifdef DYNAMIC_PLUGINS |
132 if (!mpadec) | |
133 { | |
134 /* try to open shared decoder plugin */ | |
135 int buf_len; | |
136 char *buf; | |
137 ad_functions_t *funcs_sym; | |
138 ad_info_t *info_sym; | |
139 | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9132
diff
changeset
|
140 buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_audio->codec->drv)+16; |
8152 | 141 buf = malloc(buf_len); |
142 if (!buf) | |
143 break; | |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9132
diff
changeset
|
144 snprintf(buf, buf_len, "%s/mplayer/ad_%s.so", MPLAYER_LIBDIR, sh_audio->codec->drv); |
8152 | 145 mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf); |
146 sh_audio->dec_handle = dlopen(buf, RTLD_LAZY); | |
147 if (!sh_audio->dec_handle) | |
148 break; | |
149 snprintf(buf, buf_len, "mpcodecs_ad_%s", sh_audio->codec->drv); | |
150 funcs_sym = dlsym(sh_audio->dec_handle, buf); | |
151 if (!funcs_sym || !funcs_sym->info || !funcs_sym->preinit || | |
152 !funcs_sym->init || !funcs_sym->uninit || !funcs_sym->control || | |
153 !funcs_sym->decode_audio) | |
154 break; | |
155 info_sym = funcs_sym->info; | |
156 if (strcmp(info_sym->short_name, sh_audio->codec->drv)) | |
157 break; | |
158 free(buf); | |
159 mpadec = funcs_sym; | |
160 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
|
161 MPLAYER_LIBDIR, sh_audio->codec->drv); |
8152 | 162 } |
163 #endif | |
7522 | 164 if(!mpadec){ // driver not available (==compiled in) |
165 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_AudioCodecFamilyNotAvailableStr, | |
166 sh_audio->codec->name, sh_audio->codec->drv); | |
167 continue; | |
168 } | |
169 // it's available, let's try to init! | |
170 // init() | |
171 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_OpeningAudioDecoder,mpadec->info->short_name,mpadec->info->name); | |
172 if(!init_audio_codec(sh_audio)){ | |
173 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_ADecoderInitFailed); | |
174 continue; // try next... | |
175 } | |
176 // Yeah! We got it! | |
177 return 1; | |
178 } | |
179 return 0; | |
180 } | |
181 | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
182 extern char *get_path(char *filename); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
183 |
7522 | 184 int init_best_audio_codec(sh_audio_t *sh_audio,char** audio_codec_list,char** audio_fm_list){ |
185 char* ac_l_default[2]={"",(char*)NULL}; | |
186 // hack: | |
187 if(!audio_codec_list) audio_codec_list=ac_l_default; | |
188 // Go through the codec.conf and find the best codec... | |
189 sh_audio->inited=0; | |
190 codecs_reset_selection(1); | |
191 while(!sh_audio->inited && *audio_codec_list){ | |
192 char* audio_codec=*(audio_codec_list++); | |
193 if(audio_codec[0]){ | |
194 if(audio_codec[0]=='-'){ | |
195 // disable this codec: | |
196 select_codec(audio_codec+1,1); | |
197 } else { | |
198 // forced codec by name: | |
199 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_ForcedAudioCodec,audio_codec); | |
200 init_audio(sh_audio,audio_codec,NULL,-1); | |
201 } | |
202 } else { | |
203 int status; | |
204 // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING. | |
205 if(audio_fm_list){ | |
206 char** fmlist=audio_fm_list; | |
207 // try first the preferred codec families: | |
208 while(!sh_audio->inited && *fmlist){ | |
209 char* audio_fm=*(fmlist++); | |
210 mp_msg(MSGT_DECAUDIO,MSGL_INFO,MSGTR_TryForceAudioFmtStr,audio_fm); | |
211 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) | |
212 if(init_audio(sh_audio,NULL,audio_fm,status)) break; | |
213 } | |
214 } | |
215 if(!sh_audio->inited) | |
216 for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) | |
217 if(init_audio(sh_audio,NULL,NULL,status)) break; | |
218 } | |
219 } | |
220 | |
221 if(!sh_audio->inited){ | |
222 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantFindAudioCodec,sh_audio->format); | |
10683 | 223 mp_msg(MSGT_DECAUDIO,MSGL_HINT, MSGTR_RTFMCodecs); |
7522 | 224 return 0; // failed |
225 } | |
226 | |
227 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Selected audio codec: [%s] afm:%s (%s)\n", | |
228 sh_audio->codec->name,sh_audio->codec->drv,sh_audio->codec->info); | |
229 return 1; // success | |
230 } | |
231 | |
5342 | 232 void uninit_audio(sh_audio_t *sh_audio) |
233 { | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
234 if(sh_audio->afilter){ |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
235 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
|
236 af_uninit(sh_audio->afilter); |
10803 | 237 free(sh_audio->afilter); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
238 sh_audio->afilter=NULL; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
239 } |
7240 | 240 if(sh_audio->inited){ |
241 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_UninitAudioStr,sh_audio->codec->drv); | |
242 mpadec->uninit(sh_audio); | |
8152 | 243 #ifdef DYNAMIC_PLUGINS |
244 if (sh_audio->dec_handle) | |
245 dlclose(sh_audio->dec_handle); | |
246 #endif | |
7240 | 247 sh_audio->inited=0; |
248 } | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
249 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
|
250 sh_audio->a_out_buffer=NULL; |
5458 | 251 if(sh_audio->a_buffer) free(sh_audio->a_buffer); |
252 sh_audio->a_buffer=NULL; | |
253 if(sh_audio->a_in_buffer) free(sh_audio->a_in_buffer); | |
254 sh_audio->a_in_buffer=NULL; | |
5342 | 255 } |
256 | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
257 /* Init audio filters */ |
8995
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
258 int preinit_audio_filters(sh_audio_t *sh_audio, |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
259 int in_samplerate, int in_channels, int in_format, int in_bps, |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
260 int* out_samplerate, int* out_channels, int* out_format, int out_bps){ |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
261 char strbuf[200]; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
262 af_stream_t* afs=malloc(sizeof(af_stream_t)); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
263 memset(afs,0,sizeof(af_stream_t)); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
264 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
265 // input format: same as codec's output format: |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
266 afs->input.rate = in_samplerate; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
267 afs->input.nch = in_channels; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
268 afs->input.format = af_format_decode(in_format); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
269 afs->input.bps = in_bps; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
270 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
271 // output format: same as ao driver's input format (if missing, fallback to input) |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
272 afs->output.rate = *out_samplerate ? *out_samplerate : afs->input.rate; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
273 afs->output.nch = *out_channels ? *out_channels : afs->input.nch; |
12384 | 274 afs->output.format = *out_format ? af_format_decode(*out_format) : afs->input.format; |
8995
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
275 afs->output.bps = out_bps ? out_bps : afs->input.bps; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
276 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
277 // filter config: |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
278 memcpy(&afs->cfg,&af_cfg,sizeof(af_cfg_t)); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
279 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
280 mp_msg(MSGT_DECAUDIO, MSGL_INFO, "Checking audio filter chain for %dHz/%dch/%dbit -> %dHz/%dch/%dbit...\n", |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
281 afs->input.rate,afs->input.nch,afs->input.bps*8, |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
282 afs->output.rate,afs->output.nch,afs->output.bps*8); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
283 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
284 // let's autoprobe it! |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
285 if(0 != af_init(afs,0)){ |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
286 free(afs); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
287 return 0; // failed :( |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
288 } |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
289 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
290 *out_samplerate=afs->output.rate; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
291 *out_channels=afs->output.nch; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
292 *out_format=af_format_encode((void*)(&afs->output)); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
293 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
294 mp_msg(MSGT_DECAUDIO, MSGL_INFO, "AF_pre: af format: %d bps, %d ch, %d hz, %s\n", |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
295 afs->output.bps, afs->output.nch, afs->output.rate, |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
296 fmt2str(afs->output.format,strbuf,200)); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
297 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
298 sh_audio->afilter=(void*)afs; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
299 return 1; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
300 } |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
301 |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
302 /* Init audio filters */ |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
303 int init_audio_filters(sh_audio_t *sh_audio, |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
304 int in_samplerate, int in_channels, int in_format, int in_bps, |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
305 int out_samplerate, int out_channels, int out_format, int out_bps, |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
306 int out_minsize, int out_maxsize){ |
8995
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
307 af_stream_t* afs=sh_audio->afilter; |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
308 if(!afs){ |
9018 | 309 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
|
310 memset(afs,0,sizeof(af_stream_t)); |
865cbed58cf8
2-pass libaf initialization to get better filter chain.
arpi
parents:
8969
diff
changeset
|
311 } |
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 // input format: same as codec's output format: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
314 afs->input.rate = in_samplerate; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
315 afs->input.nch = in_channels; |
8167 | 316 afs->input.format = af_format_decode(in_format); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
317 afs->input.bps = in_bps; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
318 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
319 // output format: same as ao driver's input format (if missing, fallback to input) |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
320 afs->output.rate = out_samplerate ? out_samplerate : afs->input.rate; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
321 afs->output.nch = out_channels ? out_channels : afs->input.nch; |
8167 | 322 afs->output.format = af_format_decode(out_format ? out_format : afs->input.format); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
323 afs->output.bps = out_bps ? out_bps : afs->input.bps; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
324 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
325 // filter config: |
7614 | 326 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
|
327 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
328 mp_msg(MSGT_DECAUDIO, MSGL_INFO, "Building audio filter chain for %dHz/%dch/%dbit -> %dHz/%dch/%dbit...\n", |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
329 afs->input.rate,afs->input.nch,afs->input.bps*8, |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
330 afs->output.rate,afs->output.nch,afs->output.bps*8); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
331 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
332 // let's autoprobe it! |
8969
a892e5f051e1
Adding support for more logical libaf configuration
anders
parents:
8167
diff
changeset
|
333 if(0 != af_init(afs,1)){ |
9132 | 334 sh_audio->afilter=NULL; |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
335 free(afs); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
336 return 0; // failed :( |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
337 } |
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 // allocate the a_out_* buffers: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
340 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
|
341 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
|
342 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
343 sh_audio->a_out_buffer_size=out_maxsize; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
344 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
|
345 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
|
346 sh_audio->a_out_buffer_len=0; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
347 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
348 // ok! |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
349 sh_audio->afilter=(void*)afs; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
350 return 1; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
351 } |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
352 |
5342 | 353 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) |
354 { | |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
355 int declen; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
356 af_data_t afd; // filter input |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
357 af_data_t* pafd; // filter output |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
358 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
359 if(!sh_audio->inited) return -1; // no codec |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
360 if(!sh_audio->afilter){ |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
361 // no filter, just decode: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
362 // 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
|
363 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
|
364 } |
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 // declen=af_inputlen(sh_audio->afilter,minlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
367 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
|
368 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
|
369 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
370 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
|
371 minlen, maxlen, declen, sh_audio->a_buffer_size); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
372 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
373 if(declen<=0) return -1; // error! |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
374 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
375 // 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
|
376 // 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
|
377 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
378 // decode if needed: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
379 while(declen>sh_audio->a_buffer_len){ |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
380 int len=declen-sh_audio->a_buffer_len; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
381 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
|
382 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
383 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
|
384 len, maxlen, sh_audio->audio_out_minsize); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
385 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
386 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
|
387 // 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
|
388 len=mpadec->decode_audio(sh_audio, |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
389 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
|
390 if(len<=0) break; // EOF? |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
391 sh_audio->a_buffer_len+=len; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
392 } |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
393 if(declen>sh_audio->a_buffer_len) |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
394 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
|
395 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
396 // round to whole samples: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
397 // declen/=sh_audio->samplesize*sh_audio->channels; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
398 // declen*=sh_audio->samplesize*sh_audio->channels; |
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 // run the filters: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
401 afd.audio=sh_audio->a_buffer; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
402 afd.len=declen; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
403 afd.rate=sh_audio->samplerate; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
404 afd.nch=sh_audio->channels; |
8167 | 405 afd.format=af_format_decode(sh_audio->sample_format); |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
406 afd.bps=sh_audio->samplesize; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
407 //pafd=&afd; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
408 // printf("\nAF: %d --> ",declen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
409 pafd=af_play(sh_audio->afilter,&afd); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
410 // printf("%d \n",pafd->len); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
411 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
412 if(!pafd) return -1; // error |
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 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
|
415 declen, pafd->len, maxlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
416 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
417 // copy filter==>out: |
11857
6107e58dcc28
not pretty, but at least it prevents the channels from getting out of order...
rfelker
parents:
11855
diff
changeset
|
418 if(maxlen < pafd->len) { |
6107e58dcc28
not pretty, but at least it prevents the channels from getting out of order...
rfelker
parents:
11855
diff
changeset
|
419 maxlen -= maxlen % (sh_audio->channels * sh_audio->samplesize); |
11855 | 420 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
|
421 } |
5342 | 422 else |
7604
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
423 maxlen=pafd->len; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
424 memmove(buf, pafd->audio, maxlen); |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
425 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
426 // remove processed data from decoder buffer: |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
427 sh_audio->a_buffer_len-=declen; |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
428 if(sh_audio->a_buffer_len>0) |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
429 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
|
430 |
32efb806436e
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
arpi
parents:
7561
diff
changeset
|
431 return maxlen; |
5342 | 432 } |
433 | |
434 void resync_audio_stream(sh_audio_t *sh_audio) | |
435 { | |
6049 | 436 sh_audio->a_in_buffer_len=0; // clear audio input buffer |
5342 | 437 if(!sh_audio->inited) return; |
6049 | 438 mpadec->control(sh_audio,ADCTRL_RESYNC_STREAM,NULL); |
5342 | 439 } |
440 | |
441 void skip_audio_frame(sh_audio_t *sh_audio) | |
442 { | |
443 if(!sh_audio->inited) return; | |
444 if(mpadec->control(sh_audio,ADCTRL_SKIP_FRAME,NULL)==CONTROL_TRUE) return; | |
445 // default skip code: | |
446 ds_fill_buffer(sh_audio->ds); // skip block | |
447 } |