mirror of
https://github.com/mpv-player/mpv
synced 2025-01-29 19:22:48 +00:00
dlopen() support for ad and vd
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8153 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
3bc5ffa8f8
commit
7ea0933b9e
@ -18,6 +18,10 @@
|
||||
|
||||
#include "../libaf/af.h"
|
||||
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_FAKE_MONO
|
||||
int fakemono=0;
|
||||
#endif
|
||||
@ -147,6 +151,39 @@ int init_audio(sh_audio_t *sh_audio,char* codecname,char* afm,int status){
|
||||
for (i=0; mpcodecs_ad_drivers[i] != NULL; i++)
|
||||
if(!strcmp(mpcodecs_ad_drivers[i]->info->short_name,sh_audio->codec->drv)) break;
|
||||
mpadec=mpcodecs_ad_drivers[i];
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
if (!mpadec)
|
||||
{
|
||||
/* try to open shared decoder plugin */
|
||||
int buf_len;
|
||||
char *buf;
|
||||
ad_functions_t *funcs_sym;
|
||||
ad_info_t *info_sym;
|
||||
|
||||
buf_len = strlen(LIBDIR)+strlen(sh_audio->codec->drv)+16;
|
||||
buf = malloc(buf_len);
|
||||
if (!buf)
|
||||
break;
|
||||
snprintf(buf, buf_len, "%s/mplayer/ad_%s.so", LIBDIR, sh_audio->codec->drv);
|
||||
mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf);
|
||||
sh_audio->dec_handle = dlopen(buf, RTLD_LAZY);
|
||||
if (!sh_audio->dec_handle)
|
||||
break;
|
||||
snprintf(buf, buf_len, "mpcodecs_ad_%s", sh_audio->codec->drv);
|
||||
funcs_sym = dlsym(sh_audio->dec_handle, buf);
|
||||
if (!funcs_sym || !funcs_sym->info || !funcs_sym->preinit ||
|
||||
!funcs_sym->init || !funcs_sym->uninit || !funcs_sym->control ||
|
||||
!funcs_sym->decode_audio)
|
||||
break;
|
||||
info_sym = funcs_sym->info;
|
||||
if (strcmp(info_sym->short_name, sh_audio->codec->drv))
|
||||
break;
|
||||
free(buf);
|
||||
mpadec = funcs_sym;
|
||||
mp_msg(MSGT_DECAUDIO, MSGL_V, "Using external decoder plugin (%s/mplayer/ad_%s.so)!\n",
|
||||
LIBDIR, sh_audio->codec->drv);
|
||||
}
|
||||
#endif
|
||||
if(!mpadec){ // driver not available (==compiled in)
|
||||
mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_AudioCodecFamilyNotAvailableStr,
|
||||
sh_audio->codec->name, sh_audio->codec->drv);
|
||||
@ -225,6 +262,10 @@ void uninit_audio(sh_audio_t *sh_audio)
|
||||
if(sh_audio->inited){
|
||||
mp_msg(MSGT_DECAUDIO,MSGL_V,MSGTR_UninitAudioStr,sh_audio->codec->drv);
|
||||
mpadec->uninit(sh_audio);
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
if (sh_audio->dec_handle)
|
||||
dlclose(sh_audio->dec_handle);
|
||||
#endif
|
||||
sh_audio->inited=0;
|
||||
}
|
||||
if(sh_audio->a_out_buffer!=sh_audio->a_buffer) free(sh_audio->a_out_buffer);
|
||||
|
@ -28,6 +28,10 @@
|
||||
|
||||
#include "dec_video.h"
|
||||
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
// ===================================================================
|
||||
|
||||
extern double video_time_usage;
|
||||
@ -134,6 +138,10 @@ void uninit_video(sh_video_t *sh_video){
|
||||
if(!sh_video->inited) return;
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_UninitVideoStr,sh_video->codec->drv);
|
||||
mpvdec->uninit(sh_video);
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
if (sh_video->dec_handle)
|
||||
dlclose(sh_video->dec_handle);
|
||||
#endif
|
||||
vf_uninit_filter_chain(sh_video->vfilter);
|
||||
sh_video->inited=0;
|
||||
}
|
||||
@ -172,6 +180,38 @@ int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){
|
||||
// if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break;
|
||||
if(!strcmp(mpcodecs_vd_drivers[i]->info->short_name,sh_video->codec->drv)) break;
|
||||
mpvdec=mpcodecs_vd_drivers[i];
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
if (!mpvdec)
|
||||
{
|
||||
/* try to open shared decoder plugin */
|
||||
int buf_len;
|
||||
char *buf;
|
||||
vd_functions_t *funcs_sym;
|
||||
vd_info_t *info_sym;
|
||||
|
||||
buf_len = strlen(LIBDIR)+strlen(sh_video->codec->drv)+16;
|
||||
buf = malloc(buf_len);
|
||||
if (!buf)
|
||||
break;
|
||||
snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", LIBDIR, sh_video->codec->drv);
|
||||
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf);
|
||||
sh_video->dec_handle = dlopen(buf, RTLD_LAZY);
|
||||
if (!sh_video->dec_handle)
|
||||
break;
|
||||
snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv);
|
||||
funcs_sym = dlsym(sh_video->dec_handle, buf);
|
||||
if (!funcs_sym || !funcs_sym->info || !funcs_sym->init ||
|
||||
!funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode)
|
||||
break;
|
||||
info_sym = funcs_sym->info;
|
||||
if (strcmp(info_sym->short_name, sh_video->codec->drv))
|
||||
break;
|
||||
free(buf);
|
||||
mpvdec = funcs_sym;
|
||||
mp_msg(MSGT_DECVIDEO, MSGL_V, "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n",
|
||||
LIBDIR, sh_video->codec->drv);
|
||||
}
|
||||
#endif
|
||||
if(!mpvdec){ // driver not available (==compiled in)
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_VideoCodecFamilyNotAvailableStr,
|
||||
sh_video->codec->name, sh_video->codec->drv);
|
||||
|
@ -70,6 +70,9 @@ typedef struct {
|
||||
int a_out_buffer_size;
|
||||
// void* audio_out; // the audio_out handle, used for this audio stream
|
||||
void* afilter; // the audio filter stream
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
void *dec_handle;
|
||||
#endif
|
||||
// win32-compatible codec parameters:
|
||||
AVIStreamHeader audio;
|
||||
WAVEFORMATEX* wf;
|
||||
@ -99,6 +102,9 @@ typedef struct {
|
||||
void* video_out; // the video_out handle, used for this video stream
|
||||
void* vfilter; // the video filter chain, used for this video stream
|
||||
int vf_inited;
|
||||
#ifdef DYNAMIC_PLUGINS
|
||||
void *dec_handle;
|
||||
#endif
|
||||
// win32-compatible codec parameters:
|
||||
AVIStreamHeader video;
|
||||
BITMAPINFOHEADER* bih;
|
||||
|
Loading…
Reference in New Issue
Block a user