Skip to content
Snippets Groups Projects
Commit 31a41f79 authored by Thomas Guillem's avatar Thomas Guillem
Browse files

input/subtitles: sort subtitles coming from the file system

Keep the same subtitles order than before slaves commits (in order to don't
disturb the user).
parent 23cf1433
No related merge requests found
......@@ -116,6 +116,22 @@ static int whiteonly( const char *s )
return 1;
}
static int slave_strcmp( const void *a, const void *b )
{
const input_item_slave_t *p_slave0 = *((const input_item_slave_t **) a);
const input_item_slave_t *p_slave1 = *((const input_item_slave_t **) b);
if( p_slave0 == NULL || p_slave1 == NULL )
return 0;
/* We can compare these uris since they come from the file system */
#ifdef HAVE_STRCOLL
return strcoll( p_slave0->psz_uri, p_slave1->psz_uri );
#else
return strcmp( p_slave0->psz_uri, p_slave1->psz_uri );
#endif
}
/*
* Check if a file ends with a subtitle extension
*/
......@@ -402,6 +418,10 @@ int subtitles_Detect( input_thread_t *p_this, char *psz_path, const char *psz_na
}
}
/* Sort alphabetically */
if( i_slaves > 0 )
qsort( pp_slaves, i_slaves, sizeof (input_item_slave_t*), slave_strcmp );
*ppp_slaves = pp_slaves; /* in case of realloc */
*p_slaves = i_slaves;
return VLC_SUCCESS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment