Mercurial > mplayer.hg
comparison libmpcodecs/dec_audio.c @ 8152:4b02f73cb4b9
dlopen() support for ad and vd
author | alex |
---|---|
date | Mon, 11 Nov 2002 17:28:41 +0000 |
parents | 9fc45fe0d444 |
children | e8832e66babd |
comparison
equal
deleted
inserted
replaced
8151:76b693c15c47 | 8152:4b02f73cb4b9 |
---|---|
15 #include "dec_audio.h" | 15 #include "dec_audio.h" |
16 #include "ad.h" | 16 #include "ad.h" |
17 #include "../libao2/afmt.h" | 17 #include "../libao2/afmt.h" |
18 | 18 |
19 #include "../libaf/af.h" | 19 #include "../libaf/af.h" |
20 | |
21 #ifdef DYNAMIC_PLUGINS | |
22 #include <dlfcn.h> | |
23 #endif | |
20 | 24 |
21 #ifdef USE_FAKE_MONO | 25 #ifdef USE_FAKE_MONO |
22 int fakemono=0; | 26 int fakemono=0; |
23 #endif | 27 #endif |
24 /* used for ac3surround decoder - set using -channels option */ | 28 /* used for ac3surround decoder - set using -channels option */ |
145 sh_audio->codec->flags|=CODECS_FLAG_SELECTED; // tagging it | 149 sh_audio->codec->flags|=CODECS_FLAG_SELECTED; // tagging it |
146 // ok, it matches all rules, let's find the driver! | 150 // ok, it matches all rules, let's find the driver! |
147 for (i=0; mpcodecs_ad_drivers[i] != NULL; i++) | 151 for (i=0; mpcodecs_ad_drivers[i] != NULL; i++) |
148 if(!strcmp(mpcodecs_ad_drivers[i]->info->short_name,sh_audio->codec->drv)) break; | 152 if(!strcmp(mpcodecs_ad_drivers[i]->info->short_name,sh_audio->codec->drv)) break; |
149 mpadec=mpcodecs_ad_drivers[i]; | 153 mpadec=mpcodecs_ad_drivers[i]; |
154 #ifdef DYNAMIC_PLUGINS | |
155 if (!mpadec) | |
156 { | |
157 /* try to open shared decoder plugin */ | |
158 int buf_len; | |
159 char *buf; | |
160 ad_functions_t *funcs_sym; | |
161 ad_info_t *info_sym; | |
162 | |
163 buf_len = strlen(LIBDIR)+strlen(sh_audio->codec->drv)+16; | |
164 buf = malloc(buf_len); | |
165 if (!buf) | |
166 break; | |
167 snprintf(buf, buf_len, "%s/mplayer/ad_%s.so", LIBDIR, sh_audio->codec->drv); | |
168 mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf); | |
169 sh_audio->dec_handle = dlopen(buf, RTLD_LAZY); | |
170 if (!sh_audio->dec_handle) | |
171 break; | |
172 snprintf(buf, buf_len, "mpcodecs_ad_%s", sh_audio->codec->drv); | |
173 funcs_sym = dlsym(sh_audio->dec_handle, buf); | |
174 if (!funcs_sym || !funcs_sym->info || !funcs_sym->preinit || | |
175 !funcs_sym->init || !funcs_sym->uninit || !funcs_sym->control || | |
176 !funcs_sym->decode_audio) | |
177 break; | |
178 info_sym = funcs_sym->info; | |
179 if (strcmp(info_sym->short_name, sh_audio->codec->drv)) | |
180 break; | |
181 free(buf); | |
182 mpadec = funcs_sym; | |
183 mp_msg(MSGT_DECAUDIO, MSGL_V, "Using external decoder plugin (%s/mplayer/ad_%s.so)!\n", | |
184 LIBDIR, sh_audio->codec->drv); | |
185 } | |
186 #endif | |
150 if(!mpadec){ // driver not available (==compiled in) | 187 if(!mpadec){ // driver not available (==compiled in) |
151 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_AudioCodecFamilyNotAvailableStr, | 188 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_AudioCodecFamilyNotAvailableStr, |
152 sh_audio->codec->name, sh_audio->codec->drv); | 189 sh_audio->codec->name, sh_audio->codec->drv); |
153 continue; | 190 continue; |
154 } | 191 } |
223 sh_audio->afilter=NULL; | 260 sh_audio->afilter=NULL; |
224 } | 261 } |
225 if(sh_audio->inited){ | 262 if(sh_audio->inited){ |
226 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_UninitAudioStr,sh_audio->codec->drv); | 263 mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_UninitAudioStr,sh_audio->codec->drv); |
227 mpadec->uninit(sh_audio); | 264 mpadec->uninit(sh_audio); |
265 #ifdef DYNAMIC_PLUGINS | |
266 if (sh_audio->dec_handle) | |
267 dlclose(sh_audio->dec_handle); | |
268 #endif | |
228 sh_audio->inited=0; | 269 sh_audio->inited=0; |
229 } | 270 } |
230 if(sh_audio->a_out_buffer!=sh_audio->a_buffer) free(sh_audio->a_out_buffer); | 271 if(sh_audio->a_out_buffer!=sh_audio->a_buffer) free(sh_audio->a_out_buffer); |
231 sh_audio->a_out_buffer=NULL; | 272 sh_audio->a_out_buffer=NULL; |
232 if(sh_audio->a_buffer) free(sh_audio->a_buffer); | 273 if(sh_audio->a_buffer) free(sh_audio->a_buffer); |