From bdfdece245b5aa863b4c57996c38b5638d7797d0 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 9 Apr 2011 05:14:55 +0300 Subject: subs: move vobsub loading logic down to find_subfiles.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Analogously to the previous commit, move path handling logic for loading external vobsub files from mplayer.c to find_subfiles.c. Based on a commit from Clément Bœsch but fixed and simplified. --- mplayer.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 59dff418d9..91f314bcf2 100644 --- a/mplayer.c +++ b/mplayer.c @@ -4174,27 +4174,13 @@ if (edl_output_filename) { mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Cannot load subtitles: %s\n", filename_recode(opts->vobsub_name)); } else if (opts->sub_auto && mpctx->filename){ - /* try to autodetect vobsub from movie filename ::atmos */ - char *buf = strdup(mpctx->filename), *psub; - char *pdot = strrchr(buf, '.'); - char *pslash = strrchr(buf, '/'); -#if defined(__MINGW32__) || defined(__CYGWIN__) - if (!pslash) pslash = strrchr(buf, '\\'); -#endif - if (pdot && (!pslash || pdot > pslash)) - *pdot = '\0'; - vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec); - /* try from ~/.mplayer/sub */ - if(!vo_vobsub && (psub = get_path( "sub/" ))) { - const char *bname = mp_basename(buf); - int l; - l = strlen(psub) + strlen(bname) + 1; - psub = realloc(psub,l); - strcat(psub,bname); - vo_vobsub=vobsub_open(psub,spudec_ifo,0,&vo_spudec); - free(psub); - } - free(buf); + char **vob = find_vob_subtitles(mpctx->filename); + for (int i = 0; i < MP_TALLOC_ELEMS(vob); i++) { + vo_vobsub = vobsub_open(vob[i], spudec_ifo, 0, &vo_spudec); + if (vo_vobsub) + break; + } + talloc_free(vob); } if(vo_vobsub){ mpctx->initialized_flags|=INITIALIZED_VOBSUB; -- cgit v1.2.3