[vlc-commits] input: attach slaves to master only

Thomas Guillem git at videolan.org
Mon Dec 4 18:18:22 CET 2017


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Dec  4 17:59:42 2017 +0100| [68378c1fa6b8634d0bb69bc8770da7ecc4e38d6d] | committer: Thomas Guillem

input: attach slaves to master only

The previous logic was wrong. An input item is not necessarily a master if it's
not a slave.

Fixes #19208

(cherry picked from 55b62a9b3428b97b2eb792fbcca6121f01158c07)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=68378c1fa6b8634d0bb69bc8770da7ecc4e38d6d
---

 include/vlc_input_item.h | 12 ++++++++++++
 src/input/item.c         | 15 ++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index b9ee89eeac..89b6324275 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -142,6 +142,18 @@ enum slave_priority
 };
 
 /* Extensions must be in alphabetical order */
+#define MASTER_EXTENSIONS \
+    "asf", "avi", "divx", \
+    "f4v", "flv", "m1v", \
+    "m2v", "m4v", "mkv", \
+    "mov", "mp2", "mp2v", \
+    "mp4", "mp4v", "mpe", \
+    "mpeg", "mpeg1", "mpeg2", \
+    "mpeg4", "mpg", "mpv2", \
+    "mxf", "ogv", "ogx", \
+    "ps", "vro","webm", \
+    "wmv", "wtv"
+
 #define SLAVE_SPU_EXTENSIONS \
     "aqt", "ass",  "cdg", \
     "dks", "idx", "jss", \
diff --git a/src/input/item.c b/src/input/item.c
index 4ed02ab2da..2000de84a2 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -623,6 +623,18 @@ static int bsearch_strcmp_cb(const void *a, const void *b)
     return strcasecmp(a, *entry);
 }
 
+static bool input_item_IsMaster(const char *psz_filename)
+{
+    static const char *const ppsz_master_exts[] = { MASTER_EXTENSIONS };
+
+    const char *psz_ext = strrchr(psz_filename, '.');
+    if (psz_ext == NULL || *(++psz_ext) == '\0')
+        return false;
+
+    return bsearch(psz_ext, ppsz_master_exts, ARRAY_SIZE(ppsz_master_exts),
+                   sizeof(const char *), bsearch_strcmp_cb) != NULL;
+}
+
 bool input_item_slave_GetType(const char *psz_filename,
                               enum slave_type *p_slave_type)
 {
@@ -1558,7 +1570,8 @@ static void rdh_attach_slaves(struct vlc_readdir_helper *p_rdh,
         input_item_t *p_item = p_node->p_item;
 
         enum slave_type unused;
-        if (input_item_slave_GetType(p_item->psz_name, &unused))
+        if (!input_item_IsMaster(p_item->psz_name)
+         || input_item_slave_GetType(p_item->psz_name, &unused))
             continue; /* don't match 2 possible slaves between each others */
 
         for (size_t j = 0; j < p_rdh->i_slaves; j++)



More information about the vlc-commits mailing list