Commit 5e89b627 authored by JP Dinger's avatar JP Dinger

playlist sorting: for inline to work, the text has to be available. IE putting...

playlist sorting: for inline to work, the text has to be available. IE putting the function behind all others that use it isn't going to work, and marking forward declarations inline won't help fix it.
parent 048c897e
...@@ -35,7 +35,7 @@ static void playlist_ItemArraySort( int i_items, playlist_item_t **pp_items, ...@@ -35,7 +35,7 @@ static void playlist_ItemArraySort( int i_items, playlist_item_t **pp_items,
int i_mode, int i_type ); int i_mode, int i_type );
static int playlist_cmp( const void *, const void * ); static int playlist_cmp( const void *, const void * );
/* Comparaison functions */ /* Comparison functions */
static int playlist_cmp_album( const playlist_item_t *, const playlist_item_t *); static int playlist_cmp_album( const playlist_item_t *, const playlist_item_t *);
static int playlist_cmp_artist( const playlist_item_t *, const playlist_item_t *); static int playlist_cmp_artist( const playlist_item_t *, const playlist_item_t *);
static int playlist_cmp_desc( const playlist_item_t *, const playlist_item_t *); static int playlist_cmp_desc( const playlist_item_t *, const playlist_item_t *);
...@@ -50,11 +50,78 @@ static int playlist_cmp_title_num( const playlist_item_t *, const playlist_item_ ...@@ -50,11 +50,78 @@ static int playlist_cmp_title_num( const playlist_item_t *, const playlist_item_
static int playlist_cmp_track_num( const playlist_item_t *, const playlist_item_t *); static int playlist_cmp_track_num( const playlist_item_t *, const playlist_item_t *);
static int playlist_cmp_uri( const playlist_item_t *, const playlist_item_t *); static int playlist_cmp_uri( const playlist_item_t *, const playlist_item_t *);
/* General comaraison functions */ /* General comparison functions */
static inline int meta_strcasecmp_title( const playlist_item_t *, /**
const playlist_item_t *); * Compare two items using their title or name
static inline int meta_sort( const playlist_item_t *, const playlist_item_t *, * @param first: the first item
vlc_meta_type_t, bool ); * @param second: the second item
* @return -1, 0 or 1 like strcmp
*/
static inline int meta_strcasecmp_title( const playlist_item_t *first,
const playlist_item_t *second )
{
int i_ret;
char *psz_first = input_item_GetTitleFbName( first->p_input );
char *psz_second = input_item_GetTitleFbName( second->p_input );
if( psz_first && psz_second )
i_ret = strcasecmp( psz_first, psz_second );
else if( !psz_first && psz_second )
i_ret = 1;
else if( psz_first && !psz_second )
i_ret = -1;
else
i_ret = 0;
free( psz_first );
free( psz_second );
return i_ret;
}
/**
* Compare two intems accoring to the given meta type
* @param first: the first item
* @param second: the second item
* @param meta: the meta type to use to sort the items
* @param b_integer: true if the meta are integers
* @return -1, 0 or 1 like strcmp
*/
static inline int meta_sort( const playlist_item_t *first,
const playlist_item_t *second,
vlc_meta_type_t meta, bool b_integer )
{
int i_ret;
char *psz_first = input_item_GetMeta( first->p_input, meta );
char *psz_second = input_item_GetMeta( second->p_input, meta );
/* Nodes go first */
if( first->i_children == -1 && second->i_children >= 0 )
i_ret = 1;
else if( first->i_children >= 0 && second->i_children == -1 )
i_ret = -1;
/* Both are nodes, sort by name */
else if( first->i_children >= 0 && second->i_children >= 0 )
i_ret = meta_strcasecmp_title( first, second );
/* Both are items */
else if( !psz_first && psz_second )
i_ret = 1;
else if( psz_first && !psz_second )
i_ret = -1;
/* No meta, sort by name */
else if( !psz_first && !psz_second )
i_ret = meta_strcasecmp_title( first, second );
else
{
if( b_integer )
i_ret = atoi( psz_first ) - atoi( psz_second );
else
i_ret = strcasecmp( psz_first, psz_second );
}
free( psz_first );
free( psz_second );
return i_ret;
}
/** /**
...@@ -411,76 +478,3 @@ static int playlist_cmp_uri( const playlist_item_t *first, ...@@ -411,76 +478,3 @@ static int playlist_cmp_uri( const playlist_item_t *first,
} }
/**
* Compare two items using their title or name
* @param first: the first item
* @param second: the second item
* @return -1, 0 or 1 like strcmp
*/
static inline int meta_strcasecmp_title( const playlist_item_t *first,
const playlist_item_t *second )
{
int i_ret;
char *psz_first = input_item_GetTitleFbName( first->p_input );
char *psz_second = input_item_GetTitleFbName( second->p_input );
if( psz_first && psz_second )
i_ret = strcasecmp( psz_first, psz_second );
else if( !psz_first && psz_second )
i_ret = 1;
else if( psz_first && !psz_second )
i_ret = -1;
else
i_ret = 0;
free( psz_first );
free( psz_second );
return i_ret;
}
/**
* Compare two intems accoring to the given meta type
* @param first: the first item
* @param second: the second item
* @param meta: the meta type to use to sort the items
* @param b_integer: true if the meta are integers
* @return -1, 0 or 1 like strcmp
*/
static inline int meta_sort( const playlist_item_t *first,
const playlist_item_t *second,
vlc_meta_type_t meta, bool b_integer )
{
int i_ret;
char *psz_first = input_item_GetMeta( first->p_input, meta );
char *psz_second = input_item_GetMeta( second->p_input, meta );
/* Nodes go first */
if( first->i_children == -1 && second->i_children >= 0 )
i_ret = 1;
else if( first->i_children >= 0 && second->i_children == -1 )
i_ret = -1;
/* Both are nodes, sort by name */
else if( first->i_children >= 0 && second->i_children >= 0 )
i_ret = meta_strcasecmp_title( first, second );
/* Both are items */
else if( !psz_first && psz_second )
i_ret = 1;
else if( psz_first && !psz_second )
i_ret = -1;
/* No meta, sort by name */
else if( !psz_first && !psz_second )
i_ret = meta_strcasecmp_title( first, second );
else
{
if( b_integer )
i_ret = atoi( psz_first ) - atoi( psz_second );
else
i_ret = strcasecmp( psz_first, psz_second );
}
free( psz_first );
free( psz_second );
return i_ret;
}
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