On Sun, Nov 21, 2010 at 05:46:16PM +0100, Clément Bœsch wrote:
+/** + * \brief Append a subtitle to a list + * \param dst Destination subtitles list + * \param src Source subtitle + * \warning Source data are copied and not reallocated + */ +static int append_sub(struct sub_list *dst, struct subfn *src) { + if (dst->sid >= MAX_SUBTITLE_FILES) + return -1; + memcpy(&dst->subs[dst->sid], src, sizeof(*src)); + dst->sid++; + return 0;
Either getting rid of this function or at least making it take the name etc. as arguments and having it do the strdup will make things even simpler.
@@ -2012,8 +2013,7 @@ char** sub_filenames(const char* path, char *fname) } if (!prio) { // doesn't contain the movie name - // don't try in the mplayer subtitle directory - if ((j == 0) && (sub_match_fuzziness >= 2)) { + if (sub_match_fuzziness >= 2) {
Huh? Where did handling of this end up? Loading any subtitle file anywhere in the path doesn't sound to me like it would ever be desireable.
+ path = realloc(path, plen + strlen(dir) + 1); + if (!path) + return -1;
memleak in case realloc fails.
+ strcpy(path + plen, dir);
av_strlcpy might make it more obvious.
+ // Load subtitles specified by sub option with highest priority + if (sub_name) { + int i; + for (i = 0; sub_name[i]; i++) { + struct subfn sub = { + .fname = strdup(sub_name[i]), + .priority = INT_MAX - i, + .noerr = 0 + }; + append_sub(&slist, &sub); + }
Seems a bit overkill to push them through qsort. Though it might be the simplest way.
+.br +/tmp/\:subs/ +.br +~/.mplayer/\:sub/ +.RE +.PD 1 +. +.TP .B \-subdelay <sec> Delays subtitles by <sec> seconds. Can be negative. @@ -11714,14 +11735,6 @@ font directory (There must be a font.desc file and files with .RAW extension.) .TP ~/.mplayer/\:DVDkeys/ cached CSS keys -. -.TP -Assuming that /path/\:to/\:movie.avi is played, MPlayer searches for sub files -in this order: -.RS -/path/\:to/\:movie.sub -.br -~/.mplayer/\:sub/\:movie.sub .RE .PD 1 . diff --git a/cfg-common.h b/cfg-common.h index c6dfef0..d50ebe2 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -562,6 +562,7 @@ const m_option_t common_opts[] = { // ------------------------- subtitles options --------------------
{"sub", &sub_name, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, + {"subdirs", &sub_dirs, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, #ifdef CONFIG_FRIBIDI {"fribidi-charset", &fribidi_charset, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"flip-hebrew", &flip_hebrew, CONF_TYPE_FLAG, 0, 0, 1, NULL}, diff --git a/mencoder.c b/mencoder.c index 6efe907..403fbac 100644 --- a/mencoder.c +++ b/mencoder.c @@ -179,6 +179,7 @@ char *font_name=NULL; char *sub_font_name=NULL; float font_factor=0.75; char **sub_name=NULL; +char **sub_dirs = NULL; float sub_delay=0; float sub_fps=0; int sub_auto = 0; diff --git a/mpcommon.h b/mpcommon.h index 19110d6..4a2147e 100644 --- a/mpcommon.h +++ b/mpcommon.h @@ -35,6 +35,7 @@ extern int sub_auto; extern float sub_delay; extern float sub_fps; extern char **sub_name; +extern char **sub_dirs; extern char *font_name; extern char *sub_font_name; extern char *audio_lang; diff --git a/mplayer.c b/mplayer.c index 3682b29..7ebc3cd 100644 --- a/mplayer.c +++ b/mplayer.c @@ -292,6 +292,7 @@ char *font_name=NULL; char *sub_font_name=NULL; float font_factor=0.75; char **sub_name=NULL; +char **sub_dirs = NULL; float sub_delay=0; float sub_fps=0; int sub_auto = 1; diff --git a/sub/subreader.c b/sub/subreader.c index 94d0877..fba9c82 100644 --- a/sub/subreader.c +++ b/sub/subreader.c @@ -2117,6 +2117,13 @@ static struct sub_list get_full_sub_list(char *fname) // Load subtitles from current media directory track_sub_directory("", fname, &slist);
+ // Load subtitles in dirs specified by subdirs option + if (sub_dirs) { + int i; + for (i = 0; sub_dirs[i]; i++) + track_sub_directory(sub_dirs[i], fname, &slist); + } + // Load subtitles in ~/.mplayer/sub mp_subdir = get_path("sub/"); if (mp_subdir) -- 1.7.3.2
_______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng