summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-04-09 05:14:55 +0300
committerUoti Urpala <uau@mplayer2.org>2011-04-20 04:22:52 +0300
commitbdfdece245b5aa863b4c57996c38b5638d7797d0 (patch)
tree3036399e13ea08cc44019d1e7208295f47226865 /sub
parent7221e28fe3d743aaf6357bb0838e762781644f0d (diff)
downloadmpv-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 'sub')
-rw-r--r--sub/find_subfiles.c25
-rw-r--r--sub/find_subfiles.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c
index 19ee0f065b..862afe53c6 100644
--- a/sub/find_subfiles.c
+++ b/sub/find_subfiles.c
@@ -5,6 +5,7 @@
#include "mp_msg.h"
#include "path.h"
+#include "mpcommon.h"
#include "sub/find_subfiles.h"
#include "sub/sub.h"
@@ -278,3 +279,27 @@ char **find_text_subtitles(const char *fname)
free(psub);
return tmp;
}
+
+char **find_vob_subtitles(const char *fname)
+{
+ char **vobs = talloc_array_ptrtype(NULL, vobs, 1);
+ int n = 0;
+
+ // Potential vobsub in the media directory
+ struct bstr bname = BSTR(mp_basename(fname));
+ int pdot = bstrrchr(bname, '.');
+ if (pdot >= 0)
+ bname.len = pdot;
+ vobs[n++] = mp_path_join(vobs, mp_dirname(fname), bname);
+
+ // Potential vobsub in ~/.mplayer/sub
+ char *mp_subdir = get_path("sub/");
+ if (mp_subdir) {
+ MP_GROW_ARRAY(vobs, n);
+ vobs[n++] = mp_path_join(vobs, BSTR(mp_subdir), bname);
+ }
+
+ free(mp_subdir);
+ MP_RESIZE_ARRAY(NULL, vobs, n);
+ return vobs;
+}
diff --git a/sub/find_subfiles.h b/sub/find_subfiles.h
index c9b0c9137e..c0391277ee 100644
--- a/sub/find_subfiles.h
+++ b/sub/find_subfiles.h
@@ -22,5 +22,6 @@
#define MAX_SUBTITLE_FILES 128
char **find_text_subtitles(const char *fname);
+char **find_vob_subtitles(const char *fname);
#endif /* MPLAYER_FINDFILES_H */