From 5e480c7b817748e000caa967711f28eae5e2a3f2 Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 23 Mar 2010 18:01:00 +0000 Subject: Get rid of pointless def_path variable; use codec_path directly instead. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30949 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/ad_realaud.c | 12 ++++++------ libmpcodecs/vd_realvid.c | 4 ++-- libmpcodecs/vd_xanim.c | 2 +- loader/elfdll.c | 2 +- loader/module.c | 4 ++-- loader/win32.c | 23 +++++++++++++---------- mpcommon.c | 2 -- mpcommon.h | 2 -- path.c | 10 +++++----- path.h | 2 +- 10 files changed, 31 insertions(+), 32 deletions(-) diff --git a/libmpcodecs/ad_realaud.c b/libmpcodecs/ad_realaud.c index 87ff3689b5..b3205065a0 100644 --- a/libmpcodecs/ad_realaud.c +++ b/libmpcodecs/ad_realaud.c @@ -252,9 +252,9 @@ static int preinit(sh_audio_t *sh){ unsigned int result; char *path; - path = malloc(strlen(def_path) + strlen(sh->codec->dll) + 2); + path = malloc(strlen(codecs_path) + strlen(sh->codec->dll) + 2); if (!path) return 0; - sprintf(path, "%s/%s", def_path, sh->codec->dll); + sprintf(path, "%s/%s", codecs_path, sh->codec->dll); /* first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones */ @@ -278,8 +278,8 @@ static int preinit(sh_audio_t *sh){ if(raSetDLLAccessPath){ #endif // used by 'SIPR' - path = realloc(path, strlen(def_path) + 13); - sprintf(path, "DT_Codecs=%s", def_path); + path = realloc(path, strlen(codecs_path) + 13); + sprintf(path, "DT_Codecs=%s", codecs_path); if(path[strlen(path)-1]!='/'){ path[strlen(path)+1]=0; path[strlen(path)]='/'; @@ -301,14 +301,14 @@ static int preinit(sh_audio_t *sh){ #ifdef CONFIG_WIN32DLL if (dll_type == 1){ if (wraOpenCodec2) { - sprintf(path, "%s\\", def_path); + sprintf(path, "%s\\", codecs_path); result = wraOpenCodec2(&sh->context, path); } else result=wraOpenCodec(&sh->context); } else #endif if (raOpenCodec2) { - sprintf(path, "%s/", def_path); + sprintf(path, "%s/", codecs_path); result = raOpenCodec2(&sh->context, path); } else result=raOpenCodec(&sh->context); diff --git a/libmpcodecs/vd_realvid.c b/libmpcodecs/vd_realvid.c index 7ddaf811e8..00f5983e64 100644 --- a/libmpcodecs/vd_realvid.c +++ b/libmpcodecs/vd_realvid.c @@ -274,9 +274,9 @@ static int init(sh_video_t *sh){ mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X sub-id: 0x%08X\n",be2me_32(((unsigned int*)extrahdr)[1]),be2me_32(((unsigned int*)extrahdr)[0])); - path = malloc(strlen(def_path) + strlen(sh->codec->dll) + 2); + path = malloc(strlen(codecs_path) + strlen(sh->codec->dll) + 2); if (!path) return 0; - sprintf(path, "%s/%s", def_path, sh->codec->dll); + sprintf(path, "%s/%s", codecs_path, sh->codec->dll); /* first try to load linux dlls, if failed and we're supporting win32 dlls, then try to load the windows ones */ diff --git a/libmpcodecs/vd_xanim.c b/libmpcodecs/vd_xanim.c index 70f9306ba3..cca4f23dd5 100644 --- a/libmpcodecs/vd_xanim.c +++ b/libmpcodecs/vd_xanim.c @@ -682,7 +682,7 @@ static int init(sh_video_t *sh) for (i=0; i < XA_CLOSE_FUNCS; i++) xa_close_func[i] = NULL; - snprintf(dll, 1024, "%s/%s", def_path, sh->codec->dll); + snprintf(dll, 1024, "%s/%s", codec_path, sh->codec->dll); if (xacodec_load(sh, dll) == 0) return 0; diff --git a/loader/elfdll.c b/loader/elfdll.c index 5c33d2bde9..f6ac158107 100644 --- a/loader/elfdll.c +++ b/loader/elfdll.c @@ -68,7 +68,7 @@ void *ELFDLL_dlopen(const char *libname, int flags) /* Now try to construct searches through our extra search-path */ namelen = strlen(libname); - ldpath = def_path; + ldpath = codec_path; while(ldpath && *ldpath) { int len; diff --git a/loader/module.c b/loader/module.c index b6eebcf19d..d0f32d2537 100644 --- a/loader/module.c +++ b/loader/module.c @@ -393,9 +393,9 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags) strncpy(path, libname, 511); else /* check default user path */ - strncpy(path, def_path, 300); + strncpy(path, codec_path, 300); } - else if (strcmp(def_path, listpath[i])) + else if (strcmp(codec_path, listpath[i])) /* path from the list */ strncpy(path, listpath[i], 300); else diff --git a/loader/win32.c b/loader/win32.c index fe8b198944..99f8ffd991 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -2575,7 +2575,8 @@ static int WINAPI expLoadLibraryA(char* name) return MODULE_HANDLE_psapi; result=LoadLibraryA(name); - dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result); + dbgprintf("Returned LoadLibraryA(0x%x='%s'), codec_path=%s => 0x%x\n", + name, name, codec_path, result); return result; } @@ -3589,13 +3590,15 @@ static HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd) #ifdef CONFIG_QTX_CODECS if(strstr(s, "quicktime\\*.QTX")){ dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTX\n", s, s, lpfd); - dbgprintf("\n### Searching for QuickTime plugins (*.qtx) at %s...\n",def_path); - qtx_dir=opendir(def_path); + dbgprintf("\n### Searching for QuickTime plugins (*.qtx) at %s...\n", + codec_path); + qtx_dir = opendir(codec_path); if(!qtx_dir) return (HANDLE)-1; memset(lpfd,0,sizeof(*lpfd)); if(expFindNextFileA(FILE_HANDLE_quicktimeqtx,lpfd)) return FILE_HANDLE_quicktimeqtx; - printf("loader: Couldn't find the QuickTime plugins (.qtx files) at %s\n",def_path); + printf("loader: Couldn't find the QuickTime plugins (.qtx files) at %s\n", + codec_path); return (HANDLE)-1; } #if 0 @@ -3732,8 +3735,8 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, if(strstr(cs1, "QuickTime.qts")) { int result; - char* tmp=malloc(strlen(def_path)+50); - strcpy(tmp, def_path); + char* tmp = malloc(strlen(codec_path) + 50); + strcpy(tmp, codec_path); strcat(tmp, "/"); strcat(tmp, "QuickTime.qts"); result=open(tmp, O_RDONLY); @@ -3743,9 +3746,9 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, if(strstr(cs1, ".qtx")) { int result; - char* tmp=malloc(strlen(def_path)+250); + char* tmp = malloc(strlen(codec_path) + 250); char* x=strrchr(cs1,'\\'); - sprintf(tmp,"%s/%s",def_path,x?(x+1):cs1); + sprintf(tmp, "%s/%s", codec_path, x ? (x + 1) : cs1); // printf("### Open: %s -> %s\n",cs1,tmp); result=open(tmp, O_RDONLY); free(tmp); @@ -3756,8 +3759,8 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2, if(strncmp(cs1, "AP", 2) == 0) { int result; - char* tmp=malloc(strlen(def_path)+50); - strcpy(tmp, def_path); + char* tmp = malloc(strlen(codec_path) + 50); + strcpy(tmp, codec_path); strcat(tmp, "/"); strcat(tmp, "APmpg4v1.apl"); result=open(tmp, O_RDONLY); diff --git a/mpcommon.c b/mpcommon.c index 55b6bb8558..12a0b25896 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -314,5 +314,3 @@ const m_option_t noconfig_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; -char *codec_path = NULL; - diff --git a/mpcommon.h b/mpcommon.h index 5e2368562f..412225b104 100644 --- a/mpcommon.h +++ b/mpcommon.h @@ -37,6 +37,4 @@ void set_osd_subtitle(subtitle *subs); extern int disable_system_conf; extern int disable_user_conf; -extern char *codec_path; - #endif /* MPLAYER_MPCOMMON_H */ diff --git a/path.c b/path.c index 83da4ee8d2..2a1d504ce3 100644 --- a/path.c +++ b/path.c @@ -176,20 +176,20 @@ void set_path_env(void) } #endif /* (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) */ -char *def_path = BINARY_CODECS_PATH; +char *codec_path = BINARY_CODECS_PATH; static int needs_free = 0; void set_codec_path(const char *path) { if (needs_free) - free(def_path); + free(codec_path); if (path == 0) { - def_path = BINARY_CODECS_PATH; + codec_path = BINARY_CODECS_PATH; needs_free = 0; return; } - def_path = malloc(strlen(path) + 1); - strcpy(def_path, path); + codec_path = malloc(strlen(path) + 1); + strcpy(codec_path, path); needs_free = 1; } diff --git a/path.h b/path.h index 233c6094e1..3e71120458 100644 --- a/path.h +++ b/path.h @@ -21,7 +21,7 @@ #ifndef MPLAYER_PATH_H #define MPLAYER_PATH_H -extern char *def_path; +extern char *codec_path; char *get_path(const char *filename); void set_path_env(void); -- cgit v1.2.3