[PATCH 3/3] Add subdirs option

Clément Bœsch ubitux at gmail.com
Sat Nov 20 21:08:06 CET 2010


---
 DOCS/man/en/mplayer.1 |   29 +++++++++++++++++++++--------
 cfg-common.h          |    1 +
 mencoder.c            |    1 +
 mpcommon.h            |    1 +
 mplayer.c             |    1 +
 sub/subreader.c       |    6 ++++++
 6 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 9921db4..6b82a42 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -2625,6 +2625,27 @@ Guess the encoding for Polish, fall back on cp1250.
 .PD 1
 .
 .TP
+.B \-subdirs <dirname1,dirname2,...>
+Specify extra subtitles directories to track in the media directory.
+.sp 1
+.I EXAMPLE:
+Assuming that /path/\:to/\:movie/\:movie.avi is played and \-subdirs
+sub,subtitles,/tmp/subs is specified, MPlayer searches for subtitles files in these
+directories:
+.RSs
+/path/\:to/\:movie/
+.br
+/path/\:to/\:movie/\:sub/
+.br
+/path/\:to/\:movie/\:subtitles/
+.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 1033f87..7fedfbe 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -2136,6 +2136,12 @@ static struct sub_list get_full_sub_list(char *fname)
     // Load subtitles from current media directory
     track_sub_directory("", fname, &fslist);
 
+    // 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, &fslist);
+    }
 
     // Load subtitles in ~/.mplayer/sub
     mp_subdir = get_path("sub/");
-- 
1.7.3.2


--MZf7D3rAEoQgPanC--


More information about the MPlayer-dev-eng mailing list