Commit 55b62a9b authored by Thomas Guillem's avatar 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
parent c7a229ab
......@@ -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", \
......
......@@ -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++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment