diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-04-09 05:14:55 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-04-20 04:22:52 +0300 |
commit | bdfdece245b5aa863b4c57996c38b5638d7797d0 (patch) | |
tree | 3036399e13ea08cc44019d1e7208295f47226865 /mplayer.c | |
parent | 7221e28fe3d743aaf6357bb0838e762781644f0d (diff) | |
download | mpv-bdfdece245b5aa863b4c57996c38b5638d7797d0.tar.bz2 mpv-bdfdece245b5aa863b4c57996c38b5638d7797d0.tar.xz |
subs: move vobsub loading logic down to find_subfiles.c
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.
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 28 |
1 files changed, 7 insertions, 21 deletions
@@ -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; |