1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 23:00:41 +00:00

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
This commit is contained in:
diego 2010-03-23 18:01:00 +00:00
parent cb26eaf0bb
commit 5e480c7b81
10 changed files with 31 additions and 32 deletions

View File

@ -252,9 +252,9 @@ static int preinit(sh_audio_t *sh){
unsigned int result; unsigned int result;
char *path; 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; 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, /* first try to load linux dlls, if failed and we're supporting win32 dlls,
then try to load the windows ones */ then try to load the windows ones */
@ -278,8 +278,8 @@ static int preinit(sh_audio_t *sh){
if(raSetDLLAccessPath){ if(raSetDLLAccessPath){
#endif #endif
// used by 'SIPR' // used by 'SIPR'
path = realloc(path, strlen(def_path) + 13); path = realloc(path, strlen(codecs_path) + 13);
sprintf(path, "DT_Codecs=%s", def_path); sprintf(path, "DT_Codecs=%s", codecs_path);
if(path[strlen(path)-1]!='/'){ if(path[strlen(path)-1]!='/'){
path[strlen(path)+1]=0; path[strlen(path)+1]=0;
path[strlen(path)]='/'; path[strlen(path)]='/';
@ -301,14 +301,14 @@ static int preinit(sh_audio_t *sh){
#ifdef CONFIG_WIN32DLL #ifdef CONFIG_WIN32DLL
if (dll_type == 1){ if (dll_type == 1){
if (wraOpenCodec2) { if (wraOpenCodec2) {
sprintf(path, "%s\\", def_path); sprintf(path, "%s\\", codecs_path);
result = wraOpenCodec2(&sh->context, path); result = wraOpenCodec2(&sh->context, path);
} else } else
result=wraOpenCodec(&sh->context); result=wraOpenCodec(&sh->context);
} else } else
#endif #endif
if (raOpenCodec2) { if (raOpenCodec2) {
sprintf(path, "%s/", def_path); sprintf(path, "%s/", codecs_path);
result = raOpenCodec2(&sh->context, path); result = raOpenCodec2(&sh->context, path);
} else } else
result=raOpenCodec(&sh->context); result=raOpenCodec(&sh->context);

View File

@ -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])); 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; 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, /* first try to load linux dlls, if failed and we're supporting win32 dlls,
then try to load the windows ones */ then try to load the windows ones */

View File

@ -682,7 +682,7 @@ static int init(sh_video_t *sh)
for (i=0; i < XA_CLOSE_FUNCS; i++) for (i=0; i < XA_CLOSE_FUNCS; i++)
xa_close_func[i] = NULL; 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) if (xacodec_load(sh, dll) == 0)
return 0; return 0;

View File

@ -68,7 +68,7 @@ void *ELFDLL_dlopen(const char *libname, int flags)
/* Now try to construct searches through our extra search-path */ /* Now try to construct searches through our extra search-path */
namelen = strlen(libname); namelen = strlen(libname);
ldpath = def_path; ldpath = codec_path;
while(ldpath && *ldpath) while(ldpath && *ldpath)
{ {
int len; int len;

View File

@ -393,9 +393,9 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
strncpy(path, libname, 511); strncpy(path, libname, 511);
else else
/* check default user path */ /* 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 */ /* path from the list */
strncpy(path, listpath[i], 300); strncpy(path, listpath[i], 300);
else else

View File

@ -2575,7 +2575,8 @@ static int WINAPI expLoadLibraryA(char* name)
return MODULE_HANDLE_psapi; return MODULE_HANDLE_psapi;
result=LoadLibraryA(name); 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; return result;
} }
@ -3589,13 +3590,15 @@ static HANDLE WINAPI expFindFirstFileA(LPCSTR s, LPWIN32_FIND_DATAA lpfd)
#ifdef CONFIG_QTX_CODECS #ifdef CONFIG_QTX_CODECS
if(strstr(s, "quicktime\\*.QTX")){ if(strstr(s, "quicktime\\*.QTX")){
dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTX\n", s, s, lpfd); dbgprintf("FindFirstFileA(0x%x='%s', 0x%x) => QTX\n", s, s, lpfd);
dbgprintf("\n### Searching for QuickTime plugins (*.qtx) at %s...\n",def_path); dbgprintf("\n### Searching for QuickTime plugins (*.qtx) at %s...\n",
qtx_dir=opendir(def_path); codec_path);
qtx_dir = opendir(codec_path);
if(!qtx_dir) return (HANDLE)-1; if(!qtx_dir) return (HANDLE)-1;
memset(lpfd,0,sizeof(*lpfd)); memset(lpfd,0,sizeof(*lpfd));
if(expFindNextFileA(FILE_HANDLE_quicktimeqtx,lpfd)) if(expFindNextFileA(FILE_HANDLE_quicktimeqtx,lpfd))
return FILE_HANDLE_quicktimeqtx; 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; return (HANDLE)-1;
} }
#if 0 #if 0
@ -3732,8 +3735,8 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
if(strstr(cs1, "QuickTime.qts")) if(strstr(cs1, "QuickTime.qts"))
{ {
int result; int result;
char* tmp=malloc(strlen(def_path)+50); char* tmp = malloc(strlen(codec_path) + 50);
strcpy(tmp, def_path); strcpy(tmp, codec_path);
strcat(tmp, "/"); strcat(tmp, "/");
strcat(tmp, "QuickTime.qts"); strcat(tmp, "QuickTime.qts");
result=open(tmp, O_RDONLY); result=open(tmp, O_RDONLY);
@ -3743,9 +3746,9 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
if(strstr(cs1, ".qtx")) if(strstr(cs1, ".qtx"))
{ {
int result; int result;
char* tmp=malloc(strlen(def_path)+250); char* tmp = malloc(strlen(codec_path) + 250);
char* x=strrchr(cs1,'\\'); 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); // printf("### Open: %s -> %s\n",cs1,tmp);
result=open(tmp, O_RDONLY); result=open(tmp, O_RDONLY);
free(tmp); free(tmp);
@ -3756,8 +3759,8 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
if(strncmp(cs1, "AP", 2) == 0) if(strncmp(cs1, "AP", 2) == 0)
{ {
int result; int result;
char* tmp=malloc(strlen(def_path)+50); char* tmp = malloc(strlen(codec_path) + 50);
strcpy(tmp, def_path); strcpy(tmp, codec_path);
strcat(tmp, "/"); strcat(tmp, "/");
strcat(tmp, "APmpg4v1.apl"); strcat(tmp, "APmpg4v1.apl");
result=open(tmp, O_RDONLY); result=open(tmp, O_RDONLY);

View File

@ -314,5 +314,3 @@ const m_option_t noconfig_opts[] = {
{NULL, NULL, 0, 0, 0, 0, NULL} {NULL, NULL, 0, 0, 0, 0, NULL}
}; };
char *codec_path = NULL;

View File

@ -37,6 +37,4 @@ void set_osd_subtitle(subtitle *subs);
extern int disable_system_conf; extern int disable_system_conf;
extern int disable_user_conf; extern int disable_user_conf;
extern char *codec_path;
#endif /* MPLAYER_MPCOMMON_H */ #endif /* MPLAYER_MPCOMMON_H */

10
path.c
View File

@ -176,20 +176,20 @@ void set_path_env(void)
} }
#endif /* (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) */ #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; static int needs_free = 0;
void set_codec_path(const char *path) void set_codec_path(const char *path)
{ {
if (needs_free) if (needs_free)
free(def_path); free(codec_path);
if (path == 0) { if (path == 0) {
def_path = BINARY_CODECS_PATH; codec_path = BINARY_CODECS_PATH;
needs_free = 0; needs_free = 0;
return; return;
} }
def_path = malloc(strlen(path) + 1); codec_path = malloc(strlen(path) + 1);
strcpy(def_path, path); strcpy(codec_path, path);
needs_free = 1; needs_free = 1;
} }

2
path.h
View File

@ -21,7 +21,7 @@
#ifndef MPLAYER_PATH_H #ifndef MPLAYER_PATH_H
#define MPLAYER_PATH_H #define MPLAYER_PATH_H
extern char *def_path; extern char *codec_path;
char *get_path(const char *filename); char *get_path(const char *filename);
void set_path_env(void); void set_path_env(void);